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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/security/vibration/vibrate-on-top-page-before-during-after-user-gesture.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
(Empty)
1 <html>
2 <head>
3 <script src="/resources/testharness.js"></script>
mustaq 2017/04/13 19:05:04 Can you please add a <title> to describe the test
binlu 2017/04/13 19:55:27 Done.
4 <script src="/resources/testharnessreport.js"></script>
5 <script src="/js-test-resources/user-gesture-utils.js"></script>
6 <script>
7 var test = async_test(
mustaq 2017/04/13 19:05:04 Ditto about async_test.
binlu 2017/04/13 19:55:27 Done.
8 "Testing vibrate 3 times on the top page: " +
9 " 1. blocked before user gesture;" +
10 " 2. succeed during the click event;" +
11 " 3. succeed after user click.");
12 function startTest()
13 {
14 test.step(function() {
15 assert_false(
16 navigator.vibrate(200),
17 "1. Blocked vibrate before user gesture.");
18 });
19
20 // A manual click should enable vibrate.
21 var element = document.getElementById("test");
22 simulateUserClick(element.offsetLeft + 2, element.offsetTop + 2);
23 performTestWithClick();
24 }
25
26 function performTestWithClick()
27 {
28 test.step(function () {
29 assert_true(
30 navigator.vibrate(200),
31 "2. Vibrate triggered by user gesture succeeded.");
32 });
33 window.requestAnimationFrame(performTestAfterClick);
34 }
35
36 function performTestAfterClick()
37 {
38 test.step(function () {
39 assert_true(
40 navigator.vibrate(200),
41 "3. Vibrate after user gesture succeeded.");
42 });
43 test.done();
44 }
45 </script>
46 </head>
47 <body onload="startTest();">
48 <button id="test">Click to vibrate</button>
49 </body>
50 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698