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..1dfcde4e5c3ecec5805f1eb368d1f31e11daad9e |
--- /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) triggers vibration correctly.'); |
+ |
+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) triggers cancel correctly.'); |
+ |
+</script> |