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/testharness.js"></script> |
5 <script src="../resources/testharnessreport.js"></script> | |
5 <script> | 6 <script> |
6 description("Basic screen.lockOrientation() / screen.unlockOrientation() testing "); | |
7 | 7 |
8 shouldBeEqualToString("screen.orientation", "portrait-primary"); | 8 var previousOrientation = screen.orientation; |
9 shouldNotThrow("screen.unlockOrientation()"); | |
10 | 9 |
11 [ 'any', 'portrait', 'landscape', 'portrait-primary', 'portrait-secondary', | 10 test(function() { |
12 'landscape-primary', 'landscape-secondary' ].forEach(function(orientation) { | 11 var caught = false; |
jochen (gone - plz use gerrit)
2014/05/22 08:34:35
4 space indent plz
mlamouri (slow - plz ping)
2014/05/22 08:58:56
Done.
| |
13 shouldBeTrue("screen.lockOrientation('" + orientation + "')"); | 12 try { |
14 }); | 13 screen.unlockOrientation(); |
14 } catch (e) { | |
15 caught = true; | |
16 } | |
15 | 17 |
16 // Update is made asynchronously so that shouldn't change. | 18 assert_false(caught); |
17 shouldBeEqualToString("screen.orientation", "portrait-primary"); | 19 }, "Test that unlockOrientation() doesn't throw when there is no lock"); |
18 shouldNotThrow("screen.unlockOrientation()"); | 20 |
21 test(function() { | |
22 [ 'any', 'portrait', 'landscape', 'portrait-primary', 'portrait-secondary', | |
23 'landscape-primary', 'landscape-secondary' ].forEach(function(orientation) { | |
24 var pending = true; | |
25 screen.lockOrientation(orientation).then(function() { | |
26 pending = false; | |
27 }, function() { | |
28 pending = false; | |
29 }); | |
30 | |
31 assert_true(pending); | |
32 }); | |
33 }, "Test that screen.lockOrientation returns a pending promise."); | |
34 | |
35 test(function() { | |
36 assert_equals(screen.orientation, previousOrientation); | |
37 }, "Test that screen.lockOrientation() is actually async"); | |
38 | |
39 test(function() { | |
40 var caught = false; | |
41 try { | |
42 screen.unlockOrientation(); | |
43 } catch (e) { | |
44 caught = true; | |
45 } | |
46 | |
47 assert_false(caught); | |
48 }, "Test that unlockOrientation doesn't throw when there is a lock"); | |
49 | |
19 </script> | 50 </script> |
20 </body> | 51 </body> |
21 </html> | 52 </html> |
OLD | NEW |