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:
Phil Ringnalda 2015-10-02 22:10:24 -07:00
parent fc2528e0d1
commit 23f82e924e
10 changed files with 37 additions and 136 deletions

View File

@ -274,27 +274,13 @@ WindowNamedPropertiesHandler::Create(JSContext* aCx,
// Note: since the scope polluter proxy lives on the window's prototype
// chain, it needs a singleton type to avoid polluting type information
// for properties on the window.
JS::Rooted<JSObject*> gsp(aCx);
js::ProxyOptions options;
options.setSingleton(true);
options.setClass(&WindowNamedPropertiesClass.mBase);
JS::Rooted<JSObject*> gsp(aCx);
gsp = js::NewProxyObject(aCx, WindowNamedPropertiesHandler::getInstance(),
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;
return js::NewProxyObject(aCx, WindowNamedPropertiesHandler::getInstance(),
JS::NullHandleValue, aProto,
options);
}
} // namespace dom

View File

@ -3111,14 +3111,6 @@ CreateGlobal(JSContext* aCx, T* aNative, nsWrapperCache* aCache,
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;
}

View File

@ -2820,19 +2820,6 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
chromeProperties=chromeProperties,
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]
if aliasedMembers:
assert needInterfacePrototypeObject
@ -2852,18 +2839,17 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
prop = '"%s"' % alias
return CGList([
getSymbolJSID,
# XXX If we ever create non-enumerable properties that can
# be aliased, we should consider making the aliases
# match the enumerability of the property being aliased.
# XXX If we ever create non-enumerate properties that can be
# aliased, we should consider making the aliases match
# the enumerability of the property being aliased.
CGGeneric(fill(
"""
if (!${defineFn}(aCx, proto, ${prop}, aliasedVal, JSPROP_ENUMERATE)) {
$*{failureCode}
return;
}
""",
defineFn=defineFn,
prop=prop,
failureCode=failureCode))
prop=prop))
], "\n")
def defineAliasesFor(m):
@ -2871,23 +2857,21 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
CGGeneric(fill(
"""
if (!JS_GetProperty(aCx, proto, \"${prop}\", &aliasedVal)) {
$*{failureCode}
return;
}
""",
failureCode=failureCode,
prop=m.identifier.name))
] + [defineAlias(alias) for alias in sorted(m.aliases)])
defineAliases = CGList([
CGGeneric(fill("""
CGGeneric(dedent("""
// Set up aliases on the interface prototype object we just created.
JS::Handle<JSObject*> proto = GetProtoObjectHandle(aCx, aGlobal);
if (!proto) {
$*{failureCode}
return;
}
""",
failureCode=failureCode)),
""")),
CGGeneric("JS::Rooted<JS::Value> aliasedVal(aCx);\n\n")
] + [defineAliasesFor(m) for m in sorted(aliasedMembers)])
else:
@ -2913,6 +2897,14 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
else:
holderClass = "Class.ToJSClass()"
holderProto = "*protoCache"
failureCode = dedent(
"""
*protoCache = nullptr;
if (interfaceCache) {
*interfaceCache = nullptr;
}
return;
""")
createUnforgeableHolder = CGGeneric(fill(
"""
JS::Rooted<JSObject*> unforgeableHolder(aCx);
@ -2946,32 +2938,9 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
else:
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(
[getParentProto, CGGeneric(getConstructorProto), initIds,
prefCache, CGGeneric(call), defineAliases, unforgeableHolderSetup,
makeProtoPrototypeImmutable],
prefCache, CGGeneric(call), defineAliases, unforgeableHolderSetup],
"\n").define()

View File

@ -1056,13 +1056,6 @@ CreateObjectPrototype(JSContext* cx, JSProtoKey key)
if (!objectProto)
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
* to have unknown properties, to simplify handling of e.g. heterogenous

View File

@ -6320,12 +6320,6 @@ JS_DecodeInterpretedFunction(JSContext* cx, const void* data, uint32_t length)
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::SetAsmJSCacheOps(JSRuntime* rt, const JS::AsmJSCacheOps* ops)
{

View File

@ -2453,16 +2453,6 @@ JS_FreezeObject(JSContext* cx, JS::Handle<JSObject*> obj);
extern JS_PUBLIC_API(bool)
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*)
JS_New(JSContext* cx, JS::HandleObject ctor, const JS::HandleValueArray& args);

View File

@ -2395,7 +2395,7 @@ JSObject::reportNotExtensible(JSContext* cx, unsigned report)
// immutable-prototype behavior is enforced; if it's false, behavior is not
// enforced, and immutable-prototype bits stored on objects are completely
// ignored.
static const bool ImmutablePrototypesEnabled = false;
static const bool ImmutablePrototypesEnabled = true;
JS_FRIEND_API(bool)
JS_ImmutablePrototypesEnabled()
@ -2467,15 +2467,6 @@ js::SetPrototype(JSContext* cx, HandleObject obj, HandleObject proto, JS::Object
if (!extensible)
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
* 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->hadElementsAccess()) fprintf(stderr, " had_elements_access");
if (obj->wasNewScriptCleared()) fprintf(stderr, " new_script_cleared");
if (!obj->hasLazyPrototype() && obj->nonLazyPrototypeIsImmutable()) fprintf(stderr, " immutable_prototype");
if (obj->isNative()) {
NativeObject* nobj = &obj->as<NativeObject>();

View File

@ -5760,13 +5760,6 @@ NewGlobalObject(JSContext* cx, JS::CompartmentOptions& options,
return nullptr;
#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
if (!JS_InitCTypesClass(cx, glob))
return nullptr;

View File

@ -89,6 +89,9 @@ js::GlobalObject::getTypedObjectModule() const {
return v.toObject().as<TypedObjectModuleObject>();
}
/* static */ bool
GlobalObject::ensureConstructor(JSContext* cx, Handle<GlobalObject*> global, JSProtoKey key)
{

View File

@ -1040,25 +1040,6 @@ xpc::CreateSandboxObject(JSContext* cx, MutableHandleValue vp, nsISupports* prin
{
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) {
bool ok = JS_WrapObject(cx, &options.proto);
if (!ok)
@ -1093,11 +1074,17 @@ xpc::CreateSandboxObject(JSContext* cx, MutableHandleValue vp, nsISupports* prin
return NS_ERROR_OUT_OF_MEMORY;
}
ok = JS_SplicePrototype(cx, sandbox, options.proto);
ok = JS_SetPrototype(cx, sandbox, options.proto);
if (!ok)
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.
AutoSkipPropertyMirroring askip(CompartmentPrivate::Get(sandbox));
@ -1127,6 +1114,10 @@ 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