Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <script src="../resources/testharness.js"></script> | |
| 3 <script src="../resources/testharnessreport.js"></script> | |
| 4 <script src="../resources/mojo-helpers.js"></script> | |
| 5 <script src="resources/vibration-helpers.js"></script> | |
| 6 <script> | |
| 7 | |
| 8 'use strict'; | |
| 9 | |
| 10 if (!window.testRunner) | |
| 11 debug('This test cannot be run without the TestRunner'); | |
| 12 | |
| 13 vibration_test(vibration => { | |
| 14 assert_true(vibration instanceof Object); | |
| 15 assert_true(vibration.mockVibrationManager instanceof Object); | |
| 16 }, 'VibrationManager Mojo bindings and mock interfaces are available to tests.') ; | |
| 17 | |
| 18 vibration_test(vibration => { | |
| 19 let promise = new Promise(resolve => { | |
| 20 let listener = msg => { | |
| 21 window.removeEventListener('message', listener); | |
| 22 resolve(msg.data); | |
| 23 }; | |
| 24 window.addEventListener('message', listener); | |
| 25 | |
| 26 navigator.vibrate(1234); | |
| 27 }); | |
| 28 | |
| 29 return promise.then(msgData => { | |
| 30 assert_equals(msgData, 'Vibrate'); | |
| 31 assert_equals(vibration.mockVibrationManager.getDuration(), 1234); | |
| 32 assert_false(vibration.mockVibrationManager.isCancelled()); | |
| 33 }); | |
| 34 }, 'navigator.vibrate(1234) can trigger MockVibrationManager vibrate(1234) corre ctly.'); | |
|
timvolodine
2017/03/15 18:20:18
nit: seems better: "can trigger" -> "triggers"
al
leonhsl(Using Gerrit)
2017/03/16 06:32:42
Done.
| |
| 35 | |
| 36 vibration_test(vibration => { | |
| 37 let promise = new Promise(resolve => { | |
| 38 let listener = msg => { | |
| 39 window.removeEventListener('message', listener); | |
| 40 resolve(msg.data); | |
| 41 }; | |
| 42 window.addEventListener('message', listener); | |
| 43 | |
| 44 navigator.vibrate(0); | |
| 45 }); | |
| 46 | |
| 47 return promise.then(msgData => { | |
| 48 assert_equals(msgData, 'Cancel'); | |
| 49 assert_true(vibration.mockVibrationManager.isCancelled()); | |
| 50 }); | |
| 51 }, 'navigator.vibrate(0) can trigger MockVibrationManager cancel() correctly.'); | |
|
timvolodine
2017/03/15 18:20:18
also here
leonhsl(Using Gerrit)
2017/03/16 06:32:42
Done.
| |
| 52 | |
| 53 </script> | |
| OLD | NEW |