diff --git a/js/src/ctypes/CTypes.cpp b/js/src/ctypes/CTypes.cpp index 0834904bf250..5797e00e7237 100644 --- a/js/src/ctypes/CTypes.cpp +++ b/js/src/ctypes/CTypes.cpp @@ -155,8 +155,6 @@ bool PtrGetter(JSContext* cx, const JS::CallArgs& args); static bool CreateArray(JSContext* cx, unsigned argc, Value* vp); static bool ToString(JSContext* cx, unsigned argc, Value* vp); static bool ToSource(JSContext* cx, unsigned argc, Value* vp); -static bool HasInstance(JSContext* cx, HandleObject obj, MutableHandleValue v, - bool* bp); /* * Get the global "ctypes" object. @@ -487,7 +485,7 @@ static const JSClassOps sCTypeClassOps = { nullptr, // mayResolve CType::Finalize, // finalize CType::ConstructData, // call - CType::HasInstance, // hasInstance + nullptr, // hasInstance CType::ConstructData, // construct CType::Trace, // trace }; @@ -4929,36 +4927,6 @@ bool CType::ToSource(JSContext* cx, unsigned argc, Value* vp) { return true; } -bool CType::HasInstance(JSContext* cx, HandleObject obj, MutableHandleValue v, - bool* bp) { - MOZ_ASSERT(CType::IsCType(obj)); - - Value slot = JS::GetReservedSlot(obj, SLOT_PROTO); - JS::Rooted prototype(cx, &slot.toObject()); - MOZ_ASSERT(prototype); - MOZ_ASSERT(CData::IsCDataProto(prototype)); - - *bp = false; - if (v.isPrimitive()) { - return true; - } - - RootedObject proto(cx, &v.toObject()); - for (;;) { - if (!JS_GetPrototype(cx, proto, &proto)) { - return false; - } - if (!proto) { - break; - } - if (proto == prototype) { - *bp = true; - break; - } - } - return true; -} - static JSObject* CType::GetGlobalCTypes(JSContext* cx, JSObject* objArg) { MOZ_ASSERT(CType::IsCType(objArg)); diff --git a/toolkit/components/ctypes/tests/unit/test_jsctypes.js b/toolkit/components/ctypes/tests/unit/test_jsctypes.js index 85988d1f3425..84267d6fc993 100644 --- a/toolkit/components/ctypes/tests/unit/test_jsctypes.js +++ b/toolkit/components/ctypes/tests/unit/test_jsctypes.js @@ -2168,6 +2168,10 @@ function run_type_ctor_class_tests( Assert.ok(d.__proto__ === t.prototype); Assert.ok(d instanceof t); Assert.ok(d.constructor === t); + // Other objects that are not instances of 't'. + Assert.equal({} instanceof t, false); + Assert.equal(t.__proto__ instanceof t, false); + Assert.equal(t.prototype instanceof t, false); } }