我試圖爲Firefox做一個擴展,我需要使用timbre.js(http://mohayonao.github.io/timbre.js/),所以我想將它包含在contentScriptFile中並在test.js文件中使用它這種方式:firefox add-on include timbre.js
exports.main = function() {
var widget = new Widget({
id: "widget",
label: "Label",
contentURL: "cat.png",
contentScriptFile: [data.url('timbre.js'), data.url('test.js')]
});
的問題是,它不會因爲這個加載:
Timestamp: 16. 07. 13 12:35:33 Error: addon_name: An exception occurred. NS_ERROR_FAILURE: Failure Traceback (most recent call last): File "resource://gre/modules/commonjs/sdk/content/symbiont.js", line 172, in _onReady self._onInit(); File "resource://gre/modules/commonjs/sdk/widget.js", line 803, in null this._initSymbiont(); File "resource://gre/modules/commonjs/sdk/content/symbiont.js", line 200, in Symbiont<._onInit this._initWorker({ window: this._frame.contentWindow }); File "resource://gre/modules/commonjs/sdk/content/worker.js", line 510, in Worker this._contentWorker = WorkerSandbox(this); File "resource://gre/modules/commonjs/sdk/deprecated/traits.js", line 114, in Trait return self.constructor.apply(self, arguments) || self._public; File "resource://gre/modules/commonjs/sdk/content/worker.js", line 302, in WorkerSandbox this._importScripts.apply(this, contentScriptFile); File "resource://gre/modules/commonjs/sdk/content/worker.js", line 361, in _importScripts load(this._sandbox, String(uri)); File "resource://gre/modules/commonjs/sdk/loader/sandbox.js", line 47, in load return scriptLoader.loadSubScript(uri, sandbox, 'UTF-8'); File "resource://jid0-gb1orekgm6ay3hjawryzhdrneug-at-jetpack/synesthesia/data/timbre.js", line 1, in null (function(t){"use strict";function e(){function e(t){for(var e,i=Array(t.byteLength),s=t.BYTES_PER_ELEMENT,n=0,r=i.length;r>n;++n)e=8*(n%s),i[n]=( [...]
即使試圖導入它的require(),但它不工作。 我應該如何導入它? 謝謝再見!
contentScriptFile是Widget的選項。 – pondermatic