我正在使用 Mozilla addons-sdk 制作 Firefox 扩展。我在面板中显示一个特定的 HTML 页面。根据收到的某个事件,我想重新加载扩展程序(而不仅仅是页面)。重新加载 = 重新运行 main.js,就像浏览器重新启动时一样。
仅重新加载 HTML 页面的问题在于,当重新加载发生时,page-worker 仍然是旧的,并且在重新加载期间接收到的事件没有得到正确处理。对应于这些事件,您会收到以下错误:
Timestamp: 4/11/13 12:34:20 PM
Error: ubp-install: An exception occurred.
Traceback (most recent call last):
File "resource://onebutton-at-user043-dot-com/addon-sdk/lib/sdk/panel.js", line 273, in _onHide
this._emit('hide');
File "resource://onebutton-at-user043-dot-com/addon-sdk/lib/sdk/deprecated/events.js", line 123, in _emit
return this._emitOnObject.apply(this, args);
File "resource://onebutton-at-user043-dot-com/addon-sdk/lib/sdk/deprecated/events.js", line 153, in _emitOnObject
listener.apply(targetObj, params);
File "resource://onebutton-at-user043-dot-com/ubp-install/lib/main.js", line 232, in
type: 'Application_reload'
File "resource://onebutton-at-user043-dot-com/addon-sdk/lib/sdk/content/worker.js", line 369, in
emit: function () self._emitEventToContent(Array.slice(arguments))
File "resource://onebutton-at-user043-dot-com/addon-sdk/lib/sdk/content/worker.js", line 404, in _emitEventToContent
throw new Error(ERR_FROZEN);
Error: The page is currently hidden and can no longer be used until it is visible again.
简而言之,我需要一种重新加载 Firefox 扩展的方法。