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

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

Issue 2778693004: Remove navigator.vibrate without user gesture. (Closed)
Patch Set: reformat again! Created 3 years, 8 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script> 2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script> 3 <script src="../resources/testharnessreport.js"></script>
4 <script src="../resources/mojo-helpers.js"></script> 4 <script src="../resources/mojo-helpers.js"></script>
5 <script src="../resources/user-gesture-utils.js"></script>
5 <script src="resources/vibration-helpers.js"></script> 6 <script src="resources/vibration-helpers.js"></script>
7 <script src="vibration-utils.js"></script>
8 <h4 id="test"></h4>
6 <script> 9 <script>
7 10
8 'use strict'; 11 'use strict';
9 12
10 if (!window.testRunner) 13 if (!window.testRunner)
11 debug('This test cannot be run without the TestRunner'); 14 debug('This test cannot be run without the TestRunner');
12 15
16 // Simulates a user click for vibrate to be allowed.
17 // See: https://www.chromestatus.com/feature/5644273861001216.
18 simulateUserClick("test");
19
13 vibration_test(vibration => { 20 vibration_test(vibration => {
14 assert_true(vibration instanceof Object); 21 assert_true(vibration instanceof Object);
15 assert_true(vibration.mockVibrationManager instanceof Object); 22 assert_true(vibration.mockVibrationManager instanceof Object);
16 }, 'VibrationManager Mojo bindings and mock interfaces are available to tests.') ; 23 }, 'VibrationManager Mojo bindings and mock interfaces are available to tests.') ;
17 24
18 vibration_test(vibration => { 25 vibration_test(vibration => {
19 let promise = new Promise(resolve => { 26 let promise = new Promise(resolve => {
20 let listener = msg => { 27 let listener = msg => {
21 window.removeEventListener('message', listener); 28 window.removeEventListener('message', listener);
22 resolve(msg.data); 29 resolve(msg.data);
(...skipping 21 matching lines...) Expand all
44 navigator.vibrate(0); 51 navigator.vibrate(0);
45 }); 52 });
46 53
47 return promise.then(msgData => { 54 return promise.then(msgData => {
48 assert_equals(msgData, 'Cancel'); 55 assert_equals(msgData, 'Cancel');
49 assert_true(vibration.mockVibrationManager.isCancelled()); 56 assert_true(vibration.mockVibrationManager.isCancelled());
50 }); 57 });
51 }, 'navigator.vibrate(0) triggers cancel correctly.'); 58 }, 'navigator.vibrate(0) triggers cancel correctly.');
52 59
53 </script> 60 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698