Chromium Code Reviews| OLD | NEW |
|---|---|
| (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> | |
| OLD | NEW |