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

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

Issue 2778693004: Remove navigator.vibrate without user gesture. (Closed)
Patch Set: refactor SimulateUserClick 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 var element = document.getElementById("test");
19 simulateUserClick(element.offsetLeft + 2, element.offsetTop + 2);
20
13 vibration_test(vibration => { 21 vibration_test(vibration => {
14 assert_true(vibration instanceof Object); 22 assert_true(vibration instanceof Object);
15 assert_true(vibration.mockVibrationManager instanceof Object); 23 assert_true(vibration.mockVibrationManager instanceof Object);
16 }, 'VibrationManager Mojo bindings and mock interfaces are available to tests.') ; 24 }, 'VibrationManager Mojo bindings and mock interfaces are available to tests.') ;
17 25
18 vibration_test(vibration => { 26 vibration_test(vibration => {
19 let promise = new Promise(resolve => { 27 let promise = new Promise(resolve => {
20 let listener = msg => { 28 let listener = msg => {
21 window.removeEventListener('message', listener); 29 window.removeEventListener('message', listener);
22 resolve(msg.data); 30 resolve(msg.data);
(...skipping 21 matching lines...) Expand all
44 navigator.vibrate(0); 52 navigator.vibrate(0);
45 }); 53 });
46 54
47 return promise.then(msgData => { 55 return promise.then(msgData => {
48 assert_equals(msgData, 'Cancel'); 56 assert_equals(msgData, 'Cancel');
49 assert_true(vibration.mockVibrationManager.isCancelled()); 57 assert_true(vibration.mockVibrationManager.isCancelled());
50 }); 58 });
51 }, 'navigator.vibrate(0) triggers cancel correctly.'); 59 }, 'navigator.vibrate(0) triggers cancel correctly.');
52 60
53 </script> 61 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698