Backed out 4 changesets (bug 1136925) for potentially busting m-e10s-dt on a CLOSED TREE

Backed out changeset 331761aaae22 (bug 1136925)
Backed out changeset 2faa0e91fe23 (bug 1136925)
Backed out changeset a00f2530c911 (bug 1136925)
Backed out changeset d5e658bc0792 (bug 1136925)
This commit is contained in:
Wes Kocher 2015-02-26 23:17:34 -08:00
parent 34716e99af
commit bc62dd3b33
26 changed files with 67 additions and 46 deletions

View File

@ -280,6 +280,7 @@ WindowNamedPropertiesHandler::Create(JSContext* aCx,
options.setClass(&WindowNamedPropertiesClass.mBase);
return js::NewProxyObject(aCx, WindowNamedPropertiesHandler::getInstance(),
JS::NullHandleValue, aProto,
js::GetGlobalForObjectCrossCompartment(aProto),
options);
}

View File

@ -1057,15 +1057,13 @@ const nsChromeOuterWindowProxy
nsChromeOuterWindowProxy::singleton;
static JSObject*
NewOuterWindowProxy(JSContext *cx, JS::Handle<JSObject*> global, bool isChrome)
NewOuterWindowProxy(JSContext *cx, JS::Handle<JSObject*> parent, bool isChrome)
{
JSAutoCompartment ac(cx, global);
MOZ_ASSERT(js::GetGlobalForObjectCrossCompartment(global) == global);
JSAutoCompartment ac(cx, parent);
js::WrapperOptions options;
options.setClass(&OuterWindowProxyClass);
options.setSingleton(true);
JSObject *obj = js::Wrapper::New(cx, global,
JSObject *obj = js::Wrapper::New(cx, parent, parent,
isChrome ? &nsChromeOuterWindowProxy::singleton
: &nsOuterWindowProxy::singleton,
options);

View File

@ -1813,7 +1813,7 @@ ReparentWrapper(JSContext* aCx, JS::Handle<JSObject*> aObjArg)
return NS_ERROR_FAILURE;
}
JS::Rooted<JSObject*> newobj(aCx, JS_CloneObject(aCx, aObj, proto));
JS::Rooted<JSObject*> newobj(aCx, JS_CloneObject(aCx, aObj, proto, newParent));
if (!newobj) {
return NS_ERROR_FAILURE;
}

View File

@ -2802,7 +2802,7 @@ public:
options.setClass(aClass);
JS::Rooted<JS::Value> proxyPrivateVal(aCx, JS::PrivateValue(aNative));
aReflector.set(js::NewProxyObject(aCx, aHandler, proxyPrivateVal, aProto,
options));
/* parent= */nullptr, options));
if (aReflector) {
mNative = aNative;
mReflector = aReflector;

View File

@ -1020,6 +1020,7 @@ WrapperOwner::fromRemoteObjectVariant(JSContext *cx, RemoteObject objVar)
&CPOWProxyHandler::singleton,
v,
nullptr,
junkScope,
options);
if (!obj)
return nullptr;

View File

@ -581,7 +581,7 @@ class MOZ_STACK_CLASS ProxyOptions {
JS_FRIEND_API(JSObject *)
NewProxyObject(JSContext *cx, const BaseProxyHandler *handler, HandleValue priv,
JSObject *proto, const ProxyOptions &options = ProxyOptions());
JSObject *proto, JSObject *parent, const ProxyOptions &options = ProxyOptions());
JSObject *
RenewProxyObject(JSContext *cx, JSObject *obj, BaseProxyHandler *handler, Value priv);

View File

@ -44,9 +44,10 @@ PreWrap(JSContext *cx, JS::HandleObject scope, JS::HandleObject obj,
}
static JSObject *
Wrap(JSContext *cx, JS::HandleObject existing, JS::HandleObject obj)
Wrap(JSContext *cx, JS::HandleObject existing, JS::HandleObject obj,
JS::HandleObject parent)
{
return js::Wrapper::New(cx, obj, &js::CrossCompartmentWrapper::singleton);
return js::Wrapper::New(cx, obj, parent, &js::CrossCompartmentWrapper::singleton);
}
static const JSWrapObjectCallbacks WrapObjectCallbacks = {
@ -59,7 +60,7 @@ BEGIN_TEST(testBug604087)
js::WrapperOptions options;
options.setClass(&OuterWrapperClass);
options.setSingleton(true);
JS::RootedObject outerObj(cx, js::Wrapper::New(cx, global, &js::Wrapper::singleton, options));
JS::RootedObject outerObj(cx, js::Wrapper::New(cx, global, global, &js::Wrapper::singleton, options));
JS::RootedObject compartment2(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr, JS::FireOnNewGlobalHook));
JS::RootedObject compartment3(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr, JS::FireOnNewGlobalHook));
JS::RootedObject compartment4(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr, JS::FireOnNewGlobalHook));
@ -80,7 +81,7 @@ BEGIN_TEST(testBug604087)
JS::RootedObject next(cx);
{
JSAutoCompartment ac(cx, compartment2);
next = js::Wrapper::New(cx, compartment2, &js::Wrapper::singleton, options);
next = js::Wrapper::New(cx, compartment2, compartment2, &js::Wrapper::singleton, options);
CHECK(next);
}

View File

@ -72,7 +72,7 @@ BEGIN_TEST(testSetPropertyIgnoringNamedGetter_direct)
EVAL("({})", &targetv);
RootedObject proxyObj(cx, NewProxyObject(cx, &customProxyHandler, targetv,
&protov.toObject(), ProxyOptions()));
&protov.toObject(), global, ProxyOptions()));
CHECK(proxyObj);
CHECK(JS_DefineProperty(cx, global, "target", targetv, 0));

View File

@ -738,7 +738,8 @@ typedef bool
* guaranteed not to wrap a function.
*/
typedef JSObject *
(* JSWrapObjectCallback)(JSContext *cx, JS::HandleObject existing, JS::HandleObject obj);
(* JSWrapObjectCallback)(JSContext *cx, JS::HandleObject existing, JS::HandleObject obj,
JS::HandleObject parent);
/*
* Callback used by the wrap hook to ask the embedding to prepare an object

View File

@ -443,7 +443,7 @@ JSCompartment::wrap(JSContext *cx, MutableHandleObject obj, HandleObject existin
}
}
obj.set(cb->wrap(cx, existing, obj));
obj.set(cb->wrap(cx, existing, obj, global));
if (!obj)
return false;

View File

@ -622,10 +622,10 @@ JS_SetAccumulateTelemetryCallback(JSRuntime *rt, JSAccumulateTelemetryDataCallba
}
JS_FRIEND_API(JSObject *)
JS_CloneObject(JSContext *cx, HandleObject obj, HandleObject protoArg)
JS_CloneObject(JSContext *cx, HandleObject obj, HandleObject protoArg, HandleObject parent)
{
Rooted<TaggedProto> proto(cx, TaggedProto(protoArg.get()));
return CloneObject(cx, obj, proto);
return CloneObject(cx, obj, proto, parent);
}
#ifdef DEBUG

View File

@ -148,7 +148,8 @@ extern JS_FRIEND_API(JSObject *)
JS_ObjectToOuterObject(JSContext *cx, JS::HandleObject obj);
extern JS_FRIEND_API(JSObject *)
JS_CloneObject(JSContext *cx, JS::HandleObject obj, JS::HandleObject proto);
JS_CloneObject(JSContext *cx, JS::HandleObject obj, JS::HandleObject proto,
JS::HandleObject parent);
/*
* Copy the own properties of src to dst in a fast way. src and dst must both

View File

@ -1777,7 +1777,7 @@ CopyProxyObject(JSContext *cx, Handle<ProxyObject *> from, Handle<ProxyObject *>
}
JSObject *
js::CloneObject(JSContext *cx, HandleObject obj, Handle<js::TaggedProto> proto)
js::CloneObject(JSContext *cx, HandleObject obj, Handle<js::TaggedProto> proto, HandleObject parent)
{
if (!obj->isNative() && !obj->is<ProxyObject>()) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr,
@ -1787,7 +1787,7 @@ js::CloneObject(JSContext *cx, HandleObject obj, Handle<js::TaggedProto> proto)
RootedObject clone(cx);
if (obj->isNative()) {
clone = NewObjectWithGivenTaggedProto(cx, obj->getClass(), proto, NullPtr());
clone = NewObjectWithGivenTaggedProto(cx, obj->getClass(), proto, parent);
if (!clone)
return nullptr;
@ -1803,7 +1803,7 @@ js::CloneObject(JSContext *cx, HandleObject obj, Handle<js::TaggedProto> proto)
ProxyOptions options;
options.setClass(obj->getClass());
clone = ProxyObject::New(cx, GetProxyHandler(obj), JS::NullHandleValue, proto, options);
clone = ProxyObject::New(cx, GetProxyHandler(obj), JS::NullHandleValue, proto, parent, options);
if (!clone)
return nullptr;

View File

@ -1137,7 +1137,7 @@ extern JSObject *
CreateThis(JSContext *cx, const js::Class *clasp, js::HandleObject callee);
extern JSObject *
CloneObject(JSContext *cx, HandleObject obj, Handle<js::TaggedProto> proto);
CloneObject(JSContext *cx, HandleObject obj, Handle<js::TaggedProto> proto, HandleObject parent);
extern NativeObject *
DeepCloneObjectLiteral(JSContext *cx, HandleNativeObject obj, NewObjectKind newKind = GenericObject);

View File

@ -69,7 +69,7 @@ class JS_FRIEND_API(Wrapper) : public DirectProxyHandler
virtual bool defaultValue(JSContext *cx, HandleObject obj, JSType hint,
MutableHandleValue vp) const MOZ_OVERRIDE;
static JSObject *New(JSContext *cx, JSObject *obj, const Wrapper *handler,
static JSObject *New(JSContext *cx, JSObject *obj, JSObject *parent, const Wrapper *handler,
const WrapperOptions &options = WrapperOptions());
static JSObject *Renew(JSContext *cx, JSObject *existing, JSObject *obj, const Wrapper *handler);
@ -217,7 +217,8 @@ typedef SecurityWrapper<Wrapper> SameCompartmentSecurityWrapper;
typedef SecurityWrapper<CrossCompartmentWrapper> CrossCompartmentSecurityWrapper;
extern JSObject *
TransparentObjectWrapper(JSContext *cx, HandleObject existing, HandleObject obj);
TransparentObjectWrapper(JSContext *cx, HandleObject existing, HandleObject obj,
HandleObject parent);
inline bool
IsWrapper(JSObject *obj)

View File

@ -728,14 +728,15 @@ const Class* const js::ProxyClassPtr = &js::ProxyObject::class_;
JS_FRIEND_API(JSObject *)
js::NewProxyObject(JSContext *cx, const BaseProxyHandler *handler, HandleValue priv, JSObject *proto_,
const ProxyOptions &options)
JSObject *parent_, const ProxyOptions &options)
{
if (options.lazyProto()) {
MOZ_ASSERT(!proto_);
proto_ = TaggedProto::LazyProto;
}
return ProxyObject::New(cx, handler, priv, TaggedProto(proto_), options);
return ProxyObject::New(cx, handler, priv, TaggedProto(proto_), parent_,
options);
}
void

View File

@ -1206,7 +1206,7 @@ NewScriptedProxy(JSContext *cx, CallArgs &args, const char *callerName)
RootedValue priv(cx, ObjectValue(*target));
JSObject *proxy_ =
NewProxyObject(cx, &ScriptedDirectProxyHandler::singleton,
priv, TaggedProto::LazyProto);
priv, TaggedProto::LazyProto, cx->global());
if (!proxy_)
return false;
Rooted<ProxyObject*> proxy(cx, &proxy_->as<ProxyObject>());

View File

@ -406,16 +406,19 @@ js::proxy_create(JSContext *cx, unsigned argc, Value *vp)
JSObject *handler = NonNullObject(cx, args[0]);
if (!handler)
return false;
JSObject *proto;
JSObject *proto, *parent = nullptr;
if (args.get(1).isObject()) {
proto = &args[1].toObject();
parent = proto->getParent();
} else {
MOZ_ASSERT(IsFunctionObject(&args.callee()));
proto = nullptr;
}
if (!parent)
parent = args.callee().getParent();
RootedValue priv(cx, ObjectValue(*handler));
JSObject *proxy = NewProxyObject(cx, &ScriptedIndirectProxyHandler::singleton,
priv, proto);
priv, proto, parent);
if (!proxy)
return false;
@ -435,9 +438,12 @@ js::proxy_createFunction(JSContext *cx, unsigned argc, Value *vp)
RootedObject handler(cx, NonNullObject(cx, args[0]));
if (!handler)
return false;
RootedObject proto(cx, args.callee().global().getOrCreateFunctionPrototype(cx));
RootedObject proto(cx), parent(cx);
parent = args.callee().getParent();
proto = parent->global().getOrCreateFunctionPrototype(cx);
if (!proto)
return false;
parent = proto->getParent();
RootedObject call(cx, ValueToCallable(cx, args[1], args.length() - 2));
if (!call)
@ -463,7 +469,7 @@ js::proxy_createFunction(JSContext *cx, unsigned argc, Value *vp)
RootedValue priv(cx, ObjectValue(*handler));
JSObject *proxy =
NewProxyObject(cx, &CallableScriptedIndirectProxyHandler::singleton,
priv, proto);
priv, proto, parent);
if (!proxy)
return false;
proxy->as<ProxyObject>().setExtra(0, ObjectValue(*ccHolder));

View File

@ -33,11 +33,13 @@ Wrapper::defaultValue(JSContext *cx, HandleObject proxy, JSType hint, MutableHan
}
JSObject *
Wrapper::New(JSContext *cx, JSObject *obj, const Wrapper *handler,
Wrapper::New(JSContext *cx, JSObject *obj, JSObject *parent, const Wrapper *handler,
const WrapperOptions &options)
{
MOZ_ASSERT(parent);
RootedValue priv(cx, ObjectValue(*obj));
return NewProxyObject(cx, handler, priv, options.proto(), options);
return NewProxyObject(cx, handler, priv, options.proto(), parent, options);
}
JSObject *
@ -125,11 +127,12 @@ JSObject *Wrapper::defaultProto = TaggedProto::LazyProto;
/* Compartments. */
extern JSObject *
js::TransparentObjectWrapper(JSContext *cx, HandleObject existing, HandleObject obj)
js::TransparentObjectWrapper(JSContext *cx, HandleObject existing, HandleObject obj,
HandleObject parent)
{
// Allow wrapping outer window proxies.
MOZ_ASSERT(!obj->is<WrapperObject>() || obj->getClass()->ext.innerObject);
return Wrapper::New(cx, obj, &CrossCompartmentWrapper::singleton);
return Wrapper::New(cx, obj, parent, &CrossCompartmentWrapper::singleton);
}
ErrorCopier::~ErrorCopier()

View File

@ -3968,7 +3968,7 @@ WrapWithProto(JSContext *cx, unsigned argc, jsval *vp)
WrapperOptions options(cx);
options.setProto(proto.toObjectOrNull());
JSObject *wrapped = Wrapper::New(cx, &obj.toObject(),
JSObject *wrapped = Wrapper::New(cx, &obj.toObject(), &obj.toObject().global(),
&Wrapper::singletonWithPrototype, options);
if (!wrapped)
return false;

View File

@ -14,14 +14,16 @@ using namespace js;
/* static */ ProxyObject *
ProxyObject::New(JSContext *cx, const BaseProxyHandler *handler, HandleValue priv, TaggedProto proto_,
const ProxyOptions &options)
JSObject *parent_, const ProxyOptions &options)
{
Rooted<TaggedProto> proto(cx, proto_);
RootedObject parent(cx, parent_);
const Class *clasp = options.clasp();
MOZ_ASSERT(isValidProxyClass(clasp));
MOZ_ASSERT_IF(proto.isObject(), cx->compartment() == proto.toObject()->compartment());
MOZ_ASSERT_IF(parent, cx->compartment() == parent->compartment());
/*
* Eagerly mark properties unknown for proxies, so we don't try to track
@ -48,7 +50,7 @@ ProxyObject::New(JSContext *cx, const BaseProxyHandler *handler, HandleValue pri
// Note: this will initialize the object's |data| to strange values, but we
// will immediately overwrite those below.
RootedObject obj(cx, NewObjectWithGivenTaggedProto(cx, clasp, proto, NullPtr(), allocKind,
RootedObject obj(cx, NewObjectWithGivenTaggedProto(cx, clasp, proto, parent, allocKind,
newKind));
if (!obj) {
js_free(values);

View File

@ -28,7 +28,8 @@ class ProxyObject : public JSObject
public:
static ProxyObject *New(JSContext *cx, const BaseProxyHandler *handler, HandleValue priv,
TaggedProto proto_, const ProxyOptions &options);
TaggedProto proto_, JSObject *parent_,
const ProxyOptions &options);
const Value &private_() {
return GetProxyPrivate(this);

View File

@ -1736,7 +1736,7 @@ DebugScopeObject::create(JSContext *cx, ScopeObject &scope, HandleObject enclosi
MOZ_ASSERT(scope.compartment() == cx->compartment());
RootedValue priv(cx, ObjectValue(scope));
JSObject *obj = NewProxyObject(cx, &DebugScopeProxy::singleton, priv,
nullptr /* proto */);
nullptr /* proto */, &scope.global());
if (!obj)
return nullptr;

View File

@ -647,7 +647,7 @@ WrapCallable(JSContext *cx, HandleObject callable, HandleObject sandboxProtoProx
RootedValue priv(cx, ObjectValue(*callable));
JSObject *obj = js::NewProxyObject(cx, &xpc::sandboxCallableProxyHandler,
priv, nullptr);
priv, nullptr, nullptr);
if (obj) {
js::SetProxyExtra(obj, SandboxCallableProxyHandler::SandboxProxySlot,
ObjectValue(*sandboxProtoProxy));
@ -972,7 +972,7 @@ xpc::CreateSandboxObject(JSContext *cx, MutableHandleValue vp, nsISupports *prin
// of this-binding for methods.
RootedValue priv(cx, ObjectValue(*options.proto));
options.proto = js::NewProxyObject(cx, &xpc::sandboxProxyHandler,
priv, nullptr);
priv, nullptr, nullptr);
if (!options.proto)
return NS_ERROR_OUT_OF_MEMORY;
}

View File

@ -78,7 +78,9 @@ WrapperFactory::CreateXrayWaiver(JSContext *cx, HandleObject obj)
XPCWrappedNativeScope *scope = ObjectScope(obj);
JSAutoCompartment ac(cx, obj);
JSObject *waiver = Wrapper::New(cx, obj, &XrayWaiver);
JSObject *waiver = Wrapper::New(cx, obj,
JS_GetGlobalForObject(cx, obj),
&XrayWaiver);
if (!waiver)
return nullptr;
@ -380,7 +382,8 @@ SelectAddonWrapper(JSContext *cx, HandleObject obj, const Wrapper *wrapper)
}
JSObject *
WrapperFactory::Rewrap(JSContext *cx, HandleObject existing, HandleObject obj)
WrapperFactory::Rewrap(JSContext *cx, HandleObject existing, HandleObject obj,
HandleObject parent)
{
MOZ_ASSERT(!IsWrapper(obj) ||
GetProxyHandler(obj) == &XrayWaiver ||
@ -501,7 +504,7 @@ WrapperFactory::Rewrap(JSContext *cx, HandleObject existing, HandleObject obj)
if (existing)
return Wrapper::Renew(cx, existing, obj, wrapper);
return Wrapper::New(cx, obj, wrapper);
return Wrapper::New(cx, obj, parent, wrapper);
}
// Call WaiveXrayAndWrap when you have a JS object that you don't want to be

View File

@ -46,7 +46,8 @@ class WrapperFactory {
// Rewrap an object that is about to cross compartment boundaries.
static JSObject *Rewrap(JSContext *cx,
JS::HandleObject existing,
JS::HandleObject obj);
JS::HandleObject obj,
JS::HandleObject parent);
// Wrap wrapped object into a waiver wrapper and then re-wrap it.
static bool WaiveXrayAndWrap(JSContext *cx, JS::MutableHandleValue vp);