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

Unified Diff: third_party/WebKit/LayoutTests/vibration/vibration.html

Issue 2731953003: [DeviceService] Replace vibration_browsertest.cc with layout tests. (Closed)
Patch Set: 'git cl format --js' for js/html Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
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>

Powered by Google App Engine
This is Rietveld 408576698