Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iFrame cross domain support #122

Open
dgstpierre opened this issue Jul 13, 2022 · 3 comments
Open

iFrame cross domain support #122

dgstpierre opened this issue Jul 13, 2022 · 3 comments

Comments

@dgstpierre
Copy link

Wondering if I'm doing something wrong or iFrame allow support is not yet available. I'm not able to get javascript access to user agent hints (only works on localhost) within an iframe. Need some guidance on how to use allow in a cross-domain setting to be able to access navigator.userAgentData from a script executed from an iframe.

For example:
var iframe = doc.createElement("iframe");
iframe.sandbox = "allow-scripts";
iframe.allow = "ch-ua *; ch-ua-model *";

Is this approach correct? I'm able to access navigator.userAgentData from the page that creates the frame.

@arichiv
Copy link
Collaborator

arichiv commented Jul 13, 2022

It's working for me in jsfiddle (which I believe executes the code in a third-party iframe) https://jsfiddle.net/653kgemv/

Are you getting any console messages and/or are you able to see the results from other scripts you run? Is navigator.userAgentData just returning nothing?

@dgstpierre
Copy link
Author

I left out a key point of information, I'm running in the context of a web worker. Is this supported?

@miketaylr
Copy link
Collaborator

https://wicg.github.io/ua-client-hints/#navigatoruadata should be exposed on workers, as well as window. If you're finding it's not, could you file a bug at crbug.com? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants