Bug 784233 - Relax __exposedProps__ check for sandboxes until we can repack AMO addons. r=gal

This commit is contained in:
Bobby Holley 2012-08-21 10:27:08 -07:00
Родитель 9c7aa4f09c
Коммит 4a61c7b937
3 изменённых файлов: 33 добавлений и 4 удалений

Просмотреть файл

@ -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
}