mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-31 22:25:30 +00:00
Bug 916949 - Change __noSuchMethod__ so that it only gets invoked on undefined bindings. r=jorendorff
This commit is contained in:
parent
d331acd967
commit
90dc33e75b
@ -6015,7 +6015,7 @@ DoGetPropFallback(JSContext *cx, BaselineFrame *frame, ICGetProp_Fallback *stub,
|
||||
|
||||
#if JS_HAS_NO_SUCH_METHOD
|
||||
// Handle objects with __noSuchMethod__.
|
||||
if (op == JSOP_CALLPROP && JS_UNLIKELY(res.isPrimitive()) && val.isObject()) {
|
||||
if (op == JSOP_CALLPROP && JS_UNLIKELY(res.isUndefined()) && val.isObject()) {
|
||||
if (!OnUnknownMethod(cx, obj, IdToValue(id), res))
|
||||
return false;
|
||||
}
|
||||
|
@ -1781,7 +1781,7 @@ GetPropertyIC::update(JSContext *cx, size_t cacheIndex,
|
||||
|
||||
#if JS_HAS_NO_SUCH_METHOD
|
||||
// Handle objects with __noSuchMethod__.
|
||||
if (JSOp(*pc) == JSOP_CALLPROP && JS_UNLIKELY(vp.isPrimitive())) {
|
||||
if (JSOp(*pc) == JSOP_CALLPROP && JS_UNLIKELY(vp.isUndefined())) {
|
||||
if (!OnUnknownMethod(cx, obj, IdToValue(id), vp))
|
||||
return false;
|
||||
}
|
||||
|
@ -43,18 +43,30 @@ function test()
|
||||
reportCompare(expect, actual, status);
|
||||
|
||||
status = summary + ' ' + inSection(2) + ' ';
|
||||
actual = o.bbb();
|
||||
expect = 'bbb() null';
|
||||
try {
|
||||
actual = o.bbb();
|
||||
} catch(e) {
|
||||
actual = e + '';
|
||||
}
|
||||
expect = 'TypeError: o.bbb is not a function';
|
||||
reportCompare(expect, actual, status);
|
||||
|
||||
status = summary + ' ' + inSection(3) + ' ';
|
||||
actual = o.ccc();
|
||||
expect = 'ccc() 77';
|
||||
try {
|
||||
actual = o.ccc();
|
||||
} catch(e) {
|
||||
actual = e + '';
|
||||
}
|
||||
expect = 'TypeError: o.ccc is not a function';
|
||||
reportCompare(expect, actual, status);
|
||||
|
||||
status = summary + ' ' + inSection(4) + ' ';
|
||||
actual = o.ddd();
|
||||
expect = 'ddd() foo';
|
||||
try {
|
||||
actual = o.ddd();
|
||||
} catch(e) {
|
||||
actual = e + '';
|
||||
}
|
||||
expect = 'TypeError: o.ddd is not a function';
|
||||
reportCompare(expect, actual, status);
|
||||
|
||||
status = summary + ' ' + inSection(5) + ' ';
|
||||
|
@ -391,7 +391,7 @@ GetObjectElementOperation(JSContext *cx, JSOp op, JSObject *objArg, bool wasObje
|
||||
} while (0);
|
||||
|
||||
#if JS_HAS_NO_SUCH_METHOD
|
||||
if (op == JSOP_CALLELEM && JS_UNLIKELY(res.isPrimitive()) && wasObject) {
|
||||
if (op == JSOP_CALLELEM && JS_UNLIKELY(res.isUndefined()) && wasObject) {
|
||||
RootedObject obj(cx, objArg);
|
||||
if (!OnUnknownMethod(cx, obj, rref, res))
|
||||
return false;
|
||||
|
@ -266,7 +266,7 @@ GetPropertyOperation(JSContext *cx, StackFrame *fp, HandleScript script, jsbytec
|
||||
|
||||
#if JS_HAS_NO_SUCH_METHOD
|
||||
if (op == JSOP_CALLPROP &&
|
||||
JS_UNLIKELY(vp.isPrimitive()) &&
|
||||
JS_UNLIKELY(vp.isUndefined()) &&
|
||||
wasObject)
|
||||
{
|
||||
if (!OnUnknownMethod(cx, obj, IdToValue(id), vp))
|
||||
@ -3453,7 +3453,7 @@ js::CallProperty(JSContext *cx, HandleValue v, HandlePropertyName name, MutableH
|
||||
return false;
|
||||
|
||||
#if JS_HAS_NO_SUCH_METHOD
|
||||
if (JS_UNLIKELY(vp.isPrimitive()) && v.isObject())
|
||||
if (JS_UNLIKELY(vp.isUndefined()) && v.isObject())
|
||||
{
|
||||
RootedObject obj(cx, &v.toObject());
|
||||
if (!OnUnknownMethod(cx, obj, StringValue(name), vp))
|
||||
|
Loading…
Reference in New Issue
Block a user