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

Cross-origin iframe doesn't have accessible "parent" and "top" properties in "window.parent" #6144

Closed
yss50829 opened this issue Sep 8, 2017 · 4 comments
Assignees

Comments

@yss50829
Copy link

yss50829 commented Sep 8, 2017

NWJS Version : sdk-0.25.0 (same in sdk-0.22.3)
Operating System : Win7, x64

Expected behavior

window.parent.parent and window.parent.top should return a Window and shouldn't throw error in cross-origin iframe. It's behavior of Google Chrome.

Actual behavior

VM346:1 Uncaught DOMException: Blocked a frame with origin "..." from accessing a cross-origin frame.
    at <anonymous>:1:15

How to reproduce

  1. Launch nw.exe
  2. Open DevTools
  3. Run in console
var iframe = document.createElement('iframe');
iframe.src = 'https://example.com/';
document.body.appendChild(iframe);
  1. Switch frame selector for console from "top" to "example.com"
  2. Run in console window.parent.parent (in "example.com" iframe)

Real issue

Google IMA is not working in NW.js because of exception in part of code

for (var f = 0; e != e.parent; )
            f++,
            e = e.parent;

where variable "e" is equal to "window".
You can check it on page: https://developers.google.com/interactive-media-ads/docs/sdks/html5/vastinspector
You will see cross-origin exceptions in console.
Note please, that in version 0.25.0 page with Google IMA library becomes unresponsive on load, so you should use earlier versions for reproducing exactly this issue.

@fastCargo
Copy link

you can try adding this to package.json to avoid the cors error:

"chromium-args": "--disable-web-security",

@yss50829
Copy link
Author

yss50829 commented Sep 9, 2017

I have used it already as a temporary solution, but it adds a serious vulnerability to app. So this issue is important to be fixed.

@Christywl
Copy link
Contributor

I can reproduce this issue on Linux/Windows with nwjs-sdk-v0.25.0.

@rogerwang
Copy link
Member

This shares the same root cause and fixed in #6099 . Please reopen if it's not.

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

No branches or pull requests

4 participants