Bug 1136925 part 3. Stop passing parents to js::NewProxyObject. r=waldo

This commit is contained in:
Boris Zbarsky 2015-02-26 15:58:59 -05:00
parent c210c7621b
commit e8c2fb81d9
11 changed files with 14 additions and 22 deletions

View File

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

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,
/* parent= */nullptr, options));
options));
if (aReflector) {
mNative = aNative;
mReflector = aReflector;

View File

@ -1020,7 +1020,6 @@ 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, JSObject *parent, const ProxyOptions &options = ProxyOptions());
JSObject *proto, const ProxyOptions &options = ProxyOptions());
JSObject *
RenewProxyObject(JSContext *cx, JSObject *obj, BaseProxyHandler *handler, Value priv);

View File

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

View File

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

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, cx->global());
priv, TaggedProto::LazyProto);
if (!proxy_)
return false;
Rooted<ProxyObject*> proxy(cx, &proxy_->as<ProxyObject>());

View File

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

View File

@ -37,7 +37,7 @@ Wrapper::New(JSContext *cx, JSObject *obj, const Wrapper *handler,
const WrapperOptions &options)
{
RootedValue priv(cx, ObjectValue(*obj));
return NewProxyObject(cx, handler, priv, options.proto(), nullptr, options);
return NewProxyObject(cx, handler, priv, options.proto(), options);
}
JSObject *

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 */, &scope.global());
nullptr /* proto */);
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, nullptr);
priv, 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, nullptr);
priv, nullptr);
if (!options.proto)
return NS_ERROR_OUT_OF_MEMORY;
}