Reputation: 504
I have a page I display with a pageMod.PageMod
call. Within the script I pass along with the html I display, I use a self.port.on
to listen to changes to underlying data that needs to be reflected in the page displayed.
If I run my addon using cfx run
, I have a fully functioning add that works without problems.
However, if I package my addon using cfx xpi
, then I go to my 'normal' firfox browser and install the addon using File -> Open File, the addon installs, I get an error message in the browser console that TypeError: self.port is undefined
.
If I run cfx run
, the browser version is 28.0, the same as my 'normal' browser. Why does it work with cfx run, but not my normal browser?
Here is the following code that causes the error, but I don't think it will help (options.js):
/*************************************************
* MESSAGE RECEIVED WHEN A
* CHANGE IS MADE TO UNDERLYING DATA
* USED BY THIS PAGE
**************************************************/
self.port.on("username", function(data){
console.log("received username data");
if(data=="false"){
lg = false;
}else{
lg = true;
username = data;
}
//update page
k();
});
And to add a but more context, here is how the pagemode is being instantiaed/called:
function init(cb){
var menuitem = require("menuitems").Menuitem({
id: "clickme",
menuid: "menu_ToolsPopup",
label: "Tetherly Options",
onCommand: function() {
menuitem_onclicked(cb);
},
insertbefore: "menu_pageInfo"
});
}
function menuitem_onclicked(cb){
console.log("clicked");
//open a new tab with options page...
//attach page mod script to it...
pageMod.PageMod({
include: self.data.url("html/options.html"),
contentScriptFile: [
self.data.url("js/jquery-1.11.0.js"),
self.data.url("js/options.js")
],
onAttach: function(worker) {
pagemode_onattach(worker,cb);
}
});
tabs.open(self.data.url("html/options.html"));
}
Upvotes: 0
Views: 102
Reputation: 504
So the error was with my package.json file.
I replaced this line:
"dependencies": ["menuitems", "addon-sdk"]
with:
"dependencies": ["menuitems"]
and the problem was resolved.
Upvotes: 1