| Index: LayoutTests/vibration/cancel-vibration-during-pattern-vibrating.html
|
| diff --git a/LayoutTests/vibration/cancel-vibration-during-pattern-vibrating.html b/LayoutTests/vibration/cancel-vibration-during-pattern-vibrating.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a197f824fbacdfc48e0aeb150ac385f68e7406ea
|
| --- /dev/null
|
| +++ b/LayoutTests/vibration/cancel-vibration-during-pattern-vibrating.html
|
| @@ -0,0 +1,64 @@
|
| +<html>
|
| +<head>
|
| +<script src="../fast/js/resources/js-test-pre.js"></script>
|
| +</head>
|
| +<body>
|
| +<script>
|
| +description('Tests the cancelVibration during pattern vibration is working.');
|
| +
|
| +function vibrate(pattern) {
|
| + navigator.vibrate(pattern);
|
| + shouldBeTrue('internals.isVibrating(document)');
|
| +}
|
| +
|
| +function cancelVibration(time) {
|
| + setTimeout(function() {
|
| + navigator.vibrate(0);
|
| + shouldBeFalse('internals.isVibrating(document)');
|
| + doNextTest();
|
| + }, time);
|
| +}
|
| +
|
| +function doNextTest() {
|
| + if (count == 4)
|
| + finishJSTest();
|
| + doTest(++count);
|
| +}
|
| +
|
| +function doTest(num) {
|
| + switch(num) {
|
| + case 1: // Test that cancelling works during a vibration in a pattern.
|
| + vibrate([20, 20, 20]);
|
| + // Progress time by 10ms so we are in the middle of the first vibration of the pattern.
|
| + cancelVibration(10);
|
| + break;
|
| + case 2: // Test that cancelling works during a pause in a pattern.
|
| + vibrate([10, 10, 10]);
|
| + // Progress time by 15ms so we are in the middle of the first pause of the pattern.
|
| + cancelVibration(15);
|
| + break;
|
| + case 3: // Test that the system stops thinking that it is vibrating when the pattern ends.
|
| + vibrate([10, 10, 10]);
|
| + // Progress time by 35ms so the pattern ends naturally without interruptions.
|
| + cancelVibration(35);
|
| + break;
|
| + case 4: // Test that a trailing pause is stripped so isVibrating becomes false after the last vibration in the pattern.
|
| + vibrate([10, 10, 10, 10]); // Even number of array entries, the trailing pause will be stripped.
|
| + // Progress time by 35ms so the pattern ends naturally without interruptions.
|
| + cancelVibration(35);
|
| + break;
|
| + }
|
| +}
|
| +
|
| +var count = 1;
|
| +if (window.testRunner) {
|
| + window.jsTestIsAsync = true;
|
| + shouldBeFalse('internals.isVibrating(document)'); // Before vibration test.
|
| + doTest(count);
|
| +} else {
|
| + debug('This test can not be run without the TestRunner');
|
| +}
|
| +</script>
|
| +<script src="../fast/js/resources/js-test-post.js"></script>
|
| +</body>
|
| +</html>
|
|
|