diff --git a/testing/marionette/client/marionette/marionette.py b/testing/marionette/client/marionette/marionette.py index 2c2923261711..1235e3e9acdd 100644 --- a/testing/marionette/client/marionette/marionette.py +++ b/testing/marionette/client/marionette/marionette.py @@ -322,7 +322,7 @@ class Marionette(object): return unwrapped - def execute_js_script(self, script, script_args=None, timeout=True, new_sandbox=True): + def execute_js_script(self, script, script_args=None, timeout=True, new_sandbox=True, special_powers=False): if script_args is None: script_args = [] args = self.wrapArguments(script_args) @@ -331,10 +331,11 @@ class Marionette(object): value=script, args=args, timeout=timeout, - newSandbox=new_sandbox) + newSandbox=new_sandbox, + specialPowers=special_powers) return self.unwrapValue(response) - def execute_script(self, script, script_args=None, new_sandbox=True): + def execute_script(self, script, script_args=None, new_sandbox=True, special_powers=False): if script_args is None: script_args = [] args = self.wrapArguments(script_args) @@ -342,10 +343,11 @@ class Marionette(object): 'value', value=script, args=args, - newSandbox=new_sandbox) + newSandbox=new_sandbox, + specialPowers=special_powers) return self.unwrapValue(response) - def execute_async_script(self, script, script_args=None, new_sandbox=True): + def execute_async_script(self, script, script_args=None, new_sandbox=True, special_powers=False): if script_args is None: script_args = [] args = self.wrapArguments(script_args) @@ -353,7 +355,8 @@ class Marionette(object): 'value', value=script, args=args, - newSandbox=new_sandbox) + newSandbox=new_sandbox, + specialPowers=special_powers) return self.unwrapValue(response) def find_element(self, method, target, id=None): diff --git a/testing/marionette/client/marionette/marionette_test.py b/testing/marionette/client/marionette/marionette_test.py index e445ba91a83e..619f8c7d2b40 100644 --- a/testing/marionette/client/marionette/marionette_test.py +++ b/testing/marionette/client/marionette/marionette_test.py @@ -173,7 +173,7 @@ class MarionetteJSTestCase(CommonTestCase): args.append({'__marionetteArgs': {'appframe': frame}}) try: - results = self.marionette.execute_js_script(js, args) + results = self.marionette.execute_js_script(js, args, special_powers=True) if launch_app: self.kill_gaia_app(launch_app) diff --git a/testing/marionette/client/marionette/tests/unit/test_specialpowers.py b/testing/marionette/client/marionette/tests/unit/test_specialpowers.py index 5c3a491dc6d4..aea11a878f04 100644 --- a/testing/marionette/client/marionette/tests/unit/test_specialpowers.py +++ b/testing/marionette/client/marionette/tests/unit/test_specialpowers.py @@ -14,8 +14,8 @@ class TestSpecialPowersContent(MarionetteTestCase): result = self.marionette.execute_script(""" SpecialPowers.setCharPref("%(pref)s", "%(value)s"); return SpecialPowers.getCharPref("%(pref)s") - """ % {'pref': self.testpref, 'value': self.testvalue}); - self.assertEqual(result, self.testvalue) + """ % {'pref': self.testpref, 'value': self.testvalue}, special_powers=True); + self.assertEqual(result, self.testvalue) def test_prefs_after_navigate(self): test_html = self.marionette.absolute_url("test.html") diff --git a/testing/marionette/client/marionette/tests/unit/unit-tests.ini b/testing/marionette/client/marionette/tests/unit/unit-tests.ini index c6590ff6b48a..de2de526b1c9 100644 --- a/testing/marionette/client/marionette/tests/unit/unit-tests.ini +++ b/testing/marionette/client/marionette/tests/unit/unit-tests.ini @@ -13,6 +13,7 @@ b2g = false [test_perf.py] [test_log.py] [test_emulator.py] +browser = false [test_execute_async_script.py] [test_execute_script.py] [test_simpletest_fail.js] diff --git a/testing/marionette/marionette-actors.js b/testing/marionette/marionette-actors.js index 275faedccda9..891bf49847a6 100644 --- a/testing/marionette/marionette-actors.js +++ b/testing/marionette/marionette-actors.js @@ -277,7 +277,6 @@ MarionetteDriverActor.prototype = { //add this to seenItems so we can guarantee the user will get winId as this window's id this.curBrowser.elementManager.seenItems[winId] = win; } - this.browsers[winId] = browser; }, /** @@ -438,7 +437,7 @@ MarionetteDriverActor.prototype = { * @return Sandbox * Returns the sandbox */ - createExecuteSandbox: function MDA_createExecuteSandbox(aWindow, marionette, args) { + createExecuteSandbox: function MDA_createExecuteSandbox(aWindow, marionette, args, specialPowers) { try { args = this.curBrowser.elementManager.convertWrappedArguments(args, aWindow); } @@ -457,12 +456,14 @@ MarionetteDriverActor.prototype = { _chromeSandbox[fn] = marionette[fn].bind(marionette); }); - loader.loadSubScript("chrome://specialpowers/content/specialpowersAPI.js", - _chromeSandbox); - loader.loadSubScript("chrome://specialpowers/content/SpecialPowersObserverAPI.js", - _chromeSandbox); - loader.loadSubScript("chrome://specialpowers/content/ChromePowers.js", - _chromeSandbox); + if (specialPowers == true) { + loader.loadSubScript("chrome://specialpowers/content/specialpowersAPI.js", + _chromeSandbox); + loader.loadSubScript("chrome://specialpowers/content/SpecialPowersObserverAPI.js", + _chromeSandbox); + loader.loadSubScript("chrome://specialpowers/content/ChromePowers.js", + _chromeSandbox); + } return _chromeSandbox; }, @@ -541,7 +542,7 @@ MarionetteDriverActor.prototype = { let curWindow = this.getCurrentWindow(); let marionette = new Marionette(this, curWindow, "chrome", this.marionetteLog, this.marionettePerf); - let _chromeSandbox = this.createExecuteSandbox(curWindow, marionette, aRequest.args); + let _chromeSandbox = this.createExecuteSandbox(curWindow, marionette, aRequest.args, aRequest.specialPowers); if (!_chromeSandbox) return; @@ -688,7 +689,7 @@ MarionetteDriverActor.prototype = { chromeAsyncReturnFunc(marionette.generate_results(), 0); } - let _chromeSandbox = this.createExecuteSandbox(curWindow, marionette, aRequest.args); + let _chromeSandbox = this.createExecuteSandbox(curWindow, marionette, aRequest.args, aRequest.specialPowers); if (!_chromeSandbox) return; @@ -822,9 +823,11 @@ MarionetteDriverActor.prototype = { //enable Marionette in that browser window this.startBrowser(foundWin, false); } - utils.window = foundWin; + else { + utils.window = foundWin; + this.curBrowser = this.browsers[winId]; + } foundWin.focus(); - this.curBrowser = this.browsers[winId]; this.sendOk(); return; }