Bug 1255800 - Remove JS_THIS_OBJECT from js. r=jorendorff

--HG--
extra : rebase_source : ec366038f9619c8c4e8465b9c8ac5b9bc9971086
This commit is contained in:
Tom Schuster 2018-03-22 16:38:30 +01:00
Родитель 4d8cb59be3
Коммит 6eddb18596
13 изменённых файлов: 93 добавлений и 124 удалений

Просмотреть файл

@ -345,49 +345,4 @@ CallArgsFromSp(unsigned stackSlots, Value* sp, bool constructing = false,
} // namespace JS
/*
* Macros to hide interpreter stack layout details from a JSNative using its
* JS::Value* vp parameter. DO NOT USE THESE! Instead use JS::CallArgs and
* friends, above. These macros will be removed when we change JSNative to
* take a const JS::CallArgs&.
*/
/*
* Return |this| if |this| is an object. Otherwise, return the global object
* if |this| is null or undefined, and finally return a boxed version of any
* other primitive.
*
* Note: if this method returns null, an error has occurred and must be
* propagated or caught.
*/
MOZ_ALWAYS_INLINE JS::Value
JS_THIS(JSContext* cx, JS::Value* vp)
{
return vp[1].isPrimitive() ? JS::detail::ComputeThis(cx, vp) : vp[1];
}
/*
* A note on JS_THIS_OBJECT: no equivalent method is part of the CallArgs
* interface, and we're unlikely to add one (functions shouldn't be implicitly
* exposing the global object to arbitrary callers). Continue using |vp|
* directly for this case, but be aware this API will eventually be replaced
* with a function that operates directly upon |args.thisv()|.
*/
#define JS_THIS_OBJECT(cx,vp) (JS_THIS(cx,vp).toObjectOrNull())
/*
* |this| is passed to functions in ES5 without change. Functions themselves
* do any post-processing they desire to box |this|, compute the global object,
* &c. This macro retrieves a function's unboxed |this| value.
*
* This macro must not be used in conjunction with JS_THIS or JS_THIS_OBJECT,
* or vice versa. Either use the provided this value with this macro, or
* compute the boxed |this| value using those. JS_THIS_VALUE must not be used
* if the function is being called as a constructor.
*
* But: DO NOT USE THIS! Instead use JS::CallArgs::thisv(), above.
*
*/
#define JS_THIS_VALUE(cx,vp) ((vp)[1])
#endif /* js_CallArgs_h */

Просмотреть файл

@ -277,7 +277,7 @@ namespace PointerType {
static bool Decrement(JSContext* cx, unsigned argc, Value* vp);
// The following is not an instance function, since we don't want to expose arbitrary
// pointer arithmetic at this moment.
static bool OffsetBy(JSContext* cx, const CallArgs& args, int offset);
static bool OffsetBy(JSContext* cx, const CallArgs& args, int offset, const char* name);
} // namespace PointerType
namespace ArrayType {
@ -1985,6 +1985,17 @@ VariadicArgumentTypeError(JSContext* cx, uint32_t index, HandleValue actual)
return false;
}
MOZ_MUST_USE JSObject*
GetThisObject(JSContext* cx, const CallArgs& args, const char* msg)
{
if (!args.thisv().isObject()) {
IncompatibleThisProto(cx, msg, args.thisv());
return nullptr;
}
return &args.thisv().toObject();
}
static JSObject*
InitCTypeClass(JSContext* cx, HandleObject ctypesObj)
{
@ -4931,7 +4942,7 @@ bool
CType::CreateArray(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject baseType(cx, JS_THIS_OBJECT(cx, vp));
RootedObject baseType(cx, GetThisObject(cx, args, "CType.prototype.array"));
if (!baseType)
return false;
if (!CType::IsCType(baseType)) {
@ -4962,7 +4973,7 @@ bool
CType::ToString(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject obj(cx, JS_THIS_OBJECT(cx, vp));
RootedObject obj(cx, GetThisObject(cx, args, "CType.prototype.toString"));
if (!obj)
return false;
if (!CType::IsCType(obj) && !CType::IsCTypeProto(obj)) {
@ -4993,7 +5004,7 @@ bool
CType::ToSource(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
JSObject* obj = JS_THIS_OBJECT(cx, vp);
JSObject* obj = GetThisObject(cx, args, "CType.prototype.toSource");
if (!obj)
return false;
if (!CType::IsCType(obj) && !CType::IsCTypeProto(obj)) {
@ -5081,7 +5092,7 @@ ABI::ToSource(JSContext* cx, unsigned argc, Value* vp)
return ArgumentLengthError(cx, "ABI.prototype.toSource", "no", "s");
}
JSObject* obj = JS_THIS_OBJECT(cx, vp);
JSObject* obj = GetThisObject(cx, args, "ABI.prototype.toSource");
if (!obj)
return false;
if (!ABI::IsABI(obj)) {
@ -5300,7 +5311,7 @@ bool
PointerType::IsNull(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject obj(cx, JS_THIS_OBJECT(cx, vp));
RootedObject obj(cx, GetThisObject(cx, args, "PointerType.prototype.isNull"));
if (!obj)
return false;
if (!CData::IsCDataMaybeUnwrap(&obj)) {
@ -5321,29 +5332,17 @@ PointerType::IsNull(JSContext* cx, unsigned argc, Value* vp)
}
bool
PointerType::OffsetBy(JSContext* cx, const CallArgs& args, int offset)
PointerType::OffsetBy(JSContext* cx, const CallArgs& args, int offset, const char* name)
{
RootedObject obj(cx, JS_THIS_OBJECT(cx, args.base()));
RootedObject obj(cx, GetThisObject(cx, args, name));
if (!obj)
return false;
if (!CData::IsCDataMaybeUnwrap(&obj)) {
if (offset == 1) {
return IncompatibleThisProto(cx, "PointerType.prototype.increment",
args.thisv());
}
return IncompatibleThisProto(cx, "PointerType.prototype.decrement",
args.thisv());
}
if (!CData::IsCDataMaybeUnwrap(&obj))
return IncompatibleThisProto(cx, name, args.thisv());
RootedObject typeObj(cx, CData::GetCType(obj));
if (CType::GetTypeCode(typeObj) != TYPE_pointer) {
if (offset == 1) {
return IncompatibleThisType(cx, "PointerType.prototype.increment",
"non-PointerType CData", args.thisv());
}
return IncompatibleThisType(cx, "PointerType.prototype.decrement",
"non-PointerType CData", args.thisv());
}
if (CType::GetTypeCode(typeObj) != TYPE_pointer)
return IncompatibleThisType(cx, name, "non-PointerType CData", args.thisv());
RootedObject baseType(cx, PointerType::GetBaseType(typeObj));
if (!CType::IsSizeDefined(baseType)) {
@ -5367,14 +5366,14 @@ bool
PointerType::Increment(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
return OffsetBy(cx, args, 1);
return OffsetBy(cx, args, 1, "PointerType.prototype.increment");
}
bool
PointerType::Decrement(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
return OffsetBy(cx, args, -1);
return OffsetBy(cx, args, -1, "PointerType.prototype.decrement");
}
bool
@ -5859,7 +5858,7 @@ bool
ArrayType::AddressOfElement(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject obj(cx, JS_THIS_OBJECT(cx, vp));
RootedObject obj(cx, GetThisObject(cx, args, "ArrayType.prototype.addressOfElement"));
if (!obj)
return false;
if (!CData::IsCDataMaybeUnwrap(&obj)) {
@ -6262,7 +6261,7 @@ bool
StructType::Define(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject obj(cx, JS_THIS_OBJECT(cx, vp));
RootedObject obj(cx, GetThisObject(cx, args, "StructType.prototype.define"));
if (!obj)
return false;
if (!CType::IsCType(obj)) {
@ -6554,10 +6553,11 @@ bool
StructType::AddressOfField(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject obj(cx, JS_THIS_OBJECT(cx, vp));
RootedObject obj(cx, GetThisObject(cx, args, "StructType.prototype.addressOfField"));
if (!obj)
return false;
if (!CData::IsCDataMaybeUnwrap(&obj)) {
if (!CData::IsCDataMaybeUnwrap(&obj)) {
return IncompatibleThisProto(cx, "StructType.prototype.addressOfField",
args.thisv());
}
@ -7808,7 +7808,7 @@ CData::Address(JSContext* cx, unsigned argc, Value* vp)
return ArgumentLengthError(cx, "CData.prototype.address", "no", "s");
}
RootedObject obj(cx, JS_THIS_OBJECT(cx, vp));
RootedObject obj(cx, GetThisObject(cx, args, "CData.prototype.address"));
if (!obj)
return false;
if (!IsCDataMaybeUnwrap(&obj)) {
@ -7916,7 +7916,7 @@ ReadStringCommon(JSContext* cx, InflateUTF8Method inflateUTF8, unsigned argc,
return ArgumentLengthError(cx, funName, "no", "s");
}
RootedObject obj(cx, JS_THIS_OBJECT(cx, vp));
RootedObject obj(cx, GetThisObject(cx, args, funName));
if (!obj) {
return IncompatibleThisProto(cx, funName, args.thisv());
}
@ -8065,7 +8065,7 @@ CData::ToSource(JSContext* cx, unsigned argc, Value* vp)
return ArgumentLengthError(cx, "CData.prototype.toSource", "no", "s");
}
RootedObject obj(cx, JS_THIS_OBJECT(cx, vp));
RootedObject obj(cx, GetThisObject(cx, args, "CData.prototype.toSource"));
if (!obj)
return false;
if (!CData::IsCDataMaybeUnwrap(&obj) && !CData::IsCDataProto(obj)) {
@ -8110,7 +8110,7 @@ bool
CDataFinalizer::Methods::ToSource(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject objThis(cx, JS_THIS_OBJECT(cx, vp));
RootedObject objThis(cx, GetThisObject(cx, args, "CDataFinalizer.prototype.toSource"));
if (!objThis)
return false;
if (!CDataFinalizer::IsCDataFinalizer(objThis)) {
@ -8169,7 +8169,7 @@ bool
CDataFinalizer::Methods::ToString(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
JSObject* objThis = JS_THIS_OBJECT(cx, vp);
JSObject* objThis = GetThisObject(cx, args, "CDataFinalizer.prototype.toString");
if (!objThis)
return false;
if (!CDataFinalizer::IsCDataFinalizer(objThis)) {
@ -8489,7 +8489,7 @@ CDataFinalizer::Methods::Forget(JSContext* cx, unsigned argc, Value* vp)
"s");
}
RootedObject obj(cx, JS_THIS_OBJECT(cx, vp));
RootedObject obj(cx, GetThisObject(cx, args, "CDataFinalizer.prototype.forget"));
if (!obj)
return false;
if (!CDataFinalizer::IsCDataFinalizer(obj)) {
@ -8536,7 +8536,7 @@ CDataFinalizer::Methods::Dispose(JSContext* cx, unsigned argc, Value* vp)
"s");
}
RootedObject obj(cx, JS_THIS_OBJECT(cx, vp));
RootedObject obj(cx, GetThisObject(cx, args, "CDataFinalizer.prototype.dispose"));
if (!obj)
return false;
if (!CDataFinalizer::IsCDataFinalizer(obj)) {
@ -8819,7 +8819,7 @@ bool
Int64::ToString(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject obj(cx, JS_THIS_OBJECT(cx, vp));
RootedObject obj(cx, GetThisObject(cx, args, "Int64.prototype.toString"));
if (!obj)
return false;
if (!Int64::IsInt64(obj)) {
@ -8838,7 +8838,7 @@ bool
Int64::ToSource(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject obj(cx, JS_THIS_OBJECT(cx, vp));
RootedObject obj(cx, GetThisObject(cx, args, "Int64.prototype.toSource"));
if (!obj)
return false;
if (!Int64::IsInt64(obj)) {
@ -9003,7 +9003,7 @@ bool
UInt64::ToString(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject obj(cx, JS_THIS_OBJECT(cx, vp));
RootedObject obj(cx, GetThisObject(cx, args, "UInt64.prototype.toString"));
if (!obj)
return false;
if (!UInt64::IsUInt64(obj)) {
@ -9022,7 +9022,7 @@ bool
UInt64::ToSource(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject obj(cx, JS_THIS_OBJECT(cx, vp));
RootedObject obj(cx, GetThisObject(cx, args, "UInt64.prototype.toSource"));
if (!obj)
return false;
if (!UInt64::IsUInt64(obj)) {

Просмотреть файл

@ -181,6 +181,8 @@ MOZ_MUST_USE bool
DeflateStringToUTF8Buffer(JSContext* maybecx, const CharT* src, size_t srclen,
char* dst, size_t* dstlenp);
MOZ_MUST_USE JSObject*
GetThisObject(JSContext* cx, const CallArgs& args, const char* msg);
/*******************************************************************************
** Function and struct API definitions

Просмотреть файл

@ -213,9 +213,10 @@ bool
Library::Open(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
JSObject* ctypesObj = JS_THIS_OBJECT(cx, vp);
JSObject* ctypesObj = GetThisObject(cx, args, "ctypes.open");
if (!ctypesObj)
return false;
if (!IsCTypesGlobal(ctypesObj)) {
JS_ReportErrorASCII(cx, "not a ctypes object");
return false;
@ -239,10 +240,11 @@ Library::Close(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject obj(cx);
if (args.thisv().isObject())
obj = &args.thisv().toObject();
if (!obj || !IsLibrary(obj)) {
RootedObject obj(cx, GetThisObject(cx, args, "ctypes.close"));
if (!obj)
return false;
if (!IsLibrary(obj)) {
JS_ReportErrorASCII(cx, "not a library");
return false;
}
@ -264,9 +266,11 @@ bool
Library::Declare(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject obj(cx, JS_THIS_OBJECT(cx, vp));
RootedObject obj(cx, GetThisObject(cx, args, "ctypes.declare"));
if (!obj)
return false;
if (!IsLibrary(obj)) {
JS_ReportErrorASCII(cx, "not a library");
return false;

Просмотреть файл

@ -2,7 +2,7 @@ load(libdir + 'asserts.js');
function test() {
assertTypeErrorMessage(() => { ctypes.default_abi.toSource.call(1); },
"ABI.prototype.toSource called on incompatible Number");
"ABI.prototype.toSource called on incompatible object, got the number 1");
}
if (typeof ctypes === "object")

Просмотреть файл

@ -2,9 +2,9 @@ load(libdir + 'asserts.js');
function test() {
assertTypeErrorMessage(() => { ctypes.int32_t.array.call(1); },
"CType.prototype.array called on incompatible object, got the object (new Number(1))");
"CType.prototype.array called on incompatible object, got the number 1");
assertTypeErrorMessage(() => { ctypes.int32_t.array(10)().addressOfElement.call(1); },
"ArrayType.prototype.addressOfElement called on incompatible object, got the object (new Number(1))");
"ArrayType.prototype.addressOfElement called on incompatible object, got the number 1");
assertTypeErrorMessage(() => { ctypes.int32_t.array(10)().addressOfElement.call(ctypes.int32_t(0)); },
"ArrayType.prototype.addressOfElement called on non-ArrayType CData, got ctypes.int32_t(0)");
}

Просмотреть файл

@ -2,14 +2,14 @@ load(libdir + 'asserts.js');
function test() {
assertTypeErrorMessage(() => { ctypes.int32_t(0).address.call(1); },
"CData.prototype.address called on incompatible object, got the object (new Number(1))");
"CData.prototype.address called on incompatible object, got the number 1");
assertTypeErrorMessage(() => { ctypes.char.array(10)("abc").readString.call(1); },
"CData.prototype.readString called on incompatible object, got the object (new Number(1))");
"CData.prototype.readString called on incompatible object, got the number 1");
assertTypeErrorMessage(() => { ctypes.char.array(10)("abc").readStringReplaceMalformed.call(1); },
"CData.prototype.readStringReplaceMalformed called on incompatible object, got the object (new Number(1))");
"CData.prototype.readStringReplaceMalformed called on incompatible object, got the number 1");
assertTypeErrorMessage(() => { ctypes.int32_t(0).toSource.call(1); },
"CData.prototype.toSource called on incompatible Number");
"CData.prototype.toSource called on incompatible object, got the number 1");
let p = Object.getPrototypeOf(ctypes.int32_t());
let o = {};

Просмотреть файл

@ -2,9 +2,9 @@ load(libdir + 'asserts.js');
function test() {
assertTypeErrorMessage(() => { ctypes.int32_t.toString.call(1); },
"CType.prototype.toString called on incompatible Number");
"CType.prototype.toString called on incompatible object, got the number 1");
assertTypeErrorMessage(() => { ctypes.int32_t.toSource.call(1); },
"CType.prototype.toSource called on incompatible Number");
"CType.prototype.toSource called on incompatible object, got the number 1");
}
if (typeof ctypes === "object")

Просмотреть файл

@ -3,13 +3,13 @@ load(libdir + 'asserts.js');
function test() {
let fin = ctypes.CDataFinalizer(ctypes.int32_t(0), ctypes.FunctionType(ctypes.default_abi, ctypes.int32_t, [ctypes.int32_t]).ptr(x => x));
assertTypeErrorMessage(() => { fin.toSource.call(1); },
"CDataFinalizer.prototype.toSource called on incompatible Number");
"CDataFinalizer.prototype.toSource called on incompatible object, got the number 1");
assertTypeErrorMessage(() => { fin.toString.call(1); },
"CDataFinalizer.prototype.toString called on incompatible Number");
"CDataFinalizer.prototype.toString called on incompatible object, got the number 1");
assertTypeErrorMessage(() => { fin.forget.call(1); },
"CDataFinalizer.prototype.forget called on incompatible object, got the object (new Number(1))");
"CDataFinalizer.prototype.forget called on incompatible object, got the number 1");
assertTypeErrorMessage(() => { fin.dispose.call(1); },
"CDataFinalizer.prototype.dispose called on incompatible object, got the object (new Number(1))");
"CDataFinalizer.prototype.dispose called on incompatible object, got the number 1");
fin.forget();
assertTypeErrorMessage(() => { fin.readString(); },

Просмотреть файл

@ -2,20 +2,20 @@ load(libdir + 'asserts.js');
function test() {
assertTypeErrorMessage(() => { ctypes.Int64(0).toString.call(1); },
"Int64.prototype.toString called on incompatible Number");
"Int64.prototype.toString called on incompatible object, got the number 1");
assertTypeErrorMessage(() => { ctypes.Int64(0).toString.call(ctypes.int32_t(0)); },
"Int64.prototype.toString called on non-Int64 CData");
assertTypeErrorMessage(() => { ctypes.Int64(0).toSource.call(1); },
"Int64.prototype.toSource called on incompatible Number");
"Int64.prototype.toSource called on incompatible object, got the number 1");
assertTypeErrorMessage(() => { ctypes.Int64(0).toSource.call(ctypes.int32_t(0)); },
"Int64.prototype.toSource called on non-Int64 CData");
assertTypeErrorMessage(() => { ctypes.UInt64(0).toString.call(1); },
"UInt64.prototype.toString called on incompatible Number");
"UInt64.prototype.toString called on incompatible object, got the number 1");
assertTypeErrorMessage(() => { ctypes.UInt64(0).toString.call(ctypes.int32_t(0)); },
"UInt64.prototype.toString called on non-UInt64 CData");
assertTypeErrorMessage(() => { ctypes.UInt64(0).toSource.call(1); },
"UInt64.prototype.toSource called on incompatible Number");
"UInt64.prototype.toSource called on incompatible object, got the number 1");
assertTypeErrorMessage(() => { ctypes.UInt64(0).toSource.call(ctypes.int32_t(0)); },
"UInt64.prototype.toSource called on non-UInt64 CData");
}

Просмотреть файл

@ -2,15 +2,15 @@ load(libdir + 'asserts.js');
function test() {
assertTypeErrorMessage(() => { ctypes.int32_t.ptr(0).isNull.call(1); },
"PointerType.prototype.isNull called on incompatible object, got the object (new Number(1))");
"PointerType.prototype.isNull called on incompatible object, got the number 1");
assertTypeErrorMessage(() => { ctypes.int32_t.ptr(0).isNull.call({}); },
"PointerType.prototype.isNull called on incompatible object, got the object ({})");
assertTypeErrorMessage(() => { ctypes.int32_t.ptr(0).increment.call(1); },
"PointerType.prototype.increment called on incompatible object, got the object (new Number(1))");
"PointerType.prototype.increment called on incompatible object, got the number 1");
assertTypeErrorMessage(() => { ctypes.int32_t.ptr(0).increment.call(ctypes.int32_t(0)); },
"PointerType.prototype.increment called on non-PointerType CData, got ctypes.int32_t(0)");
assertTypeErrorMessage(() => { ctypes.int32_t.ptr(0).decrement.call(1); },
"PointerType.prototype.decrement called on incompatible object, got the object (new Number(1))");
"PointerType.prototype.decrement called on incompatible object, got the number 1");
assertTypeErrorMessage(() => { ctypes.int32_t.ptr(0).decrement.call(ctypes.int32_t(0)); },
"PointerType.prototype.decrement called on non-PointerType CData, got ctypes.int32_t(0)");
}

Просмотреть файл

@ -2,7 +2,7 @@ load(libdir + 'asserts.js');
function test() {
assertTypeErrorMessage(() => { ctypes.StructType("a").define.call(1); },
"StructType.prototype.define called on incompatible object, got the object (new Number(1))");
"StructType.prototype.define called on incompatible object, got the number 1");
assertTypeErrorMessage(() => { ctypes.StructType("a").define.call(ctypes.int32_t); },
"StructType.prototype.define called on non-StructType, got ctypes.int32_t");
@ -22,7 +22,7 @@ function test() {
"StructType property setter called on non-StructType CData, got ctypes.int32_t(0)");
assertTypeErrorMessage(() => { ctypes.StructType("a", [])().addressOfField.call(1); },
"StructType.prototype.addressOfField called on incompatible object, got the object (new Number(1))");
"StructType.prototype.addressOfField called on incompatible object, got the number 1");
assertTypeErrorMessage(() => { ctypes.StructType("a", [])().addressOfField.call(ctypes.int32_t(0)); },
"StructType.prototype.addressOfField called on non-StructType CData, got ctypes.int32_t(0)");
}

Просмотреть файл

@ -7982,10 +7982,13 @@ static bool
dom_genericGetter(JSContext* cx, unsigned argc, JS::Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject obj(cx, JS_THIS_OBJECT(cx, vp));
if (!obj)
return false;
if (!args.thisv().isObject()) {
args.rval().setUndefined();
return true;
}
RootedObject obj(cx, &args.thisv().toObject());
if (JS_GetClass(obj) != &dom_class) {
args.rval().set(UndefinedValue());
return true;
@ -8003,12 +8006,14 @@ static bool
dom_genericSetter(JSContext* cx, unsigned argc, JS::Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject obj(cx, JS_THIS_OBJECT(cx, vp));
if (!obj)
return false;
MOZ_ASSERT(args.length() == 1);
if (!args.thisv().isObject()) {
args.rval().setUndefined();
return true;
}
RootedObject obj(cx, &args.thisv().toObject());
if (JS_GetClass(obj) != &dom_class) {
args.rval().set(UndefinedValue());
return true;
@ -8029,10 +8034,13 @@ static bool
dom_genericMethod(JSContext* cx, unsigned argc, JS::Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject obj(cx, JS_THIS_OBJECT(cx, vp));
if (!obj)
return false;
if (!args.thisv().isObject()) {
args.rval().setUndefined();
return true;
}
RootedObject obj(cx, &args.thisv().toObject());
if (JS_GetClass(obj) != &dom_class) {
args.rval().set(UndefinedValue());
return true;