Title: [201826] trunk/LayoutTests/imported/w3c
Revision
201826
Author
[email protected]
Date
2016-06-08 12:50:20 -0700 (Wed, 08 Jun 2016)

Log Message

Import new AddEventListenerOptions test from W3C web-platform-tests
https://bugs.webkit.org/show_bug.cgi?id=158535

Reviewed by Ryosuke Niwa.

Import new AddEventListenerOptions test from W3C web-platform-tests.

* web-platform-tests/dom/events/AddEventListenerOptions-passive-expected.txt: Added.
* web-platform-tests/dom/events/AddEventListenerOptions-passive.html: Added.
* web-platform-tests/dom/events/EventListenerOptions-capture.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (201825 => 201826)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2016-06-08 19:40:34 UTC (rev 201825)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2016-06-08 19:50:20 UTC (rev 201826)
@@ -1,3 +1,16 @@
+2016-06-08  Chris Dumez  <[email protected]>
+
+        Import new AddEventListenerOptions test from W3C web-platform-tests
+        https://bugs.webkit.org/show_bug.cgi?id=158535
+
+        Reviewed by Ryosuke Niwa.
+
+        Import new AddEventListenerOptions test from W3C web-platform-tests.
+
+        * web-platform-tests/dom/events/AddEventListenerOptions-passive-expected.txt: Added.
+        * web-platform-tests/dom/events/AddEventListenerOptions-passive.html: Added.
+        * web-platform-tests/dom/events/EventListenerOptions-capture.html:
+
 2016-06-07  Chris Dumez  <[email protected]>
 
         Implement EventListenerOptions argument to addEventListener

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/AddEventListenerOptions-passive-expected.txt (0 => 201826)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/AddEventListenerOptions-passive-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/AddEventListenerOptions-passive-expected.txt	2016-06-08 19:50:20 UTC (rev 201826)
@@ -0,0 +1,6 @@
+
+PASS Supports passive option on addEventListener only 
+PASS preventDefault should be ignored if-and-only-if the passive option is true 
+PASS passive behavior of one listener should be unaffeted by the presence of other listeners 
+PASS Equivalence of option values 
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/AddEventListenerOptions-passive.html (0 => 201826)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/AddEventListenerOptions-passive.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/AddEventListenerOptions-passive.html	2016-06-08 19:50:20 UTC (rev 201826)
@@ -0,0 +1,113 @@
+<!DOCTYPE HTML>
+<meta charset="utf-8">
+<title>EventListenerOptions.passive</title>
+<link rel="author" title="Rick Byers" href=""
+<link rel="help" href=""
+<script src=""
+<script src=""
+<div id="log"></div>
+
+<script>
+
+test(function() {
+  var supportsPassive = false;
+  var query_options = {
+    get passive() {
+      supportsPassive = true;
+      return false;
+    },
+    get dummy() {
+      assert_unreached("dummy value getter invoked");
+      return false;
+    }
+  };
+
+  document.addEventListener('test_event', null, query_options);
+  assert_true(supportsPassive, "addEventListener doesn't support the passive option");
+
+  supportsPassive = false;
+  document.removeEventListener('test_event', null, query_options);
+  assert_false(supportsPassive, "removeEventListener supports the passive option when it should not");
+}, "Supports passive option on addEventListener only");
+
+function testPassiveValue(optionsValue, expectedDefaultPrevented) {
+  var defaultPrevented = undefined;
+  var handler = function handler(e) {
+    assert_false(e.defaultPrevented, "Event prematurely marked defaultPrevented");
+    e.preventDefault();
+    defaultPrevented = e.defaultPrevented;
+  }
+  document.addEventListener('test', handler, optionsValue);
+  var uncanceled = document.body.dispatchEvent(new Event('test', {bubbles: true, cancelable: true}));
+
+  assert_equals(defaultPrevented, expectedDefaultPrevented, "Incorrect defaultPrevented for options: " + JSON.stringify(optionsValue));
+  assert_equals(uncanceled, !expectedDefaultPrevented, "Incorrect return value from dispatchEvent");
+
+  document.removeEventListener('test', handler, optionsValue);
+}
+
+test(function() {
+  testPassiveValue(undefined, true);
+  testPassiveValue({}, true);
+  testPassiveValue({passive: false}, true);
+  testPassiveValue({passive: true}, false);
+  testPassiveValue({passive: 0}, true);
+  testPassiveValue({passive: 1}, false);
+}, "preventDefault should be ignored if-and-only-if the passive option is true");
+
+function testPassiveWithOtherHandlers(optionsValue, expectedDefaultPrevented) {
+  var handlerInvoked1 = false;
+  var dummyHandler1 = function() {
+    handlerInvoked1 = true;
+  };
+  var handlerInvoked2 = false;
+  var dummyHandler2 = function() {
+    handlerInvoked2 = true;
+  };
+
+  document.addEventListener('test', dummyHandler1, {passive:true});
+  document.addEventListener('test', dummyHandler2);
+
+  testPassiveValue(optionsValue, expectedDefaultPrevented);
+
+  assert_true(handlerInvoked1, "Extra passive handler not invoked");
+  assert_true(handlerInvoked2, "Extra non-passive handler not invoked");
+
+  document.removeEventListener('test', dummyHandler1);
+  document.removeEventListener('test', dummyHandler2);
+}
+
+test(function() {
+  testPassiveWithOtherHandlers({}, true);
+  testPassiveWithOtherHandlers({passive: false}, true);
+  testPassiveWithOtherHandlers({passive: true}, false);
+}, "passive behavior of one listener should be unaffeted by the presence of other listeners");
+
+function testOptionEquivalence(optionValue1, optionValue2, expectedEquality) {
+  var invocationCount = 0;
+  var handler = function handler(e) {
+    invocationCount++;
+  }
+  document.addEventListener('test', handler, optionValue1);
+  document.addEventListener('test', handler, optionValue2);
+  document.body.dispatchEvent(new Event('test', {bubbles: true}));
+  assert_equals(invocationCount, expectedEquality ? 1 : 2, "equivalence of options " +
+    JSON.stringify(optionValue1) + " and " + JSON.stringify(optionValue2));
+  document.removeEventListener('test', handler, optionValue1);
+  document.removeEventListener('test', handler, optionValue2);
+}
+
+test(function() {
+  // Sanity check options that should be treated as distinct handlers
+  testOptionEquivalence({capture:true}, {capture:false, passive:false}, false);
+  testOptionEquivalence({capture:true}, {passive:true}, false);
+
+  // Option values that should be treated as equivalent
+  testOptionEquivalence({}, {passive:false}, true);
+  testOptionEquivalence({passive:true}, {passive:false}, true);
+  testOptionEquivalence(undefined, {passive:true}, true);
+  testOptionEquivalence({capture: true, passive: false}, {capture: true, passive: true}, true);
+
+}, "Equivalence of option values");
+
+</script>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/EventListenerOptions-capture.html (201825 => 201826)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/EventListenerOptions-capture.html	2016-06-08 19:40:34 UTC (rev 201825)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/EventListenerOptions-capture.html	2016-06-08 19:50:20 UTC (rev 201826)
@@ -16,9 +16,9 @@
     handlerPhase = e.eventPhase;
   }
   document.addEventListener('test', handler, captureValue);
-  document.body.dispatchEvent(new Event('test', {'bubbles': true}));
+  document.body.dispatchEvent(new Event('test', {bubbles: true}));
   document.removeEventListener('test', handler, captureValue);
-  document.body.dispatchEvent(new Event('test', {'bubbles': true}));
+  document.body.dispatchEvent(new Event('test', {bubbles: true}));
   assert_equals(handlerPhase, expectedValue, "Incorrect event phase for value: " + JSON.stringify(captureValue));
 }
 
@@ -72,7 +72,7 @@
   }
   document.addEventListener('test', handler, addOptionValue);
   document.removeEventListener('test', handler, removeOptionValue);
-  document.body.dispatchEvent(new Event('test', {'bubbles': true}));
+  document.body.dispatchEvent(new Event('test', {bubbles: true}));
   assert_equals(!handlerInvoked, expectedEquality, "equivalence of options " +
     JSON.stringify(addOptionValue) + " and " + JSON.stringify(removeOptionValue));
   if (handlerInvoked)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to