Is it possible to open development tools for background page (application has no windows)?
I thought it might be something like
// in bg context
nw.Window.get().showDevTools();
But it crashes (#4368), however @rogerwang mentioned that although background page has no corresponding window, call to nw.Window.get() inside it's context should not crash.
Am I missing something?
It should be possible. For now you can do that with "inspect background page" in the context menu of SDK build.
But mister, I dont have a UI on which I can invoke context menu!..
var gui = require('nw.gui');
var win = gui.Window.get();
win.showDevTools();
Work for background app on my side
@thib3113 this is the same as nw.Window.get().showDevTools() (crashes nw).
Again, my app is headless: main field in package.json points to .js file.
@offshore I don't know what was in your "nw" var ... I use 脿 main html just for include the js on my side, so, its different.
Calling Window.get() will now throw an error, as seen in the commit of this fixed ticket: #4368
So I guess the only way to get the BG dev tools is by using the context menu on the main page :/
This isn't really an answer to this issue but maybe some people aren't aware of it. You can debug the background page in devtools by using remote debugging in Chrome.
@offshore I found an interim solution here: https://github.com/nwjs/nw.js/issues/4881 . Works for me :)
chrome.developerPrivate.openDevTools({
renderViewId: -1,
renderProcessId: -1,
extensionId: chrome.runtime.id
})
@applebya, excellent, thank you!
Is there a solution to this? I still have this issue of unable to see the inspect background option
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
@offshore I found an interim solution here: https://github.com/nwjs/nw.js/issues/4881 . Works for me :)