Open MarkR42 opened 9 years ago
There is a way to do this, by using the chrome
module:
https://github.com/mozilla/pluotsorbet/blob/9afd89c0079833245de4447fd9dd13366bbc69dd/tests/automation.js#L8
Yes, I see that, I tried using chrome module to set settings, it does work.
I suppose we should update the documentation to give this example.
Mark
On 2 October 2015 at 20:41, Marco notifications@github.com wrote:
There is a way to do this, by using the chrome module:
— Reply to this email directly or view it on GitHub https://github.com/laurentj/slimerjs/issues/385#issuecomment-145136761.
@MarkR42 can you post an example code of setting preferences using chrome module ?
Dmitry, Hi,
This works for me, but there might be a nicer way:
var {Cc, Ci} = require("chrome");
var prefs = Cc["@mozilla.org/preferences-service;1"]
.getService(Ci.nsIPrefService);
var branch = prefs.getBranch("privacy.donottrackheader.");
branch.setBoolPref("enabled", true);
This example sets the "Do not track" flag, which can be tested easily because web servers receive it as a HTTP header "DNT".
Unfortunately very little of the add-on SDK is shipped with SlimerJS, so it's not available (Firefox's own versions, cannot be require()d).
I originally tried: var prefs_service=require("sdk/preferences/service"); prefs_service.set(...
That does NOT work in SlimerJS.
However, because the Firefox addon-SDK is mostly wrappers for XPCOM stuff (as in the example above), it can be used directly.
Mark
As a potential enhancement, it would be really useful to set Mozilla preferences programmatically.