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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/security/vibration/resources/vibrate-in-iframe-with-user-gesture-allowed.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 <html> 1 <html>
2 <head> 2 <head>
3 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharness.js"></script>
4 <script src="/resources/testharnessreport.js"></script> 4 <script src="/resources/testharnessreport.js"></script>
5 <script> 5 <script>
6 var test = async_test( 6 var test = async_test(
mustaq 2017/04/13 19:05:04 The async_test label seems redundant with the asse
binlu 2017/04/13 19:55:26 Done.
7 "Testing vibrate 3 times in a x-origin iframe: " + 7 "Testing vibrate 3 times in an iframe: " +
8 " 1. blocked before user gesture;" + 8 " 1. blocked before user gesture;" +
9 " 2. succeed during the click event;" + 9 " 2. succeed during the click event;" +
10 " 3. succeed after user click."); 10 " 3. succeed after user click.");
11 function loaded() 11 function loaded()
12 { 12 {
13 document.getElementsByTagName('h4')[0].innerHTML = document.domain; 13 document.getElementsByTagName('h4')[0].innerHTML = document.domain;
14 } 14 }
15 15
16 function startTest(event) 16 function startTest(event)
17 { 17 {
18 // A manual click should navigate. 18 // A manual click should enable vibrate.
19 if (window.eventSender) { 19 if (window.eventSender) {
20 var button = document.getElementById("b");
21 eventSender.mouseMoveTo(button.offsetLeft + event.data.x + 2, bu tton.offsetTop + event.data.y + 2);
22 test.step(function() { 20 test.step(function() {
23 assert_false( 21 assert_false(
24 navigator.vibrate(200), 22 navigator.vibrate(200),
25 "1. Blocked vibrate before user gesture."); 23 "1. Blocked vibrate before user gesture.");
26 }); 24 });
27 25 var element = document.getElementById("b");
28 eventSender.mouseDown(); 26 simulateUserClick(element.offsetLeft + event.data.x + 2, element .offsetTop + event.data.y + 2);
29 eventSender.mouseUp();
30 } 27 }
31 } 28 }
32 29
33 function performTestAfterClick() 30 function performTestAfterClick()
34 { 31 {
35 test.step(function () { 32 test.step(function () {
36 assert_true( 33 assert_true(
37 navigator.vibrate(200), 34 navigator.vibrate(200),
38 "3. Vibrate after user gesture succeeded."); 35 "3. Vibrate after user gesture succeeded.");
39 }); 36 });
(...skipping 11 matching lines...) Expand all
51 } 48 }
52 49
53 window.addEventListener("message", startTest, false); 50 window.addEventListener("message", startTest, false);
54 </script> 51 </script>
55 </head> 52 </head>
56 <body onload="loaded();"> 53 <body onload="loaded();">
57 <h4>DOMAIN</h4> 54 <h4>DOMAIN</h4>
58 <button id="b" onclick="performTestWithClick();">Perform Test</button> 55 <button id="b" onclick="performTestWithClick();">Perform Test</button>
59 </body> 56 </body>
60 </html> 57 </html>
58
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698