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

Side by Side Diff: third_party/WebKit/LayoutTests/vibration/resources/vibrate-from-iframe.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>
3 <script src="../../resources/testharnessreport.js"></script>
4 <script src="../../resources/user-gesture-utils.js"></script>
2 <script> 5 <script>
3 'use strict'; 6 'use strict';
4 7
5 navigator.vibrate(1234); 8 /*function startTest(event) {
mustaq 2017/04/13 14:28:34 Used code.
binlu 2017/04/13 15:11:11 Done.
9 // Simulates a user click for vibrate to be allowed.
10 // See: https://www.chromestatus.com/feature/5644273861001216.
11 //simulateUserClick("test", event);
12 */
13 function startTest() {
14 if (window.eventSender) {
15 // Get iframe's Left Position
16 var iframes = window.parent.document.getElementsByTagName('iframe');
17 // The last iframe.
18 var iframe = iframes[iframes.length-1];
19 var element = document.getElementById("test");
20 eventSender.mouseMoveTo(element.offsetLeft + iframe.offsetLeft + 2, element. offsetTop + iframe.offsetTop + 2);
21 eventSender.mouseDown();
22 eventSender.mouseUp();
23 }
24 }
6 25
26 function testVibrate() {
27 test(function () {
28 assert_true(navigator.vibrate(200));
29 }, "An iframe may call navigator.vibrate with user gesture.");
30 }
31
32 // window.addEventListener("message", startTest, false);
7 </script> 33 </script>
34 <body onload="startTest();">
35 <button id="test" onclick="testVibrate();">Click to vibrate</button>
36 </body>
37 </html>
38
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698