зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1052139 - Adjust sandbox code to create the sandbox with an (observably) immutable [[Prototype]], once the flag's flipped. r=bz
This commit is contained in:
Родитель
225fa78d5c
Коммит
5a14010e95
|
@ -1046,6 +1046,24 @@ xpc::CreateSandboxObject(JSContext* cx, MutableHandleValue vp, nsISupports* prin
|
|||
// Pass on ownership of sbp to |sandbox|.
|
||||
JS_SetPrivate(sandbox, sbp.forget().take());
|
||||
|
||||
{
|
||||
// Don't try to mirror standard class properties, if we're using a
|
||||
// mirroring sandbox. (This is meaningless for non-mirroring
|
||||
// sandboxes.)
|
||||
AutoSkipPropertyMirroring askip(CompartmentPrivate::Get(sandbox));
|
||||
|
||||
// Ensure |Object.prototype| is instantiated before prototype-
|
||||
// splicing below. For write-to-global-prototype behavior, extend
|
||||
// this to all builtin properties.
|
||||
if (options.writeToGlobalPrototype) {
|
||||
if (!JS_EnumerateStandardClasses(cx, sandbox))
|
||||
return NS_ERROR_XPC_UNEXPECTED;
|
||||
} else {
|
||||
if (!JS_GetObjectPrototype(cx, sandbox))
|
||||
return NS_ERROR_XPC_UNEXPECTED;
|
||||
}
|
||||
}
|
||||
|
||||
if (options.proto) {
|
||||
bool ok = JS_WrapObject(cx, &options.proto);
|
||||
if (!ok)
|
||||
|
@ -1114,10 +1132,6 @@ xpc::CreateSandboxObject(JSContext* cx, MutableHandleValue vp, nsISupports* prin
|
|||
// every global.
|
||||
if (!dom::PromiseBinding::GetConstructorObject(cx, sandbox))
|
||||
return NS_ERROR_XPC_UNEXPECTED;
|
||||
|
||||
// Resolve standard classes eagerly to avoid triggering mirroring hooks for them.
|
||||
if (options.writeToGlobalPrototype && !JS_EnumerateStandardClasses(cx, sandbox))
|
||||
return NS_ERROR_XPC_UNEXPECTED;
|
||||
}
|
||||
|
||||
// We handle the case where the context isn't in a compartment for the
|
||||
|
|
Загрузка…
Ссылка в новой задаче