Bug 868805 - [LenientThis] attribute's setter should return undefined. r=bz

This commit is contained in:
Cameron McCormack 2013-05-06 12:36:38 +10:00
parent 24b5c10e04
commit 2a03ace5c1
3 changed files with 29 additions and 0 deletions

View File

@ -5075,6 +5075,7 @@ class CGGenericSetter(CGAbstractBindingMethod):
unwrapFailureCode = (
"MOZ_ASSERT(!JS_IsExceptionPending(cx));\n"
"ReportLenientThisUnwrappingFailure(cx, obj);\n"
"JS_SET_RVAL(cx, vp, JS::UndefinedValue());\n"
"return true;")
else:
name = "genericSetter"

View File

@ -74,6 +74,7 @@ MOCHITEST_FILES := \
test_bug852846.html \
test_bug862092.html \
test_bug560072.html \
test_lenientThis.html \
$(NULL)
MOCHITEST_CHROME_FILES = \

View File

@ -0,0 +1,27 @@
<!doctype html>
<meta charset=utf-8>
<title>[LenientThis]</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
function noop1() { }
function noop2() { }
test(function() {
var desc = Object.getOwnPropertyDescriptor(Document.prototype, "onreadystatechange");
document.onreadystatechange = noop1;
assert_equals(document.onreadystatechange, noop1, "document.onreadystatechange == noop1");
assert_equals(desc.get.call({ }), undefined, "document.onreadystatechange getter.call({}) == undefined");
}, "invoking Document.onreadystatechange's getter with an invalid this object returns undefined");
test(function() {
var desc = Object.getOwnPropertyDescriptor(Document.prototype, "onreadystatechange");
document.onreadystatechange = noop1;
assert_equals(document.onreadystatechange, noop1, "document.onreadystatechange == noop1");
assert_equals(desc.set.call({ }, noop2), undefined, "document.onreadystatechange setter.call({}) == undefined");
assert_equals(document.onreadystatechange, noop1, "document.onreadystatechange == noop1 (still)");
}, "invoking Document.onreadystatechange's setter with an invalid this object does nothing and returns undefined");
</script>