mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
auto merge of #3812 : mukilan/servo/lenient-this, r=Ms2ger
Closes issue #3760
This commit is contained in:
commit
7ba02bb11d
4 changed files with 39 additions and 8 deletions
|
@ -2526,9 +2526,9 @@ class CGGenericGetter(CGAbstractBindingMethod):
|
|||
if lenientThis:
|
||||
name = "genericLenientGetter"
|
||||
unwrapFailureCode = (
|
||||
"MOZ_ASSERT(!JS_IsExceptionPending(cx));\n"
|
||||
"JS_SET_RVAL(cx, vp, JS::UndefinedValue());\n"
|
||||
"return true;")
|
||||
"assert!(JS_IsExceptionPending(cx) == 0);\n"
|
||||
"*vp = UndefinedValue();\n"
|
||||
"return 1;")
|
||||
else:
|
||||
name = "genericGetter"
|
||||
unwrapFailureCode = None
|
||||
|
@ -2600,8 +2600,8 @@ class CGGenericSetter(CGAbstractBindingMethod):
|
|||
if lenientThis:
|
||||
name = "genericLenientSetter"
|
||||
unwrapFailureCode = (
|
||||
"MOZ_ASSERT(!JS_IsExceptionPending(cx));\n"
|
||||
"return true;")
|
||||
"assert!(JS_IsExceptionPending(cx) == 0);\n"
|
||||
"return 1;")
|
||||
else:
|
||||
name = "genericSetter"
|
||||
unwrapFailureCode = None
|
||||
|
@ -4136,11 +4136,11 @@ class CGDescriptor(CGThing):
|
|||
if hasGetter:
|
||||
cgThings.append(CGGenericGetter(descriptor))
|
||||
if hasLenientGetter:
|
||||
pass
|
||||
cgThings.append(CGGenericGetter(descriptor, lenientThis=True))
|
||||
if hasSetter:
|
||||
cgThings.append(CGGenericSetter(descriptor))
|
||||
if hasLenientSetter:
|
||||
pass
|
||||
cgThings.append(CGGenericSetter(descriptor, lenientThis=True))
|
||||
|
||||
if descriptor.concrete:
|
||||
cgThings.append(CGClassFinalizeHook(descriptor))
|
||||
|
|
|
@ -79,6 +79,6 @@ partial interface Document {
|
|||
NodeList getElementsByName(DOMString elementName);
|
||||
|
||||
// special event handler IDL attributes that only apply to Document objects
|
||||
/*[LenientThis]*/ attribute EventHandler onreadystatechange;
|
||||
[LenientThis] attribute EventHandler onreadystatechange;
|
||||
};
|
||||
Document implements GlobalEventHandlers;
|
||||
|
|
28
tests/content/test_lenient_this.html
Normal file
28
tests/content/test_lenient_this.html
Normal file
|
@ -0,0 +1,28 @@
|
|||
<html>
|
||||
<head>
|
||||
<script src="harness.js"></script>
|
||||
<script>
|
||||
var handler = function () { };
|
||||
document.onreadystatechange = handler;
|
||||
var obj = {};
|
||||
|
||||
// test1: basic test
|
||||
{
|
||||
var val = Object.getOwnPropertyDescriptor(Document.prototype, "onreadystatechange").get.call(document);
|
||||
is(val, handler, "test1-0, basic test");
|
||||
}
|
||||
|
||||
// test2: Should not throw for attribute marked "[LenientThis]"
|
||||
{
|
||||
should_not_throw(function () {
|
||||
var val = null;
|
||||
val = Object.getOwnPropertyDescriptor(Document.prototype, "onreadystatechange").get.call(obj);
|
||||
is(val, undefined, "test2-0, calling getter returns undefined");
|
||||
is(Document.prototype.onreadystatechange, undefined, "test2-1, property access returns undefined");
|
||||
});
|
||||
}
|
||||
|
||||
finish();
|
||||
</script>
|
||||
</head>
|
||||
</html>
|
|
@ -234,6 +234,9 @@
|
|||
[Document interface: attribute onratechange]
|
||||
expected: FAIL
|
||||
|
||||
[Document interface: attribute onreadystatechange]
|
||||
expected: FAIL
|
||||
|
||||
[Document interface: attribute onreset]
|
||||
expected: FAIL
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue