Bug 1121577 - Only enable SpecialPowers at newSession, r=AutomatedTester

This commit is contained in:
Jonathan Griffin 2015-01-16 15:38:25 -08:00
parent 4368e3d7ea
commit 58d435e150
3 changed files with 29 additions and 12 deletions

View File

@ -16,8 +16,6 @@ let logger = Log.repository.getLogger("Marionette");
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"] let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader); .getService(Ci.mozIJSSubScriptLoader);
let specialpowers = {}; let specialpowers = {};
loader.loadSubScript("chrome://specialpowers/content/SpecialPowersObserver.js",
specialpowers);
//list of OOP frames that has the frame script loaded //list of OOP frames that has the frame script loaded
let remoteFrames = []; let remoteFrames = [];
@ -108,6 +106,11 @@ FrameManager.prototype = {
let oopFrame = frameWindow.document.getElementsByTagName("iframe")[message.json.frame]; //find the OOP frame let oopFrame = frameWindow.document.getElementsByTagName("iframe")[message.json.frame]; //find the OOP frame
let mm = oopFrame.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader.messageManager; //get the OOP frame's mm let mm = oopFrame.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader.messageManager; //get the OOP frame's mm
if (!specialpowers.hasOwnProperty("specialPowersObserver")) {
loader.loadSubScript("chrome://specialpowers/content/SpecialPowersObserver.js",
specialpowers);
}
// See if this frame already has our frame script loaded in it; if so, // See if this frame already has our frame script loaded in it; if so,
// just wake it up. // just wake it up.
for (let i = 0; i < remoteFrames.length; i++) { for (let i = 0; i < remoteFrames.length; i++) {

View File

@ -25,14 +25,7 @@ loader.loadSubScript("chrome://marionette/content/ChromeUtils.js", utils);
loader.loadSubScript("chrome://marionette/content/atoms.js", utils); loader.loadSubScript("chrome://marionette/content/atoms.js", utils);
loader.loadSubScript("chrome://marionette/content/marionette-sendkeys.js", utils); loader.loadSubScript("chrome://marionette/content/marionette-sendkeys.js", utils);
// SpecialPowers requires insecure automation-only features that we put behind a pref.
Services.prefs.setBoolPref('security.turn_off_all_security_so_that_viruses_can_take_over_this_computer',
true);
let specialpowers = {}; let specialpowers = {};
loader.loadSubScript("chrome://specialpowers/content/SpecialPowersObserver.js",
specialpowers);
specialpowers.specialPowersObserver = new specialpowers.SpecialPowersObserver();
specialpowers.specialPowersObserver.init();
Cu.import("resource://gre/modules/FileUtils.jsm"); Cu.import("resource://gre/modules/FileUtils.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm"); Cu.import("resource://gre/modules/NetUtil.jsm");
@ -56,6 +49,7 @@ loader.loadSubScript("resource://gre/modules/devtools/transport/transport.js");
let bypassOffline = false; let bypassOffline = false;
let qemu = "0"; let qemu = "0";
let device = null; let device = null;
const SECURITY_PREF = 'security.turn_off_all_security_so_that_viruses_can_take_over_this_computer';
XPCOMUtils.defineLazyServiceGetter(this, "cookieManager", XPCOMUtils.defineLazyServiceGetter(this, "cookieManager",
"@mozilla.org/cookiemanager;1", "@mozilla.org/cookiemanager;1",
@ -163,6 +157,7 @@ function MarionetteServerConnection(aPrefix, aTransport, aServer)
this.currentFrameElement = null; this.currentFrameElement = null;
this.testName = null; this.testName = null;
this.mozBrowserClose = null; this.mozBrowserClose = null;
this.enabled_security_pref = false;
this.sandbox = null; this.sandbox = null;
this.oopFrameId = null; // frame ID of current remote frame, used for mozbrowserclose events this.oopFrameId = null; // frame ID of current remote frame, used for mozbrowserclose events
this.sessionCapabilities = { this.sessionCapabilities = {
@ -584,6 +579,23 @@ MarionetteServerConnection.prototype = {
this.command_id = this.getCommandId(); this.command_id = this.getCommandId();
this.newSessionCommandId = this.command_id; this.newSessionCommandId = this.command_id;
// SpecialPowers requires insecure automation-only features that we put behind a pref
let security_pref_value = false;
try {
security_pref_value = Services.prefs.getBoolPref(SECURITY_PREF);
} catch(e) {}
if (!security_pref_value) {
this.enabled_security_pref = true;
Services.prefs.setBoolPref(SECURITY_PREF, true);
}
if (!specialpowers.hasOwnProperty('specialPowersObserver')) {
loader.loadSubScript("chrome://specialpowers/content/SpecialPowersObserver.js",
specialpowers);
specialpowers.specialPowersObserver = new specialpowers.SpecialPowersObserver();
specialpowers.specialPowersObserver.init();
}
this.scriptTimeout = 10000; this.scriptTimeout = 10000;
if (aRequest && aRequest.parameters) { if (aRequest && aRequest.parameters) {
this.sessionId = aRequest.parameters.session_id ? aRequest.parameters.session_id : null; this.sessionId = aRequest.parameters.session_id ? aRequest.parameters.session_id : null;

View File

@ -16,13 +16,15 @@ if (typeof(Cc) == 'undefined') {
/** /**
* Special Powers Exception - used to throw exceptions nicely * Special Powers Exception - used to throw exceptions nicely
**/ **/
function SpecialPowersException(aMsg) { this.SpecialPowersException = function SpecialPowersException(aMsg) {
this.message = aMsg; this.message = aMsg;
this.name = "SpecialPowersException"; this.name = "SpecialPowersException";
} }
SpecialPowersException.prototype.toString = function() { SpecialPowersException.prototype = {
toString: function SPE_toString() {
return this.name + ': "' + this.message + '"'; return this.name + ': "' + this.message + '"';
}
}; };
this.SpecialPowersObserverAPI = function SpecialPowersObserverAPI() { this.SpecialPowersObserverAPI = function SpecialPowersObserverAPI() {