mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1038844 - Use the opt-out for the SpecialPowers scope. r=mrbkap,r=ted
This commit is contained in:
parent
7239458847
commit
329c1ce903
@ -106,15 +106,6 @@ SpecialPowers.prototype.executeAfterFlushingMessageQueue = function(aCallback) {
|
|||||||
sendAsyncMessage("SPPingService", { op: "ping" });
|
sendAsyncMessage("SPPingService", { op: "ping" });
|
||||||
};
|
};
|
||||||
|
|
||||||
// Expose everything but internal APIs (starting with underscores) to
|
|
||||||
// web content. We cannot use Object.keys to view SpecialPowers.prototype since
|
|
||||||
// we are using the functions from SpecialPowersAPI.prototype
|
|
||||||
SpecialPowers.prototype.__exposedProps__ = {};
|
|
||||||
for (var i in SpecialPowers.prototype) {
|
|
||||||
if (i.charAt(0) != "_")
|
|
||||||
SpecialPowers.prototype.__exposedProps__[i] = "r";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attach our API to the window.
|
// Attach our API to the window.
|
||||||
function attachSpecialPowersToWindow(aWindow) {
|
function attachSpecialPowersToWindow(aWindow) {
|
||||||
try {
|
try {
|
||||||
|
@ -18,6 +18,10 @@ Cu.import("resource://gre/modules/Services.jsm");
|
|||||||
Cu.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
|
Cu.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
|
||||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
|
|
||||||
|
// Allow stuff from this scope to be accessed from non-privileged scopes. This
|
||||||
|
// would crash if used outside of automation.
|
||||||
|
Cu.forcePermissiveCOWs();
|
||||||
|
|
||||||
function SpecialPowersAPI() {
|
function SpecialPowersAPI() {
|
||||||
this._consoleListeners = [];
|
this._consoleListeners = [];
|
||||||
this._encounteredCrashDumpFiles = [];
|
this._encounteredCrashDumpFiles = [];
|
||||||
@ -223,27 +227,6 @@ function crawlProtoChain(obj, fn) {
|
|||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* We want to waive the __exposedProps__ security check for SpecialPowers-wrapped
|
|
||||||
* objects. We do this by creating a proxy singleton that just always returns 'rw'
|
|
||||||
* for any property name.
|
|
||||||
*/
|
|
||||||
function ExposedPropsWaiverHandler() {
|
|
||||||
// NB: XPConnect denies access if the relevant member of __exposedProps__ is not
|
|
||||||
// enumerable.
|
|
||||||
var _permit = { value: 'rw', writable: false, configurable: false, enumerable: true };
|
|
||||||
return {
|
|
||||||
getOwnPropertyDescriptor: function(name) { return _permit; },
|
|
||||||
getPropertyDescriptor: function(name) { return _permit; },
|
|
||||||
getOwnPropertyNames: function() { throw Error("Can't enumerate ExposedPropsWaiver"); },
|
|
||||||
getPropertyNames: function() { throw Error("Can't enumerate ExposedPropsWaiver"); },
|
|
||||||
enumerate: function() { throw Error("Can't enumerate ExposedPropsWaiver"); },
|
|
||||||
defineProperty: function(name) { throw Error("Can't define props on ExposedPropsWaiver"); },
|
|
||||||
delete: function(name) { throw Error("Can't delete props from ExposedPropsWaiver"); }
|
|
||||||
};
|
|
||||||
};
|
|
||||||
var ExposedPropsWaiver = Proxy.create(ExposedPropsWaiverHandler());
|
|
||||||
|
|
||||||
function SpecialPowersHandler(obj) {
|
function SpecialPowersHandler(obj) {
|
||||||
this.wrappedObject = obj;
|
this.wrappedObject = obj;
|
||||||
};
|
};
|
||||||
@ -256,10 +239,6 @@ SpecialPowersHandler.prototype.doGetPropertyDescriptor = function(name, own) {
|
|||||||
if (name == "SpecialPowers_wrappedObject")
|
if (name == "SpecialPowers_wrappedObject")
|
||||||
return { value: this.wrappedObject, writeable: false, configurable: false, enumerable: false };
|
return { value: this.wrappedObject, writeable: false, configurable: false, enumerable: false };
|
||||||
|
|
||||||
// Handle __exposedProps__.
|
|
||||||
if (name == "__exposedProps__")
|
|
||||||
return { value: ExposedPropsWaiver, writable: false, configurable: false, enumerable: false };
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Call through to the wrapped object.
|
// Call through to the wrapped object.
|
||||||
//
|
//
|
||||||
@ -445,11 +424,6 @@ SPConsoleListener.prototype = {
|
|||||||
m.isStrict = ((msg.flags & Ci.nsIScriptError.strictFlag) === 1);
|
m.isStrict = ((msg.flags & Ci.nsIScriptError.strictFlag) === 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// expose all props of 'm' as read-only
|
|
||||||
let expose = {};
|
|
||||||
for (let prop in m)
|
|
||||||
expose[prop] = 'r';
|
|
||||||
m.__exposedProps__ = expose;
|
|
||||||
Object.freeze(m);
|
Object.freeze(m);
|
||||||
|
|
||||||
this.callback.call(undefined, m);
|
this.callback.call(undefined, m);
|
||||||
@ -470,7 +444,7 @@ function wrapCallback(cb) {
|
|||||||
|
|
||||||
function wrapCallbackObject(obj) {
|
function wrapCallbackObject(obj) {
|
||||||
obj = Cu.waiveXrays(obj);
|
obj = Cu.waiveXrays(obj);
|
||||||
var wrapper = { __exposedProps__: ExposedPropsWaiver };
|
var wrapper = {};
|
||||||
for (var i in obj) {
|
for (var i in obj) {
|
||||||
if (typeof obj[i] == 'function')
|
if (typeof obj[i] == 'function')
|
||||||
wrapper[i] = wrapCallback(obj[i]);
|
wrapper[i] = wrapCallback(obj[i]);
|
||||||
@ -528,9 +502,7 @@ SpecialPowersAPI.prototype = {
|
|||||||
* Create blank privileged objects to use as out-params for privileged functions.
|
* Create blank privileged objects to use as out-params for privileged functions.
|
||||||
*/
|
*/
|
||||||
createBlankObject: function () {
|
createBlankObject: function () {
|
||||||
var obj = new Object;
|
return new Object;
|
||||||
obj.__exposedProps__ = ExposedPropsWaiver;
|
|
||||||
return obj;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1477,13 +1449,12 @@ SpecialPowersAPI.prototype = {
|
|||||||
|
|
||||||
getDOMRequestService: function() {
|
getDOMRequestService: function() {
|
||||||
var serv = Services.DOMRequest;
|
var serv = Services.DOMRequest;
|
||||||
var res = { __exposedProps__: {} };
|
var res = {};
|
||||||
var props = ["createRequest", "createCursor", "fireError", "fireSuccess",
|
var props = ["createRequest", "createCursor", "fireError", "fireSuccess",
|
||||||
"fireDone", "fireDetailedError"];
|
"fireDone", "fireDetailedError"];
|
||||||
for (var i in props) {
|
for (var i in props) {
|
||||||
let prop = props[i];
|
let prop = props[i];
|
||||||
res[prop] = function() { return serv[prop].apply(serv, arguments) };
|
res[prop] = function() { return serv[prop].apply(serv, arguments) };
|
||||||
res.__exposedProps__[prop] = "r";
|
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user