OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <html> | |
3 <body> | |
4 <script src="../../../resources/testharness.js"></script> | |
5 <script src="../../../resources/testharnessreport.js"></script> | |
6 <script> | |
7 | |
8 var test = async_test("Test that screen.orientation.lock() throws when the input
isn't valid."); | |
9 | |
10 function onOrientationChangeEvent(ev) { | |
11 assert_unreached('Unexpected orientation change'); | |
12 } | |
13 | |
14 window.screen.orientation.addEventListener('change', test.step_func(onOrientatio
nChangeEvent)); | |
15 | |
16 test.step(function() { | |
17 assert_equals(screen.orientation.type, 'portrait-primary'); | |
18 assert_throws(new TypeError(), function() { | |
19 screen.orientation.lock('invalid-orientation'); | |
20 }); | |
21 | |
22 assert_equals(screen.orientation.type, 'portrait-primary'); | |
23 assert_throws(new TypeError(), function() { | |
24 screen.orientation.lock(null); | |
25 }); | |
26 | |
27 assert_equals(screen.orientation.type, 'portrait-primary'); | |
28 assert_throws(new TypeError(), function() { | |
29 screen.orientation.lock(undefined); | |
30 }); | |
31 | |
32 assert_equals(screen.orientation.type, 'portrait-primary'); | |
33 assert_throws(new TypeError(), function() { | |
34 screen.orientation.lock(undefined); | |
35 }); | |
36 | |
37 assert_equals(screen.orientation.type, 'portrait-primary'); | |
38 assert_throws(new TypeError(), function() { | |
39 screen.orientation.lock(123); | |
40 }); | |
41 | |
42 assert_equals(screen.orientation.type, 'portrait-primary'); | |
43 assert_throws(new TypeError(), function() { | |
44 screen.orientation.lock(window); | |
45 }); | |
46 | |
47 assert_equals(screen.orientation.type, 'portrait-primary'); | |
48 assert_throws(new TypeError(), function() { | |
49 screen.orientation.lock(['portrait-primary']); | |
50 }); | |
51 | |
52 assert_equals(screen.orientation.type, 'portrait-primary'); | |
53 assert_throws(new TypeError(), function() { | |
54 screen.orientation.lock(['portrait-primary', 'landscape-primary']); | |
55 }); | |
56 | |
57 assert_equals(screen.orientation.type, 'portrait-primary'); | |
58 assert_throws(new TypeError(), function() { | |
59 screen.orientation.lock(); | |
60 }); | |
61 }); | |
62 | |
63 // Finish asynchronously to give events a chance to fire. | |
64 setTimeout(test.step_func(function() { | |
65 assert_equals(screen.orientation.type, 'portrait-primary'); | |
66 screen.orientation.unlock(); | |
67 test.done(); | |
68 })); | |
69 | |
70 </script> | |
71 </body> | |
72 </html> | |
73 | |
OLD | NEW |