[英]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}] 错误:[JavaScript警告:“ WARN addons.xpi:在screen-capture@smail.com上运行引导方法启动时发生异常:[异常...”,组件返回失败代码:0x80004005(NS_ERROR_FAILURE)[nsIAppShellService.hiddenDOMWindow]“ nsresult:” 0x80004005(NS_ERROR_FAILURE)“位置:” JS框架::资源://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 ::第89行“数据:否]” {文件:“资源://gre/modules/XPIProvider.jsm-> jar: file:///data/data/org.mozilla.firefox/files/mozilla/lmwz0qwc.default/extensions/screen-capture@smail.com.xpi!/bootstrap.js“行:89}]
The problem is that Services.appShell.hiddenDOMWindow is not created when function startup(aData, aReason)
is colling. 问题在于,当
function startup(aData, aReason)
时,不会创建Services.appShell.hiddenDOMWindow。 So the solution is to add window listener into startup function win.addEventListener('UIReady', function() { ... Services.appShell.hiddenDOMWindow.WebSocket//call function here ... }, false);
因此,解决方案是将窗口侦听器添加到启动函数
win.addEventListener('UIReady', function() { ... Services.appShell.hiddenDOMWindow.WebSocket//call function here ... }, false);
and call hidden window from callback function. 并从回调函数调用隐藏窗口。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.