зеркало из https://github.com/mozilla/gecko-dev.git
Bug 831149 - Expose SpecialPowers to conent scripts via a lazy getter, r=philikon, a=approval-mozilla-b2g18
This commit is contained in:
Родитель
99ea7b7796
Коммит
dc000b5506
|
@ -16,7 +16,8 @@ loader.loadSubScript("chrome://marionette/content/marionette-log-obj.js");
|
|||
loader.loadSubScript("chrome://marionette/content/marionette-perf.js");
|
||||
Cu.import("chrome://marionette/content/marionette-elements.js");
|
||||
Cu.import("resource://gre/modules/FileUtils.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
let utils = {};
|
||||
utils.window = content;
|
||||
// Load Event/ChromeUtils for use with JS scripts:
|
||||
|
@ -280,7 +281,7 @@ function resetValues() {
|
|||
/**
|
||||
* Returns a content sandbox that can be used by the execute_foo functions.
|
||||
*/
|
||||
function createExecuteContentSandbox(aWindow, timeout, specialPowers) {
|
||||
function createExecuteContentSandbox(aWindow, timeout) {
|
||||
let sandbox = new Cu.Sandbox(aWindow);
|
||||
sandbox.global = sandbox;
|
||||
sandbox.window = aWindow;
|
||||
|
@ -302,9 +303,9 @@ function createExecuteContentSandbox(aWindow, timeout, specialPowers) {
|
|||
}
|
||||
});
|
||||
|
||||
if (specialPowers) {
|
||||
sandbox.SpecialPowers = new SpecialPowers(aWindow);
|
||||
}
|
||||
XPCOMUtils.defineLazyGetter(sandbox, 'SpecialPowers', function() {
|
||||
return new SpecialPowers(aWindow);
|
||||
});
|
||||
|
||||
sandbox.asyncComplete = function sandbox_asyncComplete(value, status) {
|
||||
curWindow.removeEventListener("unload", onunload, false);
|
||||
|
@ -362,8 +363,7 @@ function executeScript(msg, directInject) {
|
|||
|
||||
if (msg.json.newSandbox || !sandbox) {
|
||||
sandbox = createExecuteContentSandbox(curWindow,
|
||||
msg.json.timeout,
|
||||
msg.json.specialPowers);
|
||||
msg.json.timeout);
|
||||
if (!sandbox) {
|
||||
sendError("Could not create sandbox!", 500, null, asyncTestCommandId);
|
||||
return;
|
||||
|
@ -470,8 +470,7 @@ function executeWithCallback(msg, useFinish) {
|
|||
|
||||
if (msg.json.newSandbox || !sandbox) {
|
||||
sandbox = createExecuteContentSandbox(curWindow,
|
||||
msg.json.timeout,
|
||||
msg.json.specialPowers);
|
||||
msg.json.timeout);
|
||||
if (!sandbox) {
|
||||
sendError("Could not create sandbox!", 17, null, asyncTestCommandId);
|
||||
return;
|
||||
|
|
Загрузка…
Ссылка в новой задаче