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

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: rebase 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 <title>Testing vibrate 3 times in an iframe</title>
3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharness.js"></script>
4 <script src="/resources/testharnessreport.js"></script> 5 <script src="/resources/testharnessreport.js"></script>
6 <script src="/js-test-resources/user-gesture-utils.js"></script>
5 <script> 7 <script>
6 var test = async_test(
7 "Testing vibrate 3 times in a x-origin iframe: " +
8 " 1. blocked before user gesture;" +
9 " 2. succeed during the click event;" +
10 " 3. succeed after user click.");
11 function loaded() 8 function loaded()
12 { 9 {
13 document.getElementsByTagName('h4')[0].innerHTML = document.domain; 10 document.getElementsByTagName('h4')[0].innerHTML = document.domain;
14 } 11 }
15 12
16 function startTest(event) 13 function startTest(event)
17 { 14 {
18 // A manual click should navigate. 15 // A manual click should enable vibrate.
19 if (window.eventSender) { 16 if (window.eventSender) {
20 var button = document.getElementById("b"); 17 test(function() {
21 eventSender.mouseMoveTo(button.offsetLeft + event.data.x + 2, bu tton.offsetTop + event.data.y + 2);
22 test.step(function() {
23 assert_false( 18 assert_false(
24 navigator.vibrate(200), 19 navigator.vibrate(200),
25 "1. Blocked vibrate before user gesture."); 20 "1. Blocked vibrate before user gesture.");
26 }); 21 });
27 22 var element = document.getElementById("b");
28 eventSender.mouseDown(); 23 simulateUserClick(element.offsetLeft + event.data.x + 2, element .offsetTop + event.data.y + 2);
29 eventSender.mouseUp();
30 } 24 }
31 } 25 }
32 26
33 function performTestAfterClick() 27 function performTestAfterClick()
34 { 28 {
35 test.step(function () { 29 test(function () {
36 assert_true( 30 assert_true(
37 navigator.vibrate(200), 31 navigator.vibrate(200),
38 "3. Vibrate after user gesture succeeded."); 32 "3. Vibrate after user gesture succeeded.");
39 }); 33 });
40 test.done();
41 } 34 }
42 35
43 function performTestWithClick() 36 function performTestWithClick()
44 { 37 {
45 test.step(function () { 38 test(function () {
46 assert_true( 39 assert_true(
47 navigator.vibrate(200), 40 navigator.vibrate(200),
48 "2. Vibrate triggered by user gesture succeeded."); 41 "2. Vibrate triggered by user gesture succeeded.");
49 }); 42 });
50 window.requestAnimationFrame(performTestAfterClick); 43 window.requestAnimationFrame(performTestAfterClick);
51 } 44 }
52 45
53 window.addEventListener("message", startTest, false); 46 window.addEventListener("message", startTest, false);
54 </script> 47 </script>
55 </head> 48 </head>
56 <body onload="loaded();"> 49 <body onload="loaded();">
57 <h4>DOMAIN</h4> 50 <h4>DOMAIN</h4>
58 <button id="b" onclick="performTestWithClick();">Perform Test</button> 51 <button id="b" onclick="performTestWithClick();">Perform Test</button>
59 </body> 52 </body>
60 </html> 53 </html>
54
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698