From e0236625712f96c539f04a24b7e6b2efef2f1929 Mon Sep 17 00:00:00 2001 From: Mukilan Thiyagarajan Date: Sat, 25 Oct 2014 12:05:36 +0530 Subject: [PATCH 1/3] Implement [LenientThis] support and enable it in Document.webidl Closes issue #3760 --- .../script/dom/bindings/codegen/CodegenRust.py | 14 +++++++------- components/script/dom/webidls/Document.webidl | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index a6e4fcd6ebc..883b7448d61 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -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)) diff --git a/components/script/dom/webidls/Document.webidl b/components/script/dom/webidls/Document.webidl index 9ca633a8ba4..111a37b9531 100644 --- a/components/script/dom/webidls/Document.webidl +++ b/components/script/dom/webidls/Document.webidl @@ -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; From 9653965380a33764460ee8d66cec4ef70b50a587 Mon Sep 17 00:00:00 2001 From: Mukilan Thiyagarajan Date: Sat, 25 Oct 2014 17:55:08 +0530 Subject: [PATCH 2/3] Add content test for [LenientThis] attribute Document.onreadystatechange --- tests/content/test_lenient_this.html | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/content/test_lenient_this.html diff --git a/tests/content/test_lenient_this.html b/tests/content/test_lenient_this.html new file mode 100644 index 00000000000..b31bc0b0751 --- /dev/null +++ b/tests/content/test_lenient_this.html @@ -0,0 +1,28 @@ + + + + + + From 75d41c2146ed9a453ce1f69d5e37b72e0e233493 Mon Sep 17 00:00:00 2001 From: Mukilan Thiyagarajan Date: Sat, 25 Oct 2014 23:01:59 +0530 Subject: [PATCH 3/3] Disable Document interface attribute onreadystatechange test idlharness.js does not understand [LenientThis] yet --- tests/wpt/metadata/html/dom/interfaces.html.ini | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/wpt/metadata/html/dom/interfaces.html.ini b/tests/wpt/metadata/html/dom/interfaces.html.ini index 5c69240bf80..8dd98ed292a 100644 --- a/tests/wpt/metadata/html/dom/interfaces.html.ini +++ b/tests/wpt/metadata/html/dom/interfaces.html.ini @@ -234,6 +234,9 @@ [Document interface: attribute onratechange] expected: FAIL + [Document interface: attribute onreadystatechange] + expected: FAIL + [Document interface: attribute onreset] expected: FAIL