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

Side by Side 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 unified diff | Download patch
OLDNEW
(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) triggers vibration correctly.');
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) triggers cancel correctly.');
52
53 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698