foxr icon indicating copy to clipboard operation
foxr copied to clipboard

implement Prefs class to get/set/clear Firefox preferences

Open deepsweet opened this issue 7 years ago • 1 comments

Will allow to set a dom.w3c_touch_events.enabled = 1 by foxr.connect({ defaultViewport: { hasTouch } }) for elementHandle.tap() method.

deepsweet avatar Sep 06 '18 17:09 deepsweet

Hi! After many researches, I found a way to access to the preferences, which is to use the XPCOM API.

def get_pref(self, pref, default_branch=False, value_type="unspecified"):

 pref_value = self.execute_script("""
 Components.utils.import("resource://gre/modules/Preferences.jsm");
 let pref = arguments[0];
 let defaultBranch = arguments[1];
 let valueType = arguments[2];

 prefs = new Preferences({defaultBranch: defaultBranch});
 return prefs.get(pref, null, Components.interfaces[valueType]);
 """, script_args=(pref, default_branch, value_type))

(picked from here) This seems to be the only option, from what I found. I also saw it in Marionette's maillist. In addition, it's necessary to change the context of the browser, which is trivial to do.

self._send_message("Marionette:SetContext", {"value": context})

(To another extent, I found this in the docs, but I don't know if it could help to find another way to do it)

saidsay-so avatar Jun 30 '19 15:06 saidsay-so