NWJS Version : 0.26.0
Operating System : macos
webview.executeScript({code: 'console.log(window)'}, console.log)
should log the window object
webview.executeScript({code: 'console.log(window)'}, console.log)
logs the wrong window object
I try the sample on Mac with nwjs-sdk-v0.26.0, here is my result, it returns null.

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.
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.
This is fixed in git and will be available in the next nightly build.
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?
@phiSgr yes. Please file another issue for this feature.
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.
@rogerwang are those new options already available? Or coming up in the new release?
Yes see
http://nwjs.readthedocs.io/en/nw27/References/webview%20Tag/#executescript-in-main-world
It's in 0.27 nightly and will be released with 0.27.0 in 1 or 2 days.
On Dec 6, 2017 8:26 PM, "George Petrov" notifications@github.com wrote:
@rogerwang https://github.com/rogerwang are those new options already
available? Or coming up in the new release?—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/nwjs/nw.js/issues/6229#issuecomment-349624550, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAKGGRDXsBhRlnZGhfXU754Anzx_CLMXks5s9ofpgaJpZM4QFIg0
.
Most helpful comment
This is fixed in git and will be available in the next nightly build.