OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <head> |
| 3 <title>Test vibrate with user gesture in same-origin iframe</title> |
| 4 <script src="../../resources/testharness.js"></script> |
| 5 <script src="../../resources/testharnessreport.js"></script> |
| 6 <script src="../../resources/user-gesture-utils.js"></script> |
2 <script> | 7 <script> |
3 'use strict'; | 8 'use strict'; |
4 | 9 |
5 navigator.vibrate(1234); | 10 function startTest() { |
| 11 if (window.eventSender) { |
| 12 var iframes = window.parent.document.getElementsByTagName('iframe'); |
| 13 // The last iframe. |
| 14 var iframe = iframes[iframes.length-1]; |
| 15 // Simulates a user click for vibrate to be allowed. |
| 16 var element = document.getElementById("test"); |
| 17 simulateUserClick(element.offsetLeft + iframe.offsetLeft + 2, element.offset
Top + iframe.offsetTop + 2); |
| 18 } |
| 19 } |
6 | 20 |
| 21 function testVibrate() { |
| 22 test(function () { |
| 23 assert_true(navigator.vibrate(200)); |
| 24 }, "An iframe may call navigator.vibrate with user gesture."); |
| 25 } |
7 </script> | 26 </script> |
| 27 </head> |
| 28 <body onload="startTest();"> |
| 29 <button id="test" onclick="testVibrate();">Click to vibrate</button> |
| 30 </body> |
| 31 </html> |
| 32 |
OLD | NEW |