3 <script src=
"../resources/js-test.js"></script>
7 description('Tests the cancelVibration during pattern vibration is working.');
9 function vibrate(pattern
) {
10 navigator
.vibrate(pattern
);
11 shouldBeTrue('internals.isVibrating(document)');
14 function cancelVibration(time
) {
15 setTimeout(function() {
17 shouldBeFalse('internals.isVibrating(document)');
22 function doNextTest() {
28 function doTest(num
) {
30 case 1: // Test that cancelling works during a vibration in a pattern.
31 vibrate([20, 20, 20]);
32 // Progress time by 10ms so we are in the middle of the first vibration of the pattern.
35 case 2: // Test that cancelling works during a pause in a pattern.
36 vibrate([10, 10, 10]);
37 // Progress time by 15ms so we are in the middle of the first pause of the pattern.
40 case 3: // Test that the system stops thinking that it is vibrating when the pattern ends.
41 vibrate([10, 10, 10]);
42 // Progress time by 35ms so the pattern ends naturally without interruptions.
45 case 4: // Test that a trailing pause is stripped so isVibrating becomes false after the last vibration in the pattern.
46 vibrate([10, 10, 10, 10]); // Even number of array entries, the trailing pause will be stripped.
47 // Progress time by 35ms so the pattern ends naturally without interruptions.
54 if (window
.testRunner
) {
55 window
.jsTestIsAsync
= true;
56 shouldBeFalse('internals.isVibrating(document)'); // Before vibration test.
59 debug('This test can not be run without the TestRunner');