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

Side by Side Diff: third_party/WebKit/LayoutTests/vibration/vibration.html

Issue 2731953003: [DeviceService] Replace vibration_browsertest.cc with layout tests. (Closed)
Patch Set: Add case: reload subframe 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 // Cover test case in vibration_browsertest.cc: Vibrate
19 vibration_test(vibration => {
20 let promise = new Promise(resolve => {
21 let listener = msg => {
22 window.removeEventListener('message', listener);
23 resolve(msg.data);
24 };
25 window.addEventListener('message', listener);
26
27 navigator.vibrate(1234);
28 });
29
30 return promise.then(msgData => {
31 assert_equals(msgData, 'Vibrate');
32 assert_equals(vibration.mockVibrationManager.getDuration(), 1234);
33 assert_false(vibration.mockVibrationManager.isCancelled());
34 });
35 }, 'navigator.vibrate(1234) can trigger MockVibrationManager vibrate(1234) corre ctly.');
36
37 // Cover test case in vibration_browsertest.cc: Cancel
38 vibration_test(vibration => {
39 let promise = new Promise(resolve => {
40 let listener = msg => {
41 window.removeEventListener('message', listener);
42 resolve(msg.data);
43 };
44 window.addEventListener('message', listener);
45
46 navigator.vibrate(0);
47 });
48
49 return promise.then(msgData => {
50 assert_equals(msgData, 'Cancel');
51 assert_true(vibration.mockVibrationManager.isCancelled());
52 });
53 }, 'navigator.vibrate(0) can trigger MockVibrationManager cancel() correctly.');
54
55 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698