mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Back out 2 changesets (bug 1052139) for mochitest-jetpack bustage
Backed out changeset 3dc503961322 (bug 1052139) Backed out changeset 6f278bc63614 (bug 1052139)
This commit is contained in:
parent
fc2528e0d1
commit
23f82e924e
@ -274,27 +274,13 @@ WindowNamedPropertiesHandler::Create(JSContext* aCx,
|
|||||||
// Note: since the scope polluter proxy lives on the window's prototype
|
// Note: since the scope polluter proxy lives on the window's prototype
|
||||||
// chain, it needs a singleton type to avoid polluting type information
|
// chain, it needs a singleton type to avoid polluting type information
|
||||||
// for properties on the window.
|
// for properties on the window.
|
||||||
|
JS::Rooted<JSObject*> gsp(aCx);
|
||||||
js::ProxyOptions options;
|
js::ProxyOptions options;
|
||||||
options.setSingleton(true);
|
options.setSingleton(true);
|
||||||
options.setClass(&WindowNamedPropertiesClass.mBase);
|
options.setClass(&WindowNamedPropertiesClass.mBase);
|
||||||
|
return js::NewProxyObject(aCx, WindowNamedPropertiesHandler::getInstance(),
|
||||||
JS::Rooted<JSObject*> gsp(aCx);
|
JS::NullHandleValue, aProto,
|
||||||
gsp = js::NewProxyObject(aCx, WindowNamedPropertiesHandler::getInstance(),
|
options);
|
||||||
JS::NullHandleValue, aProto,
|
|
||||||
options);
|
|
||||||
if (!gsp) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool succeeded;
|
|
||||||
if (!JS_SetImmutablePrototype(aCx, gsp, &succeeded)) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
MOZ_ASSERT(succeeded,
|
|
||||||
"errors making the [[Prototype]] of the named properties object "
|
|
||||||
"immutable should have been JSAPI failures, not !succeeded");
|
|
||||||
|
|
||||||
return gsp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
|
@ -3111,14 +3111,6 @@ CreateGlobal(JSContext* aCx, T* aNative, nsWrapperCache* aCache,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool succeeded;
|
|
||||||
if (!JS_SetImmutablePrototype(aCx, aGlobal, &succeeded)) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
MOZ_ASSERT(succeeded,
|
|
||||||
"making a fresh global object's [[Prototype]] immutable can "
|
|
||||||
"internally fail, but it should never be unsuccessful");
|
|
||||||
|
|
||||||
return proto;
|
return proto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2820,19 +2820,6 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
|
|||||||
chromeProperties=chromeProperties,
|
chromeProperties=chromeProperties,
|
||||||
name='"' + self.descriptor.interface.identifier.name + '"' if needInterfaceObject else "nullptr")
|
name='"' + self.descriptor.interface.identifier.name + '"' if needInterfaceObject else "nullptr")
|
||||||
|
|
||||||
# If we fail after here, we must clear interface and prototype caches
|
|
||||||
# using this code: intermediate failure must not expose the interface in
|
|
||||||
# partially-constructed state. Note that every case after here needs an
|
|
||||||
# interface prototype object.
|
|
||||||
failureCode = dedent(
|
|
||||||
"""
|
|
||||||
*protoCache = nullptr;
|
|
||||||
if (interfaceCache) {
|
|
||||||
*interfaceCache = nullptr;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
""")
|
|
||||||
|
|
||||||
aliasedMembers = [m for m in self.descriptor.interface.members if m.isMethod() and m.aliases]
|
aliasedMembers = [m for m in self.descriptor.interface.members if m.isMethod() and m.aliases]
|
||||||
if aliasedMembers:
|
if aliasedMembers:
|
||||||
assert needInterfacePrototypeObject
|
assert needInterfacePrototypeObject
|
||||||
@ -2852,18 +2839,17 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
|
|||||||
prop = '"%s"' % alias
|
prop = '"%s"' % alias
|
||||||
return CGList([
|
return CGList([
|
||||||
getSymbolJSID,
|
getSymbolJSID,
|
||||||
# XXX If we ever create non-enumerable properties that can
|
# XXX If we ever create non-enumerate properties that can be
|
||||||
# be aliased, we should consider making the aliases
|
# aliased, we should consider making the aliases match
|
||||||
# match the enumerability of the property being aliased.
|
# the enumerability of the property being aliased.
|
||||||
CGGeneric(fill(
|
CGGeneric(fill(
|
||||||
"""
|
"""
|
||||||
if (!${defineFn}(aCx, proto, ${prop}, aliasedVal, JSPROP_ENUMERATE)) {
|
if (!${defineFn}(aCx, proto, ${prop}, aliasedVal, JSPROP_ENUMERATE)) {
|
||||||
$*{failureCode}
|
return;
|
||||||
}
|
}
|
||||||
""",
|
""",
|
||||||
defineFn=defineFn,
|
defineFn=defineFn,
|
||||||
prop=prop,
|
prop=prop))
|
||||||
failureCode=failureCode))
|
|
||||||
], "\n")
|
], "\n")
|
||||||
|
|
||||||
def defineAliasesFor(m):
|
def defineAliasesFor(m):
|
||||||
@ -2871,23 +2857,21 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
|
|||||||
CGGeneric(fill(
|
CGGeneric(fill(
|
||||||
"""
|
"""
|
||||||
if (!JS_GetProperty(aCx, proto, \"${prop}\", &aliasedVal)) {
|
if (!JS_GetProperty(aCx, proto, \"${prop}\", &aliasedVal)) {
|
||||||
$*{failureCode}
|
return;
|
||||||
}
|
}
|
||||||
""",
|
""",
|
||||||
failureCode=failureCode,
|
|
||||||
prop=m.identifier.name))
|
prop=m.identifier.name))
|
||||||
] + [defineAlias(alias) for alias in sorted(m.aliases)])
|
] + [defineAlias(alias) for alias in sorted(m.aliases)])
|
||||||
|
|
||||||
defineAliases = CGList([
|
defineAliases = CGList([
|
||||||
CGGeneric(fill("""
|
CGGeneric(dedent("""
|
||||||
// Set up aliases on the interface prototype object we just created.
|
// Set up aliases on the interface prototype object we just created.
|
||||||
JS::Handle<JSObject*> proto = GetProtoObjectHandle(aCx, aGlobal);
|
JS::Handle<JSObject*> proto = GetProtoObjectHandle(aCx, aGlobal);
|
||||||
if (!proto) {
|
if (!proto) {
|
||||||
$*{failureCode}
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
""",
|
""")),
|
||||||
failureCode=failureCode)),
|
|
||||||
CGGeneric("JS::Rooted<JS::Value> aliasedVal(aCx);\n\n")
|
CGGeneric("JS::Rooted<JS::Value> aliasedVal(aCx);\n\n")
|
||||||
] + [defineAliasesFor(m) for m in sorted(aliasedMembers)])
|
] + [defineAliasesFor(m) for m in sorted(aliasedMembers)])
|
||||||
else:
|
else:
|
||||||
@ -2913,6 +2897,14 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
|
|||||||
else:
|
else:
|
||||||
holderClass = "Class.ToJSClass()"
|
holderClass = "Class.ToJSClass()"
|
||||||
holderProto = "*protoCache"
|
holderProto = "*protoCache"
|
||||||
|
failureCode = dedent(
|
||||||
|
"""
|
||||||
|
*protoCache = nullptr;
|
||||||
|
if (interfaceCache) {
|
||||||
|
*interfaceCache = nullptr;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
""")
|
||||||
createUnforgeableHolder = CGGeneric(fill(
|
createUnforgeableHolder = CGGeneric(fill(
|
||||||
"""
|
"""
|
||||||
JS::Rooted<JSObject*> unforgeableHolder(aCx);
|
JS::Rooted<JSObject*> unforgeableHolder(aCx);
|
||||||
@ -2946,32 +2938,9 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
|
|||||||
else:
|
else:
|
||||||
unforgeableHolderSetup = None
|
unforgeableHolderSetup = None
|
||||||
|
|
||||||
if (self.descriptor.interface.isOnGlobalProtoChain() and
|
|
||||||
needInterfacePrototypeObject):
|
|
||||||
makeProtoPrototypeImmutable = CGGeneric(fill(
|
|
||||||
"""
|
|
||||||
if (*${protoCache}) {
|
|
||||||
bool succeeded;
|
|
||||||
JS::Handle<JSObject*> prot = GetProtoObjectHandle(aCx, aGlobal);
|
|
||||||
if (!JS_SetImmutablePrototype(aCx, prot, &succeeded)) {
|
|
||||||
$*{failureCode}
|
|
||||||
}
|
|
||||||
|
|
||||||
MOZ_ASSERT(succeeded,
|
|
||||||
"making a fresh prototype object's [[Prototype]] "
|
|
||||||
"immutable can internally fail, but it should "
|
|
||||||
"never be unsuccessful");
|
|
||||||
}
|
|
||||||
""",
|
|
||||||
protoCache=protoCache,
|
|
||||||
failureCode=failureCode))
|
|
||||||
else:
|
|
||||||
makeProtoPrototypeImmutable = None
|
|
||||||
|
|
||||||
return CGList(
|
return CGList(
|
||||||
[getParentProto, CGGeneric(getConstructorProto), initIds,
|
[getParentProto, CGGeneric(getConstructorProto), initIds,
|
||||||
prefCache, CGGeneric(call), defineAliases, unforgeableHolderSetup,
|
prefCache, CGGeneric(call), defineAliases, unforgeableHolderSetup],
|
||||||
makeProtoPrototypeImmutable],
|
|
||||||
"\n").define()
|
"\n").define()
|
||||||
|
|
||||||
|
|
||||||
|
@ -1056,13 +1056,6 @@ CreateObjectPrototype(JSContext* cx, JSProtoKey key)
|
|||||||
if (!objectProto)
|
if (!objectProto)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
bool succeeded;
|
|
||||||
if (!SetImmutablePrototype(cx, objectProto, &succeeded))
|
|
||||||
return nullptr;
|
|
||||||
MOZ_ASSERT(succeeded,
|
|
||||||
"should have been able to make a fresh Object.prototype's "
|
|
||||||
"[[Prototype]] immutable");
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The default 'new' type of Object.prototype is required by type inference
|
* The default 'new' type of Object.prototype is required by type inference
|
||||||
* to have unknown properties, to simplify handling of e.g. heterogenous
|
* to have unknown properties, to simplify handling of e.g. heterogenous
|
||||||
|
@ -6320,12 +6320,6 @@ JS_DecodeInterpretedFunction(JSContext* cx, const void* data, uint32_t length)
|
|||||||
return funobj;
|
return funobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(bool)
|
|
||||||
JS_SetImmutablePrototype(JSContext *cx, JS::HandleObject obj, bool *succeeded)
|
|
||||||
{
|
|
||||||
return SetImmutablePrototype(cx, obj, succeeded);
|
|
||||||
}
|
|
||||||
|
|
||||||
JS_PUBLIC_API(void)
|
JS_PUBLIC_API(void)
|
||||||
JS::SetAsmJSCacheOps(JSRuntime* rt, const JS::AsmJSCacheOps* ops)
|
JS::SetAsmJSCacheOps(JSRuntime* rt, const JS::AsmJSCacheOps* ops)
|
||||||
{
|
{
|
||||||
|
@ -2453,16 +2453,6 @@ JS_FreezeObject(JSContext* cx, JS::Handle<JSObject*> obj);
|
|||||||
extern JS_PUBLIC_API(bool)
|
extern JS_PUBLIC_API(bool)
|
||||||
JS_PreventExtensions(JSContext* cx, JS::HandleObject obj, JS::ObjectOpResult& result);
|
JS_PreventExtensions(JSContext* cx, JS::HandleObject obj, JS::ObjectOpResult& result);
|
||||||
|
|
||||||
/*
|
|
||||||
* Attempt to make the [[Prototype]] of |obj| immutable, such that any attempt
|
|
||||||
* to modify it will fail. If an error occurs during the attempt, return false
|
|
||||||
* (with a pending exception set, depending upon the nature of the error). If
|
|
||||||
* no error occurs, return true with |*succeeded| set to indicate whether the
|
|
||||||
* attempt successfully made the [[Prototype]] immutable.
|
|
||||||
*/
|
|
||||||
extern JS_PUBLIC_API(bool)
|
|
||||||
JS_SetImmutablePrototype(JSContext* cx, JS::HandleObject obj, bool* succeeded);
|
|
||||||
|
|
||||||
extern JS_PUBLIC_API(JSObject*)
|
extern JS_PUBLIC_API(JSObject*)
|
||||||
JS_New(JSContext* cx, JS::HandleObject ctor, const JS::HandleValueArray& args);
|
JS_New(JSContext* cx, JS::HandleObject ctor, const JS::HandleValueArray& args);
|
||||||
|
|
||||||
|
@ -2395,7 +2395,7 @@ JSObject::reportNotExtensible(JSContext* cx, unsigned report)
|
|||||||
// immutable-prototype behavior is enforced; if it's false, behavior is not
|
// immutable-prototype behavior is enforced; if it's false, behavior is not
|
||||||
// enforced, and immutable-prototype bits stored on objects are completely
|
// enforced, and immutable-prototype bits stored on objects are completely
|
||||||
// ignored.
|
// ignored.
|
||||||
static const bool ImmutablePrototypesEnabled = false;
|
static const bool ImmutablePrototypesEnabled = true;
|
||||||
|
|
||||||
JS_FRIEND_API(bool)
|
JS_FRIEND_API(bool)
|
||||||
JS_ImmutablePrototypesEnabled()
|
JS_ImmutablePrototypesEnabled()
|
||||||
@ -2467,15 +2467,6 @@ js::SetPrototype(JSContext* cx, HandleObject obj, HandleObject proto, JS::Object
|
|||||||
if (!extensible)
|
if (!extensible)
|
||||||
return result.fail(JSMSG_CANT_SET_PROTO);
|
return result.fail(JSMSG_CANT_SET_PROTO);
|
||||||
|
|
||||||
// If this is a global object, resolve the Object class so that its
|
|
||||||
// [[Prototype]] chain is always properly immutable, even in the presence
|
|
||||||
// of lazy standard classes.
|
|
||||||
if (obj->is<GlobalObject>()) {
|
|
||||||
Rooted<GlobalObject*> global(cx, &obj->as<GlobalObject>());
|
|
||||||
if (!GlobalObject::ensureConstructor(cx, global, JSProto_Object))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ES6 9.1.2 step 6 forbids generating cyclical prototype chains. But we
|
* ES6 9.1.2 step 6 forbids generating cyclical prototype chains. But we
|
||||||
* have to do this comparison on the observable outer objects, not on the
|
* have to do this comparison on the observable outer objects, not on the
|
||||||
@ -3350,7 +3341,6 @@ JSObject::dump()
|
|||||||
if (obj->hasUncacheableProto()) fprintf(stderr, " has_uncacheable_proto");
|
if (obj->hasUncacheableProto()) fprintf(stderr, " has_uncacheable_proto");
|
||||||
if (obj->hadElementsAccess()) fprintf(stderr, " had_elements_access");
|
if (obj->hadElementsAccess()) fprintf(stderr, " had_elements_access");
|
||||||
if (obj->wasNewScriptCleared()) fprintf(stderr, " new_script_cleared");
|
if (obj->wasNewScriptCleared()) fprintf(stderr, " new_script_cleared");
|
||||||
if (!obj->hasLazyPrototype() && obj->nonLazyPrototypeIsImmutable()) fprintf(stderr, " immutable_prototype");
|
|
||||||
|
|
||||||
if (obj->isNative()) {
|
if (obj->isNative()) {
|
||||||
NativeObject* nobj = &obj->as<NativeObject>();
|
NativeObject* nobj = &obj->as<NativeObject>();
|
||||||
|
@ -5760,13 +5760,6 @@ NewGlobalObject(JSContext* cx, JS::CompartmentOptions& options,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool succeeded;
|
|
||||||
if (!JS_SetImmutablePrototype(cx, glob, &succeeded))
|
|
||||||
return nullptr;
|
|
||||||
MOZ_ASSERT(succeeded,
|
|
||||||
"a fresh, unexposed global object is always capable of "
|
|
||||||
"having its [[Prototype]] be immutable");
|
|
||||||
|
|
||||||
#ifdef JS_HAS_CTYPES
|
#ifdef JS_HAS_CTYPES
|
||||||
if (!JS_InitCTypesClass(cx, glob))
|
if (!JS_InitCTypesClass(cx, glob))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -89,6 +89,9 @@ js::GlobalObject::getTypedObjectModule() const {
|
|||||||
return v.toObject().as<TypedObjectModuleObject>();
|
return v.toObject().as<TypedObjectModuleObject>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* static */ bool
|
/* static */ bool
|
||||||
GlobalObject::ensureConstructor(JSContext* cx, Handle<GlobalObject*> global, JSProtoKey key)
|
GlobalObject::ensureConstructor(JSContext* cx, Handle<GlobalObject*> global, JSProtoKey key)
|
||||||
{
|
{
|
||||||
|
@ -1040,25 +1040,6 @@ xpc::CreateSandboxObject(JSContext* cx, MutableHandleValue vp, nsISupports* prin
|
|||||||
{
|
{
|
||||||
JSAutoCompartment ac(cx, sandbox);
|
JSAutoCompartment ac(cx, sandbox);
|
||||||
|
|
||||||
nsCOMPtr<nsIScriptObjectPrincipal> sbp =
|
|
||||||
new SandboxPrivate(principal, sandbox);
|
|
||||||
|
|
||||||
// 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));
|
|
||||||
|
|
||||||
// Resolve standard classes so that |Object.prototype| is
|
|
||||||
// instantiated before any prototype-splicing below. This is
|
|
||||||
// necessary for both kinds of sandboxes.
|
|
||||||
if (!JS_EnumerateStandardClasses(cx, sandbox))
|
|
||||||
return NS_ERROR_XPC_UNEXPECTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.proto) {
|
if (options.proto) {
|
||||||
bool ok = JS_WrapObject(cx, &options.proto);
|
bool ok = JS_WrapObject(cx, &options.proto);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
@ -1093,11 +1074,17 @@ xpc::CreateSandboxObject(JSContext* cx, MutableHandleValue vp, nsISupports* prin
|
|||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
ok = JS_SplicePrototype(cx, sandbox, options.proto);
|
ok = JS_SetPrototype(cx, sandbox, options.proto);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
return NS_ERROR_XPC_UNEXPECTED;
|
return NS_ERROR_XPC_UNEXPECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsIScriptObjectPrincipal> sbp =
|
||||||
|
new SandboxPrivate(principal, sandbox);
|
||||||
|
|
||||||
|
// Pass on ownership of sbp to |sandbox|.
|
||||||
|
JS_SetPrivate(sandbox, sbp.forget().take());
|
||||||
|
|
||||||
// Don't try to mirror the properties that are set below.
|
// Don't try to mirror the properties that are set below.
|
||||||
AutoSkipPropertyMirroring askip(CompartmentPrivate::Get(sandbox));
|
AutoSkipPropertyMirroring askip(CompartmentPrivate::Get(sandbox));
|
||||||
|
|
||||||
@ -1127,6 +1114,10 @@ xpc::CreateSandboxObject(JSContext* cx, MutableHandleValue vp, nsISupports* prin
|
|||||||
// every global.
|
// every global.
|
||||||
if (!dom::PromiseBinding::GetConstructorObject(cx, sandbox))
|
if (!dom::PromiseBinding::GetConstructorObject(cx, sandbox))
|
||||||
return NS_ERROR_XPC_UNEXPECTED;
|
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
|
// We handle the case where the context isn't in a compartment for the
|
||||||
|
Loading…
Reference in New Issue
Block a user