nw.js icon indicating copy to clipboard operation
nw.js copied to clipboard

Webview : contentWindow not available at this time

Open kamesh-a opened this issue 11 years ago • 5 comments

Webview tag creation and appending is successful, but only mode of communication with webview is postMessaging. in such case contentWindow is not available.

snippet:

var _webview = document.createElement('webview');
_webview.src = "http://google.com";
document.body.appendChild(_webview);

console.log( _webview.contentWindow );

expected : contentWindow of webview source behavior : "ContentWindow is not available at this time"

But the source frame is completely loaded. onload is triggered properly. take a look at the attached screenshot

_webview

kamesh-a avatar Feb 24 '15 10:02 kamesh-a

Added to it: Worked in nwjs : 0.12.0-alpha1 Not working in nwjs : 0.12.0-alpha3

kamesh-a avatar Feb 24 '15 10:02 kamesh-a

Hi @rogerwang

Thanks , for working on this issue, Fix works great. Just thought of asking your views on this, How we can debug or inspect things withing webview. Do we have way to show them in DevTools as how the iframe are shown with host/document.title names in Chrom Dev Tools.

Cheers !!!

kamesh-a avatar Mar 09 '15 14:03 kamesh-a

@kamesh-a devtools works differently. each webview have it's own dedicated devtool.

supposing your devtools port is 9222: package.json

    "chromium-args": "--remote-debugging-port=9222"

Go to http://localhost:9222/json to get the list of windows and webviews and their associated devtools frontend url. Then open it in chrome or nwjs (it should looks like http://localhost:9222/devtools/inspector.html?ws=localhost:9229/devtools/page/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX)

felicienfrancois avatar Mar 09 '15 16:03 felicienfrancois

@felicienfrancois got it !! thank you :+1:

@rogerwang i was experimenting sending a postMessage to contentWindow, it seems contentWindow is not pointing to the actual document.

my postMessages are not reaching webviews contentWindow. Strange this noticed:

Expected Behaviour : _webview.contentWindow.document = it own src, Document Current Behaviour: _webview.contentWindow.document == points to Whole HTML document which was used for embedding webview

this makes me thing the message which i am posting contentWindow is going to someOther window. so window object is not pointing to src of webview (.i.e, in example http://google.com )

nw_contentwindow_document_mismatch nw_doc_and_window_mismatch

You can witness the hover of whole document. Can you please open the issue. Do let me know if you need any info or queries regarding this.

kamesh-a avatar Mar 10 '15 10:03 kamesh-a

@felicienfrancois Need to mention that package.json is not the only way to activate remote debugger, you can just add --remote-debugging-port=9222 to nw command line.

offshore avatar Jan 25 '16 08:01 offshore