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

webview.executeScript wrong context #6229

Closed
iteufel opened this issue Oct 24, 2017 · 9 comments
Closed

webview.executeScript wrong context #6229

iteufel opened this issue Oct 24, 2017 · 9 comments

Comments

@iteufel
Copy link
Contributor

iteufel commented Oct 24, 2017

NWJS Version : 0.26.0
Operating System : macos

Expected behavior

webview.executeScript({code: 'console.log(window)'}, console.log)
should log the window object

Actual behavior

webview.executeScript({code: 'console.log(window)'}, console.log)
logs the wrong window object

How to reproduce

webview.executeScript.example.zip

@Christywl
Copy link
Contributor

Christywl commented Oct 25, 2017

I try the sample on Mac with nwjs-sdk-v0.26.0, here is my result, it returns null.

screen shot 2017-10-25 at 9 52 29 am

@rogerwang
Copy link
Member

It's executed in the right context. It's just the issue of accessing returned window object. Will look into this.

If you execute document.body.style.backgroundColor = "red"; everything works fine.

@rogerwang
Copy link
Member

Turns out it's executed in a isolated world on purpose by upstream: https://stackoverflow.com/a/24435983/180197

Will remove this limitation for NW app.

@rogerwang rogerwang added test-todo and removed WIP labels Nov 7, 2017
@rogerwang
Copy link
Member

This is fixed in git and will be available in the next nightly build.

@phiSgr
Copy link

phiSgr commented Nov 13, 2017

I have some workaround code that depends on the code being executed in the extension "isolated world" context. Is it possible, in the future, to have extra fields in the InjectDetails to determine the context?

@rogerwang
Copy link
Member

@phiSgr yes. Please file another issue for this feature.

@rogerwang
Copy link
Member

Will add a boolean field mainWorld in InjectDetails to control the world where the code would run. The default value would be false to keep align with upstream. Thanks.

@gpetrov
Copy link

gpetrov commented Dec 6, 2017

@rogerwang are those new options already available? Or coming up in the new release?

@rogerwang
Copy link
Member

rogerwang commented Dec 6, 2017 via email

wanghongjuan added a commit to wanghongjuan/nw.js that referenced this issue Jan 18, 2018
- Add test for isseu nwjs#6229
- This case is failed on failed version 0.26.0, pass on fixed version 0.27.4
@wanghongjuan wanghongjuan self-assigned this Jan 18, 2018
wanghongjuan added a commit to wanghongjuan/nw.js that referenced this issue Jan 26, 2018
- Add test for isseu nwjs#6229
- This case is failed on failed version 0.26.0, pass on fixed version 0.27.4
wanghongjuan added a commit to wanghongjuan/nw.js that referenced this issue Feb 9, 2018
- Add test for isseu nwjs#6229
- This case is failed on failed version 0.26.0, pass on fixed version 0.27.4
rogerwang pushed a commit that referenced this issue Feb 10, 2018
- Add test for isseu #6229
- This case is failed on failed version 0.26.0, pass on fixed version 0.27.4
wanghongjuan added a commit to wanghongjuan/nw.js that referenced this issue Feb 24, 2018
- Add test for issue nwjs#6229
- This case is failed on failed version 0.26.0, pass on fixed version 0.27.4
rogerwang pushed a commit that referenced this issue Mar 5, 2018
- Add test for issue #6229
- This case is failed on failed version 0.26.0, pass on fixed version 0.27.4
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

6 participants