Bug 761202 - Load special powers only if needed in Marionette. r=dburns

This commit is contained in:
Malini Das 2012-06-25 15:08:38 -04:00
Родитель ad1d3b4cf9
Коммит 5ced7504b0
5 изменённых файлов: 28 добавлений и 21 удалений

Просмотреть файл

@ -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):

Просмотреть файл

@ -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)

Просмотреть файл

@ -14,7 +14,7 @@ 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});
""" % {'pref': self.testpref, 'value': self.testvalue}, special_powers=True);
self.assertEqual(result, self.testvalue)
def test_prefs_after_navigate(self):

Просмотреть файл

@ -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]

Просмотреть файл

@ -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;
}