Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Unified Diff: third_party/WebKit/LayoutTests/fast/events/eventlisteneroptions/passive_dispatch.html

Issue 1563623002: Support registering and dispatching passive event listeners. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/events/eventlisteneroptions/passive_dispatch.html
diff --git a/third_party/WebKit/LayoutTests/fast/events/eventlisteneroptions/passive_dispatch.html b/third_party/WebKit/LayoutTests/fast/events/eventlisteneroptions/passive_dispatch.html
new file mode 100644
index 0000000000000000000000000000000000000000..7fdeb2cd2c20d66b8ce0638c73b7548b19e8b337
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/events/eventlisteneroptions/passive_dispatch.html
@@ -0,0 +1,45 @@
+<!DOCTYPE HTML>
+<body/>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+
+<script>
+
+function testPassiveValue(registerValue, expectedValue, test) {
+ var handler = function handler(e) {
+ e.preventDefault();
+ }
+ document.addEventListener('test', handler, registerValue);
+ assert_equals(expectedValue, document.body.dispatchEvent(new Event('test', {'bubbles': true, 'cancelable': true})));
+ document.removeEventListener('test', handler, registerValue);
+ assert_equals(true, document.body.dispatchEvent(new Event('test', {'bubbles': true, 'cancelable': true})));
+ test.done();
+}
+
+function testTwoHandlers() {
+ if (!internals.runtimeFlags.eventListenerOptionsEnabled)
+ return;
+
+ var passive_called = undefined;
+ var blocking_called = undefined;
+ var passive_handler = function handler(e) {
+ passive_called = true;
+ }
+ var blocking_handler = function handler(e) {
+ blocking_called = true;
+ }
+ document.addEventListener('test', passive_handler, {"passive" : true});
+ document.addEventListener('test', blocking_handler, {"passive" : false});
+ document.body.dispatchEvent(new Event('test', {'bubbles': true, 'cancelable': true}));
Rick Byers 2016/01/08 19:32:56 perhaps you should also verify that the blocking h
dtapuska 2016/01/11 18:56:28 Done.
+ assert_equals(passive_called, true);
+ assert_equals(blocking_called, true);
+ document.removeEventListener('test', passive_handler, {"passive" : true});
+ document.removeEventListener('test', blocking_handler, {"passive" : false});
+}
+
+test(function(t) { testPassiveValue({}, false, t); }, "Prevent default with empty object");
Rick Byers 2016/01/08 19:32:56 Unless you're getting coverage elsewhere, you shou
dtapuska 2016/01/11 18:56:28 Done.
+test(function(t) { testPassiveValue({passive: false}, false, t); }, "Prevent default with passive false");
+test(function(t) { testPassiveValue({passive: true}, internals.runtimeFlags.eventListenerOptionsEnabled ? true : false, t); }, "Prevent default with passive true ");
Rick Byers 2016/01/08 19:32:56 nit: Unless you're planning on explicitly running
dtapuska 2016/01/11 18:56:28 The feature is manually run with it disabled via t
+test(testTwoHandlers, "Passive and Blocking Registered Handlers");
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698