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

Side by Side 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: Adjust comments in layout tests 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/events/eventlisteneroptions/passive_query.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE HTML>
2 <body/>
3 <script src="../../../resources/testharness.js"></script>
4 <script src="../../../resources/testharnessreport.js"></script>
5
6 <!-- This test is run with normal layout tests with passiveEventListeners
7 enabled and in virtual/stable with passiveEventListeners disabled -->
8 <script>
9
10 function testTwoArgumentRegister() {
11 var handler = function handler(e) {
12 e.preventDefault();
13 }
14 document.addEventListener('test', handler);
15 assert_equals(false, document.body.dispatchEvent(new Event('test', {'bubbles': true, 'cancelable': true})));
16 document.removeEventListener('test', handler);
17 assert_equals(true, document.body.dispatchEvent(new Event('test', {'bubbles': true, 'cancelable': true})));
18 }
19
20 function testPassiveValue(registerValue, expectedValue, test) {
21 var handler = function handler(e) {
22 e.preventDefault();
23 }
24 document.addEventListener('test', handler, registerValue);
25 var event = new Event('test', {'bubbles': true, 'cancelable': true});
26 assert_equals(expectedValue, document.body.dispatchEvent(event));
27 assert_equals(!expectedValue, event.defaultPrevented);
28 document.removeEventListener('test', handler, registerValue);
29 assert_equals(true, document.body.dispatchEvent(new Event('test', {'bubbles': true, 'cancelable': true})));
30 test.done();
31 }
32
33 function testTwoHandlers() {
34 if (!internals.runtimeFlags.passiveEventListenersEnabled)
35 return;
36
37 var passive_called = undefined;
38 var blocking_called = undefined;
39 var passive_handler = function handler(e) {
40 passive_called = true;
41 }
42 var blocking_handler = function handler(e) {
43 blocking_called = true;
44 e.preventDefault();
45 }
46 document.addEventListener('test', passive_handler, {"passive" : true});
47 document.addEventListener('test', blocking_handler, {"passive" : false});
48 var event = new Event('test', {'bubbles': true, 'cancelable': true});
49 document.body.dispatchEvent(event);
50 assert_true(passive_called);
51 assert_true(blocking_called);
52 assert_true(event.defaultPrevented);
53 document.removeEventListener('test', passive_handler, {"passive" : true});
54 document.removeEventListener('test', blocking_handler, {"passive" : false});
55 }
56
57 test(testTwoArgumentRegister, "Two argument register");
58 test(function(t) { testPassiveValue(false, false, t); }, "Prevent default captur e false");
59 test(function(t) { testPassiveValue(true, false, t); }, "Prevent default capture true");
60 test(function(t) { testPassiveValue({}, false, t); }, "Prevent default with empt y object");
61 test(function(t) { testPassiveValue({passive: false}, false, t); }, "Prevent def ault with passive false");
62 test(function(t) { testPassiveValue({passive: true}, internals.runtimeFlags.pass iveEventListenersEnabled ? true : false, t); }, "Prevent default with passive tr ue ");
63 test(testTwoHandlers, "Passive and Blocking Registered Handlers");
64
65 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/events/eventlisteneroptions/passive_query.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698