简体   繁体   中英

hiddenDOMWindow failed after browser restart

This code works correct after installation extention, but when I restart browser it fails. What is the difference of calling startup function :

on install

on start

code:

function startup(aData, aReason) {
_webSocket = new Services.appShell.hiddenDOMWindow.WebSocket("ws://localhost:8887/");
...
}

error: [JavaScript Warning: "WARN addons.xpi: Exception running bootstrap method startup on screen-capture@smail.com: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIAppShellService.hiddenDOMWindow]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: resource://gre/modules/XPIProvider.jsm -> jar:file:///data/data/org.mozilla.firefox/files/mozilla/lmwz0qwc.default/extensions/screen-capture@smail.com.xpi!/bootstrap.js :: SmartScreencap.connect_ws :: line 89" data: no]" {file: "resource://gre/modules/XPIProvider.jsm -> jar:file:///data/data/org.mozilla.firefox/files/mozilla/lmwz0qwc.default/extensions/screen-capture@smail.com.xpi!/bootstrap.js" line: 89}]

The problem is that Services.appShell.hiddenDOMWindow is not created when function startup(aData, aReason) is colling. So the solution is to add window listener into startup function win.addEventListener('UIReady', function() { ... Services.appShell.hiddenDOMWindow.WebSocket//call function here ... }, false); and call hidden window from callback function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM