OLD | NEW |
---|---|
(Empty) | |
1 <html> | |
2 <head> | |
3 <script src="../fast/js/resources/js-test-pre.js"></script> | |
4 <script src="vibration-utils.js"></script> | |
5 </head> | |
6 <body> | |
7 <script> | |
8 description('Tests for how durations are handled in the Vibration API.'); | |
9 | |
10 // Empty pattern is empty. Does not start a vibration. | |
11 shouldBeTrue("navigator.vibrate([])"); | |
12 shouldBeTrue("areArraysEqual(internals.getVibrationPattern(document), [])"); | |
13 shouldBeFalse("internals.isVibrating(document)"); | |
14 stopVibration(); | |
15 | |
16 // An empty pattern is stored internally for a single 0. | |
17 shouldBeTrue("navigator.vibrate(0)"); | |
18 shouldBeTrue("areArraysEqual(internals.getVibrationPattern(document), [])"); | |
19 shouldBeFalse("internals.isVibrating(document)"); | |
20 stopVibration(); | |
21 | |
22 // An empty pattern is stored internally for a single 0. | |
23 shouldBeTrue("navigator.vibrate([0])"); | |
24 shouldBeTrue("areArraysEqual(internals.getVibrationPattern(document), [])"); | |
25 shouldBeFalse("internals.isVibrating(document)"); | |
26 stopVibration(); | |
27 | |
28 // The maximum vibration duration. | |
29 shouldBeTrue("navigator.vibrate(10000)"); | |
30 shouldBeTrue("areArraysEqual(internals.getVibrationPattern(document), [10000])") ; | |
31 shouldBeTrue("internals.isVibrating(document)"); | |
32 stopVibration(); | |
33 | |
34 // Overly long vibrations are truncated to the maximum duration. | |
35 shouldBeTrue("navigator.vibrate(10001)"); | |
36 shouldBeTrue("areArraysEqual(internals.getVibrationPattern(document), [10000])") ; | |
37 shouldBeTrue("internals.isVibrating(document)"); | |
38 stopVibration(); | |
39 | |
40 // All values in the sequence are truncated. | |
41 shouldBeTrue("navigator.vibrate([10001, 10001, 10001])"); | |
42 shouldBeTrue("areArraysEqual(internals.getVibrationPattern(document), [10000, 10 000, 10000])"); | |
43 shouldBeTrue("internals.isVibrating(document)"); | |
44 stopVibration(); | |
45 | |
46 // A negative integer is clamped to 0. This becomes an empty pattern. | |
47 shouldBeTrue("navigator.vibrate(-1)"); | |
48 shouldBeTrue("areArraysEqual(internals.getVibrationPattern(document), [])"); | |
49 shouldBeFalse("internals.isVibrating(document)"); | |
50 stopVibration(); | |
51 | |
52 // WebIDL cannot clamp values in sequences yet, so -1 first overflows to a huge | |
53 // number, then it is truncated to the maximum duration. | |
54 // All values in the sequence overflow and truncate in the same way. | |
55 shouldBeTrue("navigator.vibrate([-1, -1, -1])"); | |
Peter Beverloo
2013/10/24 17:46:59
You could use stronger language here to indicate t
Michael van Ouwerkerk
2013/10/25 10:26:39
Done.
| |
56 shouldBeTrue("areArraysEqual(internals.getVibrationPattern(document), [10000, 10 000, 10000])"); | |
57 shouldBeTrue("internals.isVibrating(document)"); | |
58 stopVibration(); | |
59 | |
60 </script> | |
61 <script src="../fast/js/resources/js-test-post.js"></script> | |
62 </body> | |
63 </html> | |
OLD | NEW |