Title: [196588] trunk
- Revision
- 196588
- Author
- [email protected]
- Date
- 2016-02-15 12:09:54 -0800 (Mon, 15 Feb 2016)
Log Message
Regression(r196563): It is no longer possible to call window.addEventListener without an explicit 'this'
https://bugs.webkit.org/show_bug.cgi?id=154245
Reviewed by Ryosuke Niwa.
Source/WebCore:
This patch adds support for calling the EventListener API without an
explicit 'this' value. If no explicit 'this' value is passed, then we
fall back to using the global object. This matches Chrome and Firefox's
behavior. It also fixes the Dromaeo/cssquery-dojo.html test.
Test: fast/dom/Window/addEventListener-implicit-this.html
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateFunctionCastedThis):
LayoutTests:
Add a layout test to cover the use of the EventListener API without an
explicit 'this' value.
* fast/dom/Window/addEventListener-implicit-this-expected.txt: Added.
* fast/dom/Window/addEventListener-implicit-this.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (196587 => 196588)
--- trunk/LayoutTests/ChangeLog 2016-02-15 20:09:07 UTC (rev 196587)
+++ trunk/LayoutTests/ChangeLog 2016-02-15 20:09:54 UTC (rev 196588)
@@ -1,3 +1,16 @@
+2016-02-15 Chris Dumez <[email protected]>
+
+ Regression(r196563): It is no longer possible to call window.addEventListener without an explicit 'this'
+ https://bugs.webkit.org/show_bug.cgi?id=154245
+
+ Reviewed by Ryosuke Niwa.
+
+ Add a layout test to cover the use of the EventListener API without an
+ explicit 'this' value.
+
+ * fast/dom/Window/addEventListener-implicit-this-expected.txt: Added.
+ * fast/dom/Window/addEventListener-implicit-this.html: Added.
+
2016-02-15 Daniel Bates <[email protected]>
CSP: 'sandbox' should be ignored in report-only mode
Added: trunk/LayoutTests/fast/dom/Window/addEventListener-implicit-this-expected.txt (0 => 196588)
--- trunk/LayoutTests/fast/dom/Window/addEventListener-implicit-this-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/Window/addEventListener-implicit-this-expected.txt 2016-02-15 20:09:54 UTC (rev 196588)
@@ -0,0 +1,16 @@
+Checks that the Window's EventListener API can be called without an explicit 'this' value.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS addEventListenerFunction.call(undefined, 'myevent', function() { wasWindowEventListenerCalled = true; }); did not throw exception.
+PASS dispatchEventFunction.call(undefined, new Event('myevent')) is true
+PASS wasWindowEventListenerCalled is true
+PASS bodyDispatchEventFunction.call(undefined, new Event('myevent')) is true
+PASS wasWindowEventListenerCalled is true
+PASS xhrDispatchEventFunction.call(undefined, new Event('myevent')) is true
+PASS wasWindowEventListenerCalled is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/dom/Window/addEventListener-implicit-this.html (0 => 196588)
--- trunk/LayoutTests/fast/dom/Window/addEventListener-implicit-this.html (rev 0)
+++ trunk/LayoutTests/fast/dom/Window/addEventListener-implicit-this.html 2016-02-15 20:09:54 UTC (rev 196588)
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Checks that the Window's EventListener API can be called without an explicit 'this' value.");
+
+var wasWindowEventListenerCalled = false;
+
+var addEventListenerFunction = window.addEventListener;
+shouldNotThrow("addEventListenerFunction.call(undefined, 'myevent', function() { wasWindowEventListenerCalled = true; });");
+
+var dispatchEventFunction = window.dispatchEvent;
+shouldBeTrue("dispatchEventFunction.call(undefined, new Event('myevent'))");
+
+shouldBeTrue("wasWindowEventListenerCalled");
+
+// As of early 2016, this matches Firefox and Chrome's behavior: We fall back to using the global window, even if the function
+// came from a non-Window object.
+wasWindowEventListenerCalled = false;
+
+bodyDispatchEventFunction = document.body.dispatchEvent;
+shouldBeTrue("bodyDispatchEventFunction.call(undefined, new Event('myevent'))");
+
+shouldBeTrue("wasWindowEventListenerCalled");
+
+wasWindowEventListenerCalled = false;
+
+var xhr = new XMLHttpRequest();
+xhrDispatchEventFunction = xhr.dispatchEvent;
+shouldBeTrue("xhrDispatchEventFunction.call(undefined, new Event('myevent'))");
+
+shouldBeTrue("wasWindowEventListenerCalled");
+
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (196587 => 196588)
--- trunk/Source/WebCore/ChangeLog 2016-02-15 20:09:07 UTC (rev 196587)
+++ trunk/Source/WebCore/ChangeLog 2016-02-15 20:09:54 UTC (rev 196588)
@@ -1,3 +1,20 @@
+2016-02-15 Chris Dumez <[email protected]>
+
+ Regression(r196563): It is no longer possible to call window.addEventListener without an explicit 'this'
+ https://bugs.webkit.org/show_bug.cgi?id=154245
+
+ Reviewed by Ryosuke Niwa.
+
+ This patch adds support for calling the EventListener API without an
+ explicit 'this' value. If no explicit 'this' value is passed, then we
+ fall back to using the global object. This matches Chrome and Firefox's
+ behavior. It also fixes the Dromaeo/cssquery-dojo.html test.
+
+ Test: fast/dom/Window/addEventListener-implicit-this.html
+
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GenerateFunctionCastedThis):
+
2016-02-14 Gavin Barraclough <[email protected]>
Organize, deduplicate & comment JSDOMWindowCustom getOwnPropertySlot
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (196587 => 196588)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2016-02-15 20:09:07 UTC (rev 196587)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2016-02-15 20:09:54 UTC (rev 196588)
@@ -3235,7 +3235,14 @@
push(@implContent, " return throwVMTypeError(state);\n");
} else {
push(@implContent, " JSValue thisValue = state->thisValue();\n");
- push(@implContent, " auto castedThis = " . GetCastingHelperForThisObject($interface) . "(thisValue);\n");
+ my $castingHelper = GetCastingHelperForThisObject($interface);
+ if ($interfaceName eq "EventTarget") {
+ # We allow calling the EventTarget API without an explicit 'this' value and fall back to using the global object instead.
+ # As of early 2016, this matches Firefox and Chrome's behavior.
+ push(@implContent, " auto castedThis = thisValue.isUndefinedOrNull() ? $castingHelper(thisValue.toThis(state, NotStrictMode)) : $castingHelper(thisValue);\n");
+ } else {
+ push(@implContent, " auto castedThis = $castingHelper(thisValue);\n");
+ }
my $domFunctionName = $function->signature->name;
push(@implContent, " if (UNLIKELY(!castedThis))\n");
push(@implContent, " return throwThisTypeError(*state, \"$interfaceName\", \"$domFunctionName\");\n");
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes