Hello,
I am trying to write a firefox addon that will read about:config preferences.
My main.js is as follows :
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
var data = require("sdk/self").data;
var window = require("sdk/windows").browserWindows;
var text_entry = require("sdk/panel").Panel({
contentURL: data.url("myaddon.html"),
contentScriptFile: data.url("myscript.js"),
width:1000,
height:700
});
// Create a button
var button = require("sdk/ui/button/action").ActionButton({
id: "show-panel",
label: "Read Preferences",
icon: {
//"16": "./icon-16.jpg",
"16": "./abc.jpg",
"32": "./def.png",
"64": "./ghi.png"
},
onClick: handleClick
});
// Show the panel when the user clicks the button.
function handleClick(state) {
text_entry.show({
position:button
});
}
const {Cc, Ci} = require("chrome");
var prefService = Cc["@
mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
var prefBranch = Cc["@
mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService);
var firefox = Cc["@
mozilla.org/fuel/application;1"].getService(Ci.fuelIApplication);
var default_values = [ prefBranch.getBoolPref("browser.safebrowsing.enabled"),
prefBranch.getBoolPref("browser.safebrowsing.malware.enabled"),
prefBranch.getBoolPref("dom.event.clipboardevents.enabled"),
prefBranch.getBoolPref("dom.storage.enabled"),
prefBranch.getBoolPref("geo.enabled"),
prefBranch.getCharPref("geo.wifi.uri"), //string
prefBranch.getIntPref("network.cookie.cookieBehavior"), //integer
prefBranch.getIntPref("network.cookie.lifetimePolicy"), //integer
prefBranch.getBoolPref("network.dns.disablePrefetch"),
prefBranch.getIntPref("network.http.sendRefererHeader"), //integer
prefBranch.getBoolPref("network.http.sendSecureXSiteReferrer"),
prefBranch.getBoolPref("network.prefetch-next"),
prefBranch.getBoolPref("privacy.donottrackheader.enabled"),
prefBranch.getBoolPref("toolkit.telemetry.enabled")];
text_entry.port.emit("default_values", default_values);
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Problem :
1. When I am trying to run the addon using $ cfx run, I am not able to find the current values of the preference - the values shown are the default values and
not the current values of the preferences (I have observed this using about:config preference values).
2. When I tried the same code on Firefox 34, it is showing the current values but the code is not giving the expected output when running on Firefox 38.
Help needed to :
1. Check whether my above code is wrong?
2. If the code is wrong then need guidance to correct the code
Thanks & Regards
Harshad