Firefox SDK extension - JPM error [closed]

痞子三分冷 提交于 2020-01-25 21:06:06

问题


Since last night, i'm getting this error out of the blue, when trying to communicate with a content script, after the "ready" event is fired in the tab that loads the page to which the script is being attached to.

console.error:
JPM [error]   Message: TypeError: this.sandbox is undefined
Stack:
receive@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/content/worker-child.js:87:7
emitOnObject@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/event/core.js:112:9
emit@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/event/core.js:89:38
messageReceived@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/remote/child.js:67:37

In desperation i even tried copy pasting the code from the mozilla website:

in index.js:

var data = require("sdk/self").data;
var pageMod = require("sdk/page-mod");

pageMod.PageMod({
  include: "*",
  contentScriptFile: data.url("element-getter.js"),
  onAttach: function(worker) {
   worker.port.emit("myCustomEvent", "mymessage");
   worker.port.on("backEvent", function(content) {
     console.log(content);
   });
  }
});

in element.getter.js:

self.port.on("myCustomEvent", function(message) {
   self.port.emit("backEvent", "newMessage");
});

Same error appears wen trying to communicate via workers, between main script and content scripts, using the "tabs" sdk module.

EDIT: Can someone else please if confirm/deny this behavior?

Any ideas are welcome!

I've submitted a bug report here: https://bugzilla.mozilla.org/show_bug.cgi?id=1314557


回答1:


Soo.. if you don't "jpm init" in the new folder, and copy-paste the contents of another, previously initialized folder, inside - you get the above error. Mistake on my part.



来源:https://stackoverflow.com/questions/40375547/firefox-sdk-extension-jpm-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!