зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1448398. Stop returning unwrapped Components.interfaces from SpecialPowers.Ci. r=kmag
This commit is contained in:
Родитель
9851f29e1d
Коммит
1151dd21cc
|
@ -27,7 +27,7 @@ let systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
|
|||
|
||||
function clearAllImageCaches() {
|
||||
var tools = Cc["@mozilla.org/image/tools;1"]
|
||||
.getService(SpecialPowers.Ci.imgITools);
|
||||
.getService(Ci.imgITools);
|
||||
var imageCache = tools.getImgCacheForDocument(window.document);
|
||||
imageCache.clearCache(true); // true=chrome
|
||||
imageCache.clearCache(false); // false=content
|
||||
|
|
|
@ -50,7 +50,7 @@ function go() {
|
|||
frame.remove();
|
||||
|
||||
TestUtils.topicObserved("outer-window-nuked", (subject, data) => {
|
||||
let id = subject.QueryInterface(SpecialPowers.Ci.nsISupportsPRUint64).data;
|
||||
let id = subject.QueryInterface(Ci.nsISupportsPRUint64).data;
|
||||
return id == winID;
|
||||
}).then(() => {
|
||||
ok(checkDead(), "Expected a dead object wrapper");
|
||||
|
|
|
@ -180,6 +180,13 @@ function unwrapPrivileged(x) {
|
|||
return obj;
|
||||
}
|
||||
|
||||
function specialPowersHasInstance(value) {
|
||||
// Because we return wrapped versions of this function, when it's called its
|
||||
// wrapper will unwrap the "this" as well as the function itself. So our
|
||||
// "this" is the unwrapped thing we started out with.
|
||||
return value instanceof this;
|
||||
}
|
||||
|
||||
function SpecialPowersHandler(wrappedObject) {
|
||||
this.wrappedObject = wrappedObject;
|
||||
}
|
||||
|
@ -224,7 +231,16 @@ SpecialPowersHandler.prototype = {
|
|||
return this.wrappedObject;
|
||||
|
||||
let obj = waiveXraysIfAppropriate(this.wrappedObject, prop);
|
||||
return wrapIfUnwrapped(Reflect.get(obj, prop));
|
||||
let val = Reflect.get(obj, prop);
|
||||
if (val === undefined && prop == Symbol.hasInstance) {
|
||||
// Special-case Symbol.hasInstance to pass the hasInstance check on to our
|
||||
// target. We only do this when the target doesn't have its own
|
||||
// Symbol.hasInstance already. Once we get rid of JS engine class
|
||||
// instance hooks (bug 1448218) and always use Symbol.hasInstance, we can
|
||||
// remove this bit (bug 1448400).
|
||||
return wrapPrivileged(specialPowersHasInstance);
|
||||
}
|
||||
return wrapIfUnwrapped(val);
|
||||
},
|
||||
|
||||
set(target, prop, val, receiver) {
|
||||
|
@ -256,8 +272,19 @@ SpecialPowersHandler.prototype = {
|
|||
let obj = waiveXraysIfAppropriate(this.wrappedObject, prop);
|
||||
let desc = Reflect.getOwnPropertyDescriptor(obj, prop);
|
||||
|
||||
if (desc === undefined)
|
||||
if (desc === undefined) {
|
||||
if (prop == Symbol.hasInstance) {
|
||||
// Special-case Symbol.hasInstance to pass the hasInstance check on to
|
||||
// our target. We only do this when the target doesn't have its own
|
||||
// Symbol.hasInstance already. Once we get rid of JS engine class
|
||||
// instance hooks (bug 1448218) and always use Symbol.hasInstance, we
|
||||
// can remove this bit (bug 1448400).
|
||||
return { value: wrapPrivileged(specialPowersHasInstance),
|
||||
writeable: true, configurable: true, enumerable: false };
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Transitively maintain the wrapper membrane.
|
||||
function wrapIfExists(key) {
|
||||
|
@ -653,15 +680,10 @@ SpecialPowersAPI.prototype = {
|
|||
},
|
||||
|
||||
/*
|
||||
* Convenient shortcuts to the standard Components abbreviations. Note that
|
||||
* we don't SpecialPowers-wrap Components.interfaces, because it's available
|
||||
* to untrusted content, and wrapping it confuses QI and identity checks.
|
||||
* Convenient shortcuts to the standard Components abbreviations.
|
||||
*/
|
||||
get Cc() { return wrapPrivileged(this.getFullComponents().classes); },
|
||||
get Ci() {
|
||||
return this.Components ? this.Components.interfaces
|
||||
: Ci;
|
||||
},
|
||||
get Ci() { return wrapPrivileged(this.getFullComponents().interfaces); },
|
||||
get Cu() { return wrapPrivileged(this.getFullComponents().utils); },
|
||||
get Cr() { return wrapPrivileged(this.Components.results); },
|
||||
|
||||
|
|
|
@ -14,9 +14,6 @@
|
|||
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var Cc = SpecialPowers.Cc;
|
||||
var Ci = SpecialPowers.Ci;
|
||||
|
||||
var mainWindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShellTreeItem)
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var Cc = SpecialPowers.Cc;
|
||||
var Ci = SpecialPowers.Ci;
|
||||
|
||||
var mainWindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShellTreeItem)
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var Cc = SpecialPowers.Cc;
|
||||
var Ci = SpecialPowers.Ci;
|
||||
|
||||
var mainWindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShellTreeItem)
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var Cc = SpecialPowers.Cc;
|
||||
var Ci = SpecialPowers.Ci;
|
||||
|
||||
var mainWindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShellTreeItem)
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var Cc = SpecialPowers.Cc;
|
||||
var Ci = SpecialPowers.Ci;
|
||||
|
||||
var mainWindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShellTreeItem)
|
||||
|
|
Загрузка…
Ссылка в новой задаче