Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/vibration/vibration.html |
| diff --git a/third_party/WebKit/LayoutTests/vibration/vibration.html b/third_party/WebKit/LayoutTests/vibration/vibration.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e013faa6e024974b3494bcb859e787e96e485aff |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/vibration/vibration.html |
| @@ -0,0 +1,53 @@ |
| +<!DOCTYPE html> |
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<script src="../resources/mojo-helpers.js"></script> |
| +<script src="resources/vibration-helpers.js"></script> |
| +<script> |
| + |
| +'use strict'; |
| + |
| +if (!window.testRunner) |
| + debug('This test cannot be run without the TestRunner'); |
| + |
| +vibration_test(vibration => { |
| + assert_true(vibration instanceof Object); |
| + assert_true(vibration.mockVibrationManager instanceof Object); |
| +}, 'VibrationManager Mojo bindings and mock interfaces are available to tests.'); |
| + |
| +vibration_test(vibration => { |
| + let promise = new Promise(resolve => { |
| + let listener = msg => { |
| + window.removeEventListener('message', listener); |
| + resolve(msg.data); |
| + }; |
| + window.addEventListener('message', listener); |
| + |
| + navigator.vibrate(1234); |
| + }); |
| + |
| + return promise.then(msgData => { |
| + assert_equals(msgData, 'Vibrate'); |
| + assert_equals(vibration.mockVibrationManager.getDuration(), 1234); |
| + assert_false(vibration.mockVibrationManager.isCancelled()); |
| + }); |
| +}, 'navigator.vibrate(1234) can trigger MockVibrationManager vibrate(1234) correctly.'); |
|
timvolodine
2017/03/15 18:20:18
nit: seems better: "can trigger" -> "triggers"
al
leonhsl(Using Gerrit)
2017/03/16 06:32:42
Done.
|
| + |
| +vibration_test(vibration => { |
| + let promise = new Promise(resolve => { |
| + let listener = msg => { |
| + window.removeEventListener('message', listener); |
| + resolve(msg.data); |
| + }; |
| + window.addEventListener('message', listener); |
| + |
| + navigator.vibrate(0); |
| + }); |
| + |
| + return promise.then(msgData => { |
| + assert_equals(msgData, 'Cancel'); |
| + assert_true(vibration.mockVibrationManager.isCancelled()); |
| + }); |
| +}, '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.
|
| + |
| +</script> |