I'm using the Firefox Add-on SDK to develop a Firefox add-on. I have followed the Getting Started tutorial .
Firefox version : 41.0.2
My Process is :
jpm run
--> OK the add-on works fine jpm xpi
--> OK : Create @myAddon.xpi (JPM [info] Successfully created .xpi at ...) So, why is the test with jpm run
OK, but does not work after installing the .xpi
file???
I can share the code with you, but how can this situation happen? If it works in test, I expect that it works in "release". I get no error or warning.
High Level :
pageMod.PageMod({
include: "*",
contentScriptFile: [data.url("jquery-1.11.3.min.js"), data.url("./Compute.js")],
onAttach: function (worker) {
var currentUrl = tabs.activeTab.url;
param = currentUrl;
Request({
url: param,
onComplete: function (response) {
var parsed = JSON.parse(response.text);
worker.port.emit('got-request', parsed);
}
}).get();
}
self.port.on('got-request', function (data) {
console.log(data);
});
Edit (moved from comments):
I find something interesting.... Depending on the level of privacy in FireFox the addon will work or not. ( Options->Privacy->History "Remember history " or "Never remember history") - Remember history " --> addOn OK - "Never remember history" --> addOn NOK Any idea why
As you have determined, if you desire your Firefox Add-on SDK add-on to work in Private Browsing mode you need to have add the key private-browsing
with a value of true
in your package.json file.
If you are using no other permissions , you could add a line to your package.json file that looks like:
"permissions": {"private-browsing": true}
The Firefox documentation on writing SDK add-ons for private browsing mode specifically states that the require("sdk/private-browsing").isPrivate()
method will return true when any of the following is the case (emphasis mine):
- a private window, or
- a tab belonging to a private window, or
- a worker that's associated with a document hosted in a private window
- any window, tab, or worker if the browser has been configured to never remember history (Options->Privacy->History)
If you do not have "private-browsing": true
, then, as the documentation states , the following will be the case (emphasis mine):
- the windows module will not list any private browser windows, generate any events for private browser windows, or let the add-on open any private browser windows
- the tabs module will not list any tabs that belong to private browser windows, and the add-on won't receive any events for such tabs
- any ui components will not be displayed in private browser windows
- any menus or menu items created using the context-menu will not be shown in context menus that belong to private browser windows
- the page-mod module will not attach content scripts to documents belonging to private browser windows
- any panel objects will not be shown if the active window is a private browser window
- the selection module will not include any selections made in private browser windows
The net effect will be that your add-on will appear to not work when the profile you are using is configured to never remember history without having the "private-browsing": true
permission in your package.json .
If you do put that permission in your package.json file, you must use the private-browsing module, require("sdk/private-browsing").isPrivate(object)
, to check for being in a private window or tab. If you are in such a window or tab you need to not store any information about such environment.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.