Backed out changeset 6c7ebb2f5a92 (bug 1134006) for bustage

This commit is contained in:
Carsten "Tomcat" Book 2015-03-10 12:37:24 +01:00
parent f064117eb7
commit fcc855696d
4 changed files with 5 additions and 106 deletions

View File

@ -206,31 +206,13 @@
function recvDomTest(message) {
savedElement = message.objects.element;
is(savedElement.QueryInterface(Components.interfaces.nsISupports), savedElement,
"QI to nsISupports works");
is(savedElement.QueryInterface(Components.interfaces.nsIDOMNode), savedElement,
"QI to a random (implemented) interface works");
function testNoInterface(savedElement, i) {
try {
savedElement.QueryInterface(i);
ok(false, "should have thrown an exception");
} catch (e) {
is(e.result, Components.results.NS_ERROR_NO_INTERFACE, "threw the right exception");
}
}
testNoInterface(savedElement, Components.interfaces.nsIDOMAttr);
testNoInterface(savedElement, Components.interfaces.nsIClassInfo);
// Test to ensure that we don't pass CPOWs to C++-implemented interfaces.
// See bug 1072980.
if (test_state == "remote") {
// This doesn't work because we intercept toString and QueryInterface specially
// This doesn't work because we intercept toString specially
// and don't cache the function pointer.
// See bug 1140636.
todo_is(savedElement.toString, savedElement.toString, "toString identity works");
todo_is(savedElement.QueryInterface, savedElement.QueryInterface, "toString identity works");
// This does work because we create a CPOW for isEqualNode that stays
// alive as long as we have a reference to the first CPOW (so as long

View File

@ -37,7 +37,6 @@ struct RemoteObject
uint64_t serializedId;
bool isCallable;
bool isConstructor;
bool isDOMObject;
nsCString objectTag;
};

View File

@ -10,7 +10,6 @@
#include "mozilla/unused.h"
#include "mozilla/dom/BindingUtils.h"
#include "jsfriendapi.h"
#include "js/CharacterEncoding.h"
#include "xpcprivate.h"
#include "CPOWTimer.h"
#include "WrapperFactory.h"
@ -27,21 +26,15 @@ struct AuxCPOWData
ObjectId id;
bool isCallable;
bool isConstructor;
bool isDOMObject;
// The object tag is just some auxilliary information that clients can use
// however they see fit.
nsCString objectTag;
AuxCPOWData(ObjectId id,
bool isCallable,
bool isConstructor,
bool isDOMObject,
const nsACString &objectTag)
AuxCPOWData(ObjectId id, bool isCallable, bool isConstructor, const nsACString &objectTag)
: id(id),
isCallable(isCallable),
isConstructor(isConstructor),
isDOMObject(isDOMObject),
objectTag(objectTag)
{}
};
@ -160,7 +153,7 @@ CPOWProxyHandler::getPropertyDescriptor(JSContext *cx, HandleObject proxy, Handl
bool
WrapperOwner::getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
MutableHandle<JSPropertyDescriptor> desc)
MutableHandle<JSPropertyDescriptor> desc)
{
ObjectId objId = idOf(proxy);
@ -190,7 +183,7 @@ CPOWProxyHandler::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, Ha
bool
WrapperOwner::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
MutableHandle<JSPropertyDescriptor> desc)
MutableHandle<JSPropertyDescriptor> desc)
{
ObjectId objId = idOf(proxy);
@ -221,7 +214,7 @@ CPOWProxyHandler::defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
bool
WrapperOwner::defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
MutableHandle<JSPropertyDescriptor> desc,
MutableHandle<JSPropertyDescriptor> desc,
ObjectOpResult &result)
{
ObjectId objId = idOf(proxy);
@ -345,19 +338,6 @@ CPOWProxyHandler::get(JSContext *cx, HandleObject proxy, HandleObject receiver,
FORWARD(get, (cx, proxy, receiver, id, vp));
}
static bool
CPOWDOMQI(JSContext *cx, unsigned argc, Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
if (!args.thisv().isObject() || !IsCPOW(&args.thisv().toObject())) {
JS_ReportError(cx, "bad this object passed to special QI");
return false;
}
RootedObject proxy(cx, &args.thisv().toObject());
FORWARD(DOMQI, (cx, proxy, args));
}
static bool
CPOWToString(JSContext *cx, unsigned argc, Value *vp)
{
@ -412,49 +392,6 @@ WrapperOwner::toString(JSContext *cx, HandleObject cpow, JS::CallArgs &args)
return true;
}
bool
WrapperOwner::DOMQI(JSContext *cx, JS::HandleObject proxy, JS::CallArgs &args)
{
// Someone's calling us, handle nsISupports specially to avoid unnecessary
// CPOW traffic.
HandleValue id = args[0];
if (id.isObject()) {
RootedObject idobj(cx, &id.toObject());
nsCOMPtr<nsIJSID> jsid;
nsresult rv = UnwrapArg<nsIJSID>(idobj, getter_AddRefs(jsid));
if (NS_SUCCEEDED(rv)) {
MOZ_ASSERT(jsid, "bad wrapJS");
const nsID *idptr = jsid->GetID();
if (idptr->Equals(NS_GET_IID(nsISupports))) {
args.rval().set(args.thisv());
return true;
}
// Webidl-implemented DOM objects never have nsIClassInfo.
if (idptr->Equals(NS_GET_IID(nsIClassInfo)))
return Throw(cx, NS_ERROR_NO_INTERFACE);
}
}
// It wasn't nsISupports, call into the other process to do the QI for us
// (since we don't know what other interfaces our object supports). Note
// that we have to use JS_GetPropertyDescriptor here to avoid infinite
// recursion back into CPOWDOMQI via WrapperOwner::get().
// We could stash the actual QI function on our own function object to avoid
// if we're called multiple times, but since we're transient, there's no
// point right now.
JS::Rooted<JSPropertyDescriptor> propDesc(cx);
if (!JS_GetPropertyDescriptor(cx, proxy, "QueryInterface", &propDesc))
return false;
if (!propDesc.value().isObject()) {
MOZ_ASSERT_UNREACHABLE("We didn't get QueryInterface off a node");
return Throw(cx, NS_ERROR_UNEXPECTED);
}
return JS_CallFunctionValue(cx, proxy, propDesc.value(), args, args.rval());
}
bool
WrapperOwner::get(JSContext *cx, HandleObject proxy, HandleObject receiver,
HandleId id, MutableHandleValue vp)
@ -469,22 +406,6 @@ WrapperOwner::get(JSContext *cx, HandleObject proxy, HandleObject receiver,
if (!toJSIDVariant(cx, id, &idVar))
return false;
AuxCPOWData *data = AuxCPOWDataOf(proxy);
if (data->isDOMObject &&
idVar.type() == JSIDVariant::TnsString &&
idVar.get_nsString().EqualsLiteral("QueryInterface"))
{
// Handle QueryInterface on DOM Objects specially since we can assume
// certain things about their implementation.
RootedFunction qi(cx, JS_NewFunction(cx, CPOWDOMQI, 1, 0, proxy,
"QueryInterface"));
if (!qi)
return false;
vp.set(ObjectValue(*JS_GetFunctionObject(qi)));
return true;
}
JSVariant val;
ReturnStatus status;
if (!SendGet(objId, receiverVar, idVar, &status, &val))
@ -1046,7 +967,6 @@ MakeRemoteObject(JSContext *cx, ObjectId id, HandleObject obj)
return RemoteObject(id.serialize(),
JS::IsCallable(obj),
JS::IsConstructor(obj),
dom::IsDOMObject(obj),
objectTag);
}
@ -1131,7 +1051,6 @@ WrapperOwner::fromRemoteObjectVariant(JSContext *cx, RemoteObject objVar)
AuxCPOWData *aux = new AuxCPOWData(objId,
objVar.isCallable(),
objVar.isConstructor(),
objVar.isDOMObject(),
objVar.objectTag());
SetProxyExtra(obj, 0, PrivateValue(this));

View File

@ -63,7 +63,6 @@ class WrapperOwner : public virtual JavaScriptShared
nsresult instanceOf(JSObject *obj, const nsID *id, bool *bp);
bool toString(JSContext *cx, JS::HandleObject callee, JS::CallArgs &args);
bool DOMQI(JSContext *cx, JS::HandleObject callee, JS::CallArgs &args);
/*
* Check that |obj| is a DOM wrapper whose prototype chain contains