mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset f3011bfcf124 (bug 1240576
) for b2g xpcshell failures CLOSED TREE
This commit is contained in:
parent
a885a7ea86
commit
153a7ce5de
@ -2,13 +2,6 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
|
||||
var CONTEXT_MENU_DELAY_PREF = "ui.click_hold_context_menus.delay";
|
||||
var DEFAULT_CONTEXT_MENU_DELAY = 750; // ms
|
||||
|
||||
this.EXPORTED_SYMBOLS = ["ActionChain"];
|
||||
|
||||
/**
|
||||
@ -25,7 +18,8 @@ this.ActionChain = function(utils, checkForInterrupted) {
|
||||
this.scrolling = false;
|
||||
// whether to send mouse event
|
||||
this.mouseEventsOnly = false;
|
||||
this.checkTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||
this.checkTimer = Components.classes["@mozilla.org/timer;1"]
|
||||
.createInstance(Components.interfaces.nsITimer);
|
||||
|
||||
// callbacks for command completion
|
||||
this.onSuccess = null;
|
||||
@ -264,9 +258,10 @@ ActionChain.prototype.actions = function(chain, touchId, i, keyModifiers) {
|
||||
let time = pack[1] * 1000;
|
||||
|
||||
// standard waiting time to fire contextmenu
|
||||
let standard = Preferences.get(
|
||||
CONTEXT_MENU_DELAY_PREF,
|
||||
DEFAULT_CONTEXT_MENU_DELAY);
|
||||
let standard = 750;
|
||||
try {
|
||||
standard = Services.prefs.getIntPref("ui.click_hold_context_menus.delay");
|
||||
} catch (e) {}
|
||||
|
||||
if (time >= standard && this.isTap) {
|
||||
chain.splice(i, 0, ["longPress"], ["wait", (time - standard) / 1000]);
|
||||
@ -302,6 +297,7 @@ ActionChain.prototype.actions = function(chain, touchId, i, keyModifiers) {
|
||||
keyModifiers);
|
||||
this.actions(chain, touchId, i, keyModifiers);
|
||||
break;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -552,8 +552,8 @@ setReq.onerror = function() {
|
||||
self.marionette.set_context("chrome")
|
||||
self.marionette.execute_script("""
|
||||
let SECURITY_PREF = "security.turn_off_all_security_so_that_viruses_can_take_over_this_computer";
|
||||
Components.utils.import("resource://gre/modules/Preferences.jsm");
|
||||
Preferences.set(SECURITY_PREF, true);
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
Services.prefs.setBoolPref(SECURITY_PREF, true);
|
||||
|
||||
if (!testUtils.hasOwnProperty("specialPowersObserver")) {
|
||||
let loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
|
@ -48,12 +48,11 @@ class BrowserMobProxyTestCaseMixin(object):
|
||||
client = self.browsermob_server.create_proxy()
|
||||
with self.marionette.using_context('chrome'):
|
||||
self.marionette.execute_script("""
|
||||
Components.utils.import("resource://gre/modules/Preferences.jsm");
|
||||
Preferences.set("network.proxy.type", 1);
|
||||
Preferences.set("network.proxy.http", "localhost");
|
||||
Preferences.set("network.proxy.http_port", %(port)s);
|
||||
Preferences.set("network.proxy.ssl", "localhost");
|
||||
Preferences.set("network.proxy.ssl_port", %(port)s);
|
||||
Services.prefs.setIntPref('network.proxy.type', 1);
|
||||
Services.prefs.setCharPref('network.proxy.http', 'localhost');
|
||||
Services.prefs.setIntPref('network.proxy.http_port', %(port)s);
|
||||
Services.prefs.setCharPref('network.proxy.ssl', 'localhost');
|
||||
Services.prefs.setIntPref('network.proxy.ssl_port', %(port)s);
|
||||
""" % {"port": client.port})
|
||||
return client
|
||||
|
||||
|
@ -6,30 +6,28 @@ from marionette import MarionetteTestCase
|
||||
from marionette_driver.by import By
|
||||
|
||||
|
||||
OOP_BY_DEFAULT = "dom.ipc.browser_frames.oop_by_default"
|
||||
BROWSER_FRAMES_ENABLED = "dom.mozBrowserFramesEnabeld"
|
||||
|
||||
|
||||
class TestGetActiveFrameOOP(MarionetteTestCase):
|
||||
def setUp(self):
|
||||
super(TestGetActiveFrameOOP, self).setUp()
|
||||
with self.marionette.using_context("chrome"):
|
||||
self.oop_by_default = self.marionette.get_pref(OOP_BY_DEFAULT)
|
||||
self.mozBrowserFramesEnabled = self.marionette.get_pref(BROWSER_FRAMES_ENABLED)
|
||||
self.marionette.set_pref(OOP_BY_DEFAULT, True)
|
||||
self.marionette.set_pref(BROWSER_FRAMES_ENABLED, True)
|
||||
|
||||
def tearDown(self):
|
||||
with self.marionette.using_context("chrome"):
|
||||
if self.oop_by_default is None:
|
||||
self.marionette.clear_pref(OOP_BY_DEFAULT)
|
||||
else:
|
||||
self.marionette.set_pref(OOP_BY_DEFAULT, self.oop_by_default)
|
||||
|
||||
if self.mozBrowserFramesEnabled is None:
|
||||
self.marionette.clear_pref(BROWSER_FRAMES_ENABLED)
|
||||
else:
|
||||
self.marionette.set_pref(BROWSER_FRAMES_ENABLED, self.mozBrowserFramesEnabled)
|
||||
with self.marionette.using_context('chrome'):
|
||||
self.oop_by_default = self.marionette.execute_script("""
|
||||
try {
|
||||
return Services.prefs.getBoolPref('dom.ipc.browser_frames.oop_by_default');
|
||||
}
|
||||
catch(e) {}
|
||||
""")
|
||||
self.mozBrowserFramesEnabled = self.marionette.execute_script("""
|
||||
try {
|
||||
return Services.prefs.getBoolPref('dom.mozBrowserFramesEnabled');
|
||||
}
|
||||
catch(e) {}
|
||||
""")
|
||||
self.marionette.execute_script("""
|
||||
Services.prefs.setBoolPref('dom.ipc.browser_frames.oop_by_default', true);
|
||||
""")
|
||||
self.marionette.execute_script("""
|
||||
Services.prefs.setBoolPref('dom.mozBrowserFramesEnabled', true);
|
||||
""")
|
||||
|
||||
def test_active_frame_oop(self):
|
||||
self.marionette.navigate(self.marionette.absolute_url("test.html"))
|
||||
@ -96,3 +94,22 @@ class TestGetActiveFrameOOP(MarionetteTestCase):
|
||||
# on a b2g device, the contents do appear
|
||||
# print self.marionette.get_url()
|
||||
# print self.marionette.page_source
|
||||
|
||||
def tearDown(self):
|
||||
with self.marionette.using_context('chrome'):
|
||||
if self.oop_by_default is None:
|
||||
self.marionette.execute_script("""
|
||||
Services.prefs.clearUserPref('dom.ipc.browser_frames.oop_by_default');
|
||||
""")
|
||||
else:
|
||||
self.marionette.execute_script("""
|
||||
Services.prefs.setBoolPref('dom.ipc.browser_frames.oop_by_default', %s);
|
||||
""" % 'true' if self.oop_by_default else 'false')
|
||||
if self.mozBrowserFramesEnabled is None:
|
||||
self.marionette.execute_script("""
|
||||
Services.prefs.clearUserPref('dom.mozBrowserFramesEnabled');
|
||||
""")
|
||||
else:
|
||||
self.marionette.execute_script("""
|
||||
Services.prefs.setBoolPref('dom.mozBrowserFramesEnabled', %s);
|
||||
""" % 'true' if self.mozBrowserFramesEnabled else 'false')
|
||||
|
@ -225,7 +225,7 @@ class TestProxy(MarionetteTestCase):
|
||||
self.marionette.start_session(capabilities)
|
||||
self.fail("We should have started a session because proxy should be a dict")
|
||||
except InvalidArgumentException as e:
|
||||
assert e.msg == "Value of 'proxy' should be an object"
|
||||
assert e.msg == "the value of 'proxy' should be an object"
|
||||
|
||||
def test_proxy_is_passed_in_with_no_proxy_doesnt_set_it(self):
|
||||
capabilities = {"requiredCapabilities":
|
||||
|
@ -5,18 +5,26 @@
|
||||
from marionette import MarionetteTestCase
|
||||
|
||||
|
||||
OOP_BY_DEFAULT = "dom.ipc.browser_frames.oop_by_default"
|
||||
BROWSER_FRAMES_ENABLED = "dom.mozBrowserFramesEnabled"
|
||||
|
||||
|
||||
class TestSwitchRemoteFrame(MarionetteTestCase):
|
||||
def setUp(self):
|
||||
super(TestSwitchRemoteFrame, self).setUp()
|
||||
with self.marionette.using_context('chrome'):
|
||||
self.oop_by_default = self.marionette.get_pref(OOP_BY_DEFAULT)
|
||||
self.mozBrowserFramesEnabled = self.marionette.get_pref(BROWSER_FRAMES_ENABLED)
|
||||
self.marionette.set_pref(OOP_BY_DEFAULT, True)
|
||||
self.marionette.set_pref(BROWSER_FRAMES_ENABLED, True)
|
||||
self.oop_by_default = self.marionette.execute_script("""
|
||||
try {
|
||||
return Services.prefs.getBoolPref('dom.ipc.browser_frames.oop_by_default');
|
||||
}
|
||||
catch(e) {}
|
||||
""")
|
||||
self.mozBrowserFramesEnabled = self.marionette.execute_script("""
|
||||
try {
|
||||
return Services.prefs.getBoolPref('dom.mozBrowserFramesEnabled');
|
||||
}
|
||||
catch(e) {}
|
||||
""")
|
||||
self.marionette.execute_script("""
|
||||
Services.prefs.setBoolPref("dom.ipc.browser_frames.oop_by_default", true);
|
||||
Services.prefs.setBoolPref("dom.mozBrowserFramesEnabled", true);
|
||||
""")
|
||||
|
||||
self.multi_process_browser = self.marionette.execute_script("""
|
||||
try {
|
||||
@ -25,25 +33,12 @@ class TestSwitchRemoteFrame(MarionetteTestCase):
|
||||
return false;
|
||||
}""")
|
||||
|
||||
def tearDown(self):
|
||||
with self.marionette.using_context("chrome"):
|
||||
if self.oop_by_default is None:
|
||||
self.marionette.clear_pref(OOP_BY_DEFAULT)
|
||||
else:
|
||||
self.marionette.set_pref(OOP_BY_DEFAULT, self.oop_by_default)
|
||||
|
||||
if self.mozBrowserFramesEnabled is None:
|
||||
self.marionette.clear_pref(BROWSER_FRAMES_ENABLED)
|
||||
else:
|
||||
self.marionette.set_pref(BROWSER_FRAMES_ENABLED, self.mozBrowserFramesEnabled)
|
||||
|
||||
@property
|
||||
def is_main_process(self):
|
||||
return self.marionette.execute_script("""
|
||||
return Components.classes["@mozilla.org/xre/app-info;1"].
|
||||
getService(Components.interfaces.nsIXULRuntime).
|
||||
processType == Components.interfaces.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
||||
""", sandbox="system")
|
||||
""", sandbox='system')
|
||||
|
||||
def test_remote_frame(self):
|
||||
self.marionette.navigate(self.marionette.absolute_url("test.html"))
|
||||
@ -60,7 +55,7 @@ class TestSwitchRemoteFrame(MarionetteTestCase):
|
||||
""" % self.marionette.absolute_url("test.html"))
|
||||
remote_iframe = self.marionette.find_element("id", "remote_iframe")
|
||||
self.marionette.switch_to_frame(remote_iframe)
|
||||
main_process = self.is_main_process
|
||||
main_process = self.is_main_process()
|
||||
self.assertFalse(main_process)
|
||||
|
||||
def test_remote_frame_revisit(self):
|
||||
@ -79,15 +74,15 @@ class TestSwitchRemoteFrame(MarionetteTestCase):
|
||||
""" % self.marionette.absolute_url("test.html"))
|
||||
self.marionette.switch_to_frame(self.marionette.find_element("id",
|
||||
"remote_iframe"))
|
||||
main_process = self.is_main_process
|
||||
main_process = self.is_main_process()
|
||||
self.assertFalse(main_process)
|
||||
self.marionette.switch_to_frame()
|
||||
main_process = self.is_main_process
|
||||
main_process = self.is_main_process()
|
||||
should_be_main_process = not self.multi_process_browser
|
||||
self.assertEqual(main_process, should_be_main_process)
|
||||
self.marionette.switch_to_frame(self.marionette.find_element("id",
|
||||
"remote_iframe"))
|
||||
main_process = self.is_main_process
|
||||
main_process = self.is_main_process()
|
||||
self.assertFalse(main_process)
|
||||
|
||||
def test_we_can_switch_to_a_remote_frame_by_index(self):
|
||||
@ -105,12 +100,31 @@ class TestSwitchRemoteFrame(MarionetteTestCase):
|
||||
document.body.appendChild(iframe);
|
||||
""" % self.marionette.absolute_url("test.html"))
|
||||
self.marionette.switch_to_frame(0)
|
||||
main_process = self.is_main_process
|
||||
main_process = self.is_main_process()
|
||||
self.assertFalse(main_process)
|
||||
self.marionette.switch_to_frame()
|
||||
main_process = self.is_main_process
|
||||
main_process = self.is_main_process()
|
||||
should_be_main_process = not self.multi_process_browser
|
||||
self.assertEqual(main_process, should_be_main_process)
|
||||
self.marionette.switch_to_frame(0)
|
||||
main_process = self.is_main_process
|
||||
main_process = self.is_main_process()
|
||||
self.assertFalse(main_process)
|
||||
|
||||
def tearDown(self):
|
||||
with self.marionette.using_context('chrome'):
|
||||
if self.oop_by_default is None:
|
||||
self.marionette.execute_script("""
|
||||
Services.prefs.clearUserPref('dom.ipc.browser_frames.oop_by_default');
|
||||
""")
|
||||
else:
|
||||
self.marionette.execute_async_script(
|
||||
"Services.prefs.setBoolPref('dom.ipc.browser_frames.oop_by_default', %s);" %
|
||||
('true' if self.oop_by_default else 'false'))
|
||||
if self.mozBrowserFramesEnabled is None:
|
||||
self.marionette.execute_script("""
|
||||
Services.prefs.clearUserPref('dom.mozBrowserFramesEnabled');
|
||||
""")
|
||||
else:
|
||||
self.marionette.execute_async_script(
|
||||
"Services.prefs.setBoolPref('dom.mozBrowserFramesEnabled', %s);" %
|
||||
('true' if self.mozBrowserFramesEnabled else 'false'))
|
||||
|
@ -110,7 +110,9 @@ MarionetteComponent.prototype.observe = function(subj, topic, data) {
|
||||
// so we wait for that by adding an observer here.
|
||||
this.observerService.addObserver(this, "final-ui-startup", false);
|
||||
#ifdef ENABLE_MARIONETTE
|
||||
this.enabled = Preferences.get(ENABLED_PREF, false);
|
||||
try {
|
||||
this.enabled = Services.prefs.getBoolPref(ENABLED_PREF);
|
||||
} catch(e) {}
|
||||
if (this.enabled) {
|
||||
this.logger.debug("Marionette enabled via build flag and pref");
|
||||
|
||||
@ -163,9 +165,11 @@ MarionetteComponent.prototype.init = function() {
|
||||
|
||||
this.loaded_ = true;
|
||||
|
||||
let forceLocal = Preferences.get(FORCELOCAL_PREF,
|
||||
Services.appinfo.name == "B2G" ? false : true);
|
||||
Preferences.set(FORCELOCAL_PREF, forceLocal);
|
||||
let forceLocal = Services.appinfo.name == "B2G" ? false : true;
|
||||
try {
|
||||
forceLocal = Services.prefs.getBoolPref(FORCELOCAL_PREF);
|
||||
} catch (e) {}
|
||||
Services.prefs.setBoolPref(FORCELOCAL_PREF, forceLocal);
|
||||
|
||||
if (!forceLocal) {
|
||||
// See bug 800138. Because the first socket that opens with
|
||||
@ -178,7 +182,10 @@ MarionetteComponent.prototype.init = function() {
|
||||
insaneSacrificialGoat.asyncListen(this);
|
||||
}
|
||||
|
||||
let port = Preferences.get(PORT_PREF, DEFAULT_PORT);
|
||||
let port = DEFAULT_PORT;
|
||||
try {
|
||||
port = Services.prefs.getIntPref(PORT_PREF);
|
||||
} catch (e) {}
|
||||
|
||||
let s;
|
||||
try {
|
||||
|
@ -7,7 +7,6 @@
|
||||
const {interfaces: Ci, utils: Cu} = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/Log.jsm");
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
Cu.import("resource://gre/modules/Task.jsm");
|
||||
|
||||
Cu.import("chrome://marionette/content/driver.js");
|
||||
|
@ -12,7 +12,6 @@ var loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
Cu.import("resource://gre/modules/FileUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Log.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/Task.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
@ -366,9 +365,9 @@ GeckoDriver.prototype.whenBrowserStarted = function(win, isNewSession) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!Preferences.get(CONTENT_LISTENER_PREF) || !isNewSession) {
|
||||
if (!Services.prefs.getBoolPref("marionette.contentListener") || !isNewSession) {
|
||||
mm.loadFrameScript(FRAME_SCRIPT, true, true);
|
||||
Preferences.set(CONTENT_LISTENER_PREF, true);
|
||||
Services.prefs.setBoolPref("marionette.contentListener", true);
|
||||
}
|
||||
} catch (e) {
|
||||
// there may not always be a content process
|
||||
@ -544,7 +543,10 @@ GeckoDriver.prototype.newSession = function(cmd, resp) {
|
||||
};
|
||||
win.addEventListener("load", listener, true);
|
||||
} else {
|
||||
let clickToStart = Preferences.get(CLICK_TO_START_PREF);
|
||||
let clickToStart;
|
||||
try {
|
||||
clickToStart = Services.prefs.getBoolPref(CLICK_TO_START_PREF);
|
||||
} catch (e) {}
|
||||
if (clickToStart && (this.appName != "B2G")) {
|
||||
let pService = Cc["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Ci.nsIPromptService);
|
||||
@ -555,7 +557,7 @@ GeckoDriver.prototype.newSession = function(cmd, resp) {
|
||||
};
|
||||
|
||||
let runSessionStart = function() {
|
||||
if (!Preferences.get(CONTENT_LISTENER_PREF)) {
|
||||
if (!Services.prefs.getBoolPref(CONTENT_LISTENER_PREF)) {
|
||||
waitForWindow.call(this);
|
||||
} else if (this.appName != "Firefox" && this.curBrowser === null) {
|
||||
// if there is a content listener, then we just wake it up
|
||||
@ -670,49 +672,45 @@ GeckoDriver.prototype.setSessionCapabilities = function(newCaps) {
|
||||
};
|
||||
|
||||
GeckoDriver.prototype.setUpProxy = function(proxy) {
|
||||
logger.config("User-provided proxy settings: " + JSON.stringify(proxy));
|
||||
logger.debug("User-provided proxy settings: " + JSON.stringify(proxy));
|
||||
|
||||
if (typeof proxy == "object" && proxy.hasOwnProperty("proxyType")) {
|
||||
switch (proxy.proxyType.toUpperCase()) {
|
||||
case "MANUAL":
|
||||
Preferences.set("network.proxy.type", 1);
|
||||
Services.prefs.setIntPref("network.proxy.type", 1);
|
||||
if (proxy.httpProxy && proxy.httpProxyPort){
|
||||
Preferences.set("network.proxy.http", proxy.httpProxy);
|
||||
Preferences.set("network.proxy.http_port", proxy.httpProxyPort);
|
||||
Services.prefs.setCharPref("network.proxy.http", proxy.httpProxy);
|
||||
Services.prefs.setIntPref("network.proxy.http_port", proxy.httpProxyPort);
|
||||
}
|
||||
if (proxy.sslProxy && proxy.sslProxyPort){
|
||||
Preferences.set("network.proxy.ssl", proxy.sslProxy);
|
||||
Preferences.set("network.proxy.ssl_port", proxy.sslProxyPort);
|
||||
Services.prefs.setCharPref("network.proxy.ssl", proxy.sslProxy);
|
||||
Services.prefs.setIntPref("network.proxy.ssl_port", proxy.sslProxyPort);
|
||||
}
|
||||
if (proxy.ftpProxy && proxy.ftpProxyPort) {
|
||||
Preferences.set("network.proxy.ftp", proxy.ftpProxy);
|
||||
Preferences.set("network.proxy.ftp_port", proxy.ftpProxyPort);
|
||||
Services.prefs.setCharPref("network.proxy.ftp", proxy.ftpProxy);
|
||||
Services.prefs.setIntPref("network.proxy.ftp_port", proxy.ftpProxyPort);
|
||||
}
|
||||
if (proxy.socksProxy) {
|
||||
Preferences.set("network.proxy.socks", proxy.socksProxy);
|
||||
Preferences.set("network.proxy.socks_port", proxy.socksProxyPort);
|
||||
Services.prefs.setCharPref("network.proxy.socks", proxy.socksProxy);
|
||||
Services.prefs.setIntPref("network.proxy.socks_port", proxy.socksProxyPort);
|
||||
if (proxy.socksVersion) {
|
||||
Preferences.set("network.proxy.socks_version", proxy.socksVersion);
|
||||
Services.prefs.setIntPref("network.proxy.socks_version", proxy.socksVersion);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case "PAC":
|
||||
Preferences.set("network.proxy.type", 2);
|
||||
Preferences.set("network.proxy.autoconfig_url", proxy.pacUrl);
|
||||
Services.prefs.setIntPref("network.proxy.type", 2);
|
||||
Services.prefs.setCharPref("network.proxy.autoconfig_url", proxy.pacUrl);
|
||||
break;
|
||||
|
||||
case "AUTODETECT":
|
||||
Preferences.set("network.proxy.type", 4);
|
||||
Services.prefs.setIntPref("network.proxy.type", 4);
|
||||
break;
|
||||
|
||||
case "SYSTEM":
|
||||
Preferences.set("network.proxy.type", 5);
|
||||
Services.prefs.setIntPref("network.proxy.type", 5);
|
||||
break;
|
||||
|
||||
case "NOPROXY":
|
||||
default:
|
||||
Preferences.set("network.proxy.type", 0);
|
||||
Services.prefs.setIntPref("network.proxy.type", 0);
|
||||
}
|
||||
} else {
|
||||
throw new InvalidArgumentError("Value of 'proxy' should be an object");
|
||||
@ -2452,7 +2450,7 @@ GeckoDriver.prototype.sessionTearDown = function(cmd, resp) {
|
||||
this.curBrowser.knownFrames.indexOf(this.curBrowser.mainContentId), 1);
|
||||
} else {
|
||||
// don't set this pref for B2G since the framescript can be safely reused
|
||||
Preferences.set(CONTENT_LISTENER_PREF, false);
|
||||
Services.prefs.setBoolPref("marionette.contentListener", false);
|
||||
}
|
||||
|
||||
// delete session in each frame in each browser
|
||||
|
@ -967,26 +967,39 @@ class Marionette(object):
|
||||
self.push_permission(perm, original_perms[perm])
|
||||
|
||||
def get_pref(self, pref):
|
||||
"""Gets the preference value.
|
||||
'''Gets the preference value.
|
||||
|
||||
:param pref: Name of the preference.
|
||||
|
||||
Usage example::
|
||||
|
||||
marionette.get_pref("browser.tabs.warnOnClose")
|
||||
"""
|
||||
marionette.get_pref('browser.tabs.warnOnClose')
|
||||
|
||||
'''
|
||||
with self.using_context(self.CONTEXT_CONTENT):
|
||||
pref_value = self.execute_script("""
|
||||
Components.utils.import("resource://gre/modules/Preferences.jsm");
|
||||
return Preferences.get(arguments[0], null);
|
||||
""", script_args=[pref], sandbox="system")
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
let pref = arguments[0];
|
||||
let type = Services.prefs.getPrefType(pref);
|
||||
switch (type) {
|
||||
case Services.prefs.PREF_STRING:
|
||||
return Services.prefs.getCharPref(pref);
|
||||
case Services.prefs.PREF_INT:
|
||||
return Services.prefs.getIntPref(pref);
|
||||
case Services.prefs.PREF_BOOL:
|
||||
return Services.prefs.getBoolPref(pref);
|
||||
case Services.prefs.PREF_INVALID:
|
||||
return null;
|
||||
}
|
||||
""", script_args=[pref], sandbox='system')
|
||||
return pref_value
|
||||
|
||||
def clear_pref(self, pref):
|
||||
with self.using_context(self.CONTEXT_CHROME):
|
||||
self.execute_script("""
|
||||
Components.utils.import("resource://gre/modules/Preferences.jsm");
|
||||
Preferences.reset(arguments[0]);
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
let pref = arguments[0];
|
||||
Services.prefs.clearUserPref(pref);
|
||||
""", script_args=[pref])
|
||||
|
||||
def set_pref(self, pref, value):
|
||||
@ -995,10 +1008,22 @@ class Marionette(object):
|
||||
self.clear_pref(pref)
|
||||
return
|
||||
|
||||
if isinstance(value, bool):
|
||||
func = 'setBoolPref'
|
||||
elif isinstance(value, (int, long)):
|
||||
func = 'setIntPref'
|
||||
elif isinstance(value, basestring):
|
||||
func = 'setCharPref'
|
||||
else:
|
||||
raise errors.MarionetteException(
|
||||
"Unsupported preference type: %s" % type(value))
|
||||
|
||||
self.execute_script("""
|
||||
Components.utils.import("resource://gre/modules/Preferences.jsm");
|
||||
Preferences.set(arguments[0], arguments[1]);
|
||||
""", script_args=[pref, value])
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
let pref = arguments[0];
|
||||
let value = arguments[1];
|
||||
Services.prefs.%s(pref, value);
|
||||
""" % func, script_args=[pref, value])
|
||||
|
||||
def set_prefs(self, prefs):
|
||||
'''Sets preferences.
|
||||
|
@ -10,7 +10,6 @@ var loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSub
|
||||
const ServerSocket = CC("@mozilla.org/network/server-socket;1", "nsIServerSocket", "initSpecialConnection");
|
||||
|
||||
Cu.import("resource://gre/modules/Log.jsm");
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
Cu.import("chrome://marionette/content/dispatcher.js");
|
||||
@ -30,9 +29,7 @@ loader.loadSubScript("chrome://marionette/content/frame-manager.js");
|
||||
const logger = Log.repository.getLogger("Marionette");
|
||||
|
||||
this.EXPORTED_SYMBOLS = ["MarionetteServer"];
|
||||
|
||||
const CONTENT_LISTENER_PREF = "marionette.contentListener";
|
||||
const MANAGE_OFFLINE_STATUS_PREF = "network.gonk.manage-offline-status";
|
||||
|
||||
/**
|
||||
* Bootstraps Marionette and handles incoming client connections.
|
||||
@ -87,11 +84,11 @@ MarionetteServer.prototype.driverFactory = function(emulator) {
|
||||
device = "desktop";
|
||||
}
|
||||
|
||||
Preferences.set(CONTENT_LISTENER_PREF, false);
|
||||
Services.prefs.setBoolPref(CONTENT_LISTENER_PREF, false);
|
||||
|
||||
if (bypassOffline) {
|
||||
logger.debug("Bypassing offline status");
|
||||
Preferences.set(MANAGE_OFFLINE_STATUS_PREF, false);
|
||||
Services.prefs.setBoolPref("network.gonk.manage-offline-status", false);
|
||||
Services.io.manageOfflineStatus = false;
|
||||
Services.io.offline = false;
|
||||
}
|
||||
@ -149,5 +146,9 @@ MarionetteServer.prototype.onConnectionClosed = function(conn) {
|
||||
};
|
||||
|
||||
function isMulet() {
|
||||
return Preferences.get("b2g.is_mulet", false);
|
||||
try {
|
||||
return Services.prefs.getBoolPref("b2g.is_mulet");
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user