Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE HTML> | |
| 2 <body/> | |
| 3 <script src="../../../resources/testharness.js"></script> | |
| 4 <script src="../../../resources/testharnessreport.js"></script> | |
| 5 | |
| 6 <script> | |
| 7 | |
| 8 function testPassiveValue(registerValue, expectedValue, test) { | |
| 9 var handler = function handler(e) { | |
| 10 e.preventDefault(); | |
| 11 } | |
| 12 document.addEventListener('test', handler, registerValue); | |
| 13 assert_equals(expectedValue, document.body.dispatchEvent(new Event('test', {'b ubbles': true, 'cancelable': true}))); | |
| 14 document.removeEventListener('test', handler, registerValue); | |
| 15 assert_equals(true, document.body.dispatchEvent(new Event('test', {'bubbles': true, 'cancelable': true}))); | |
| 16 test.done(); | |
| 17 } | |
| 18 | |
| 19 function testTwoHandlers() { | |
| 20 if (!internals.runtimeFlags.eventListenerOptionsEnabled) | |
| 21 return; | |
| 22 | |
| 23 var passive_called = undefined; | |
| 24 var blocking_called = undefined; | |
| 25 var passive_handler = function handler(e) { | |
| 26 passive_called = true; | |
| 27 } | |
| 28 var blocking_handler = function handler(e) { | |
| 29 blocking_called = true; | |
| 30 } | |
| 31 document.addEventListener('test', passive_handler, {"passive" : true}); | |
| 32 document.addEventListener('test', blocking_handler, {"passive" : false}); | |
| 33 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.
| |
| 34 assert_equals(passive_called, true); | |
| 35 assert_equals(blocking_called, true); | |
| 36 document.removeEventListener('test', passive_handler, {"passive" : true}); | |
| 37 document.removeEventListener('test', blocking_handler, {"passive" : false}); | |
| 38 } | |
| 39 | |
| 40 test(function(t) { testPassiveValue({}, false, t); }, "Prevent default with empt y 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.
| |
| 41 test(function(t) { testPassiveValue({passive: false}, false, t); }, "Prevent def ault with passive false"); | |
| 42 test(function(t) { testPassiveValue({passive: true}, internals.runtimeFlags.even tListenerOptionsEnabled ? true : false, t); }, "Prevent default with passive tru e "); | |
|
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
| |
| 43 test(testTwoHandlers, "Passive and Blocking Registered Handlers"); | |
| 44 | |
| 45 </script> | |
| OLD | NEW |