зеркало из https://github.com/mozilla/gecko-dev.git
Bug 784233 - Relax __exposedProps__ check for sandboxes until we can repack AMO addons. r=gal
This commit is contained in:
Родитель
9c7aa4f09c
Коммит
4a61c7b937
|
@ -45,5 +45,6 @@ DEPRECATED_OPERATION(InputEncoding)
|
|||
DEPRECATED_OPERATION(MozBeforePaint)
|
||||
DEPRECATED_OPERATION(MozBlobBuilder)
|
||||
DEPRECATED_OPERATION(DOMExceptionCode)
|
||||
DEPRECATED_OPERATION(NoExposedProps)
|
||||
DEPRECATED_OPERATION(MutationEvent)
|
||||
DEPRECATED_OPERATION(MozSlice)
|
||||
|
|
|
@ -95,12 +95,10 @@ function COWTests() {
|
|||
const PROPS_TO_TEST = ['foo', 'bar', 'prototype'];
|
||||
|
||||
var empty = {};
|
||||
var nonempty = {foo: 42, bar: 33};
|
||||
// Once we flip the default for __exposedProps__, this should behave
|
||||
// the same as for function objects below.
|
||||
is(getCOW(empty).foo, undefined,
|
||||
"shouldn't throw when accessing exposed properties that doesn't exist");
|
||||
PROPS_TO_TEST.forEach(function(name) {
|
||||
isPropHidden(getCOW(nonempty), name, "object without exposedProps");
|
||||
});
|
||||
|
||||
// Test function objects without __exposedProps__
|
||||
var func = function(x) { return 42; };
|
||||
|
|
|
@ -383,6 +383,16 @@ PermitIfUniversalXPConnect(JSContext *cx, jsid id, Wrapper::Action act,
|
|||
return Deny(cx, id, act);
|
||||
}
|
||||
|
||||
static bool
|
||||
IsInSandbox(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
JSAutoEnterCompartment ac;
|
||||
if (!ac.enter(cx, obj))
|
||||
return false;
|
||||
JSObject *global = JS_GetGlobalForObject(cx, obj);
|
||||
return !strcmp(js::GetObjectJSClass(global)->name, "Sandbox");
|
||||
}
|
||||
|
||||
bool
|
||||
ExposedPropertiesOnly::check(JSContext *cx, JSObject *wrapper, jsid id, Wrapper::Action act,
|
||||
Permission &perm)
|
||||
|
@ -427,6 +437,26 @@ ExposedPropertiesOnly::check(JSContext *cx, JSObject *wrapper, jsid id, Wrapper:
|
|||
if (!wrapperAC.enter(cx, wrapper))
|
||||
return false;
|
||||
|
||||
// Make a temporary exception for objects in a chrome sandbox to help
|
||||
// out jetpack. See bug 784233.
|
||||
if (!JS_ObjectIsFunction(cx, wrappedObject) &&
|
||||
IsInSandbox(cx, wrappedObject))
|
||||
{
|
||||
// This little loop hole will go away soon! See bug 553102.
|
||||
nsCOMPtr<nsPIDOMWindow> win =
|
||||
do_QueryInterface(nsJSUtils::GetStaticScriptGlobal(cx, wrapper));
|
||||
if (win) {
|
||||
nsCOMPtr<nsIDocument> doc =
|
||||
do_QueryInterface(win->GetExtantDocument());
|
||||
if (doc) {
|
||||
doc->WarnOnceAbout(nsIDocument::eNoExposedProps,
|
||||
/* asError = */ true);
|
||||
}
|
||||
}
|
||||
|
||||
perm = PermitPropertyAccess;
|
||||
return true;
|
||||
}
|
||||
return PermitIfUniversalXPConnect(cx, id, act, perm); // Deny
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче