OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <body> | 3 <body> |
4 <script src="../resources/js-test.js"></script> | 4 <script src="../resources/js-test.js"></script> |
5 <script> | 5 <script> |
6 description("Validates that lockOrientation() returns false on bad orientation v
alue in array argument."); | 6 description("Validates that lockOrientation() returns false on bad orientation v
alue in array argument."); |
7 window.jsTestIsAsync = true; | 7 window.jsTestIsAsync = true; |
8 | 8 |
9 function onOrientationChangeEvent(ev) { | 9 function onOrientationChangeEvent(ev) { |
10 testFailed("Unexpected 'orientationchange' event"); | 10 testFailed("Unexpected 'orientationchange' event"); |
11 } | 11 } |
12 | 12 |
13 function completeTest() { | 13 function completeTest() { |
14 shouldBeEqualToString("screen.orientation", "portrait-primary"); | 14 shouldBeEqualToString("screen.orientation", "portrait-primary"); |
15 screen.unlockOrientation(); | 15 screen.unlockOrientation(); |
16 finishJSTest(); | 16 finishJSTest(); |
17 } | 17 } |
18 | 18 |
19 screen.addEventListener("orientationchange", onOrientationChangeEvent); | 19 window.addEventListener("orientationchange", onOrientationChangeEvent); |
20 | 20 |
21 function typeErrorEnum(argStr) { | 21 function typeErrorEnum(argStr) { |
22 return "TypeError: Failed to execute 'lockOrientation' on 'Screen': parameter
1 ('" + argStr + "') is not a valid enum value."; | 22 return "TypeError: Failed to execute 'lockOrientation' on 'Screen': parameter
1 ('" + argStr + "') is not a valid enum value."; |
23 } | 23 } |
24 | 24 |
25 shouldBeEqualToString("screen.orientation", "portrait-primary"); | 25 shouldBeEqualToString("screen.orientation", "portrait-primary"); |
26 // Bad argument to lockOrientation(), we should not get locked. | 26 // Bad argument to lockOrientation(), we should not get locked. |
27 shouldThrow("screen.lockOrientation(['portrait-primary', 'invalid-orientation'])
", "typeErrorEnum('portrait-primary,invalid-orientation')"); | 27 shouldThrow("screen.lockOrientation(['portrait-primary', 'invalid-orientation'])
", "typeErrorEnum('portrait-primary,invalid-orientation')"); |
28 shouldThrow("screen.lockOrientation(['portrait-primary', null])", "typeErrorEnum
('portrait-primary,')"); | 28 shouldThrow("screen.lockOrientation(['portrait-primary', null])", "typeErrorEnum
('portrait-primary,')"); |
29 shouldThrow("screen.lockOrientation(['portrait-primary', undefined])", "typeErro
rEnum('portrait-primary,')"); | 29 shouldThrow("screen.lockOrientation(['portrait-primary', undefined])", "typeErro
rEnum('portrait-primary,')"); |
30 shouldThrow("screen.lockOrientation(['portrait-primary', 123])", "typeErrorEnum(
'portrait-primary,123')"); | 30 shouldThrow("screen.lockOrientation(['portrait-primary', 123])", "typeErrorEnum(
'portrait-primary,123')"); |
31 shouldThrow("screen.lockOrientation(['portrait-primary', window])", "typeErrorEn
um('portrait-primary,[object Window]')"); | 31 shouldThrow("screen.lockOrientation(['portrait-primary', window])", "typeErrorEn
um('portrait-primary,[object Window]')"); |
32 | 32 |
33 // Finish asynchronously to give events a chance to fire. | 33 // Finish asynchronously to give events a chance to fire. |
34 setTimeout(completeTest, 0); | 34 setTimeout(completeTest, 0); |
35 </script> | 35 </script> |
36 </body> | 36 </body> |
37 </html> | 37 </html> |
38 | 38 |
OLD | NEW |