Andrew Top | 61a8495 | 2019-04-30 15:07:33 -0700 | [diff] [blame] | 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 | test(function() { |
| 9 | assert_true('type' in screen.orientation); |
| 10 | assert_true('angle' in screen.orientation); |
| 11 | }, "Test screen.orientation properties"); |
| 12 | |
| 13 | test(function() { |
| 14 | assert_equals(screen.orientation.type, "portrait-primary"); |
| 15 | assert_equals(screen.orientation.angle, 0); |
| 16 | }, "Test screen.orientation default values."); |
| 17 | |
| 18 | test(function() { |
| 19 | var type = screen.orientation.type; |
| 20 | var angle = screen.orientation.angle; |
| 21 | |
| 22 | screen.orientation.type = 'foo'; |
| 23 | screen.orientation.angle = 42; |
| 24 | |
| 25 | assert_equals(screen.orientation.type, type); |
| 26 | assert_equals(screen.orientation.angle, angle); |
| 27 | }, "Test that screen.orientation properties are not writable"); |
| 28 | |
| 29 | test(function() { |
| 30 | assert_equals(screen.orientation, screen.orientation); |
| 31 | }, "Test that screen.orientation is always the same object"); |
| 32 | |
| 33 | async_test(function(t) { |
| 34 | var orientation = screen.orientation; |
| 35 | var orientationType = screen.orientation.type; |
| 36 | var orientationAngle = screen.orientation.angle; |
| 37 | |
| 38 | screen.orientation.unlock(); |
| 39 | screen.orientation.lock('landscape-primary').then(function () { |
| 40 | t.step(function () { |
| 41 | assert_equals(screen.orientation, orientation); |
| 42 | assert_equals(screen.orientation.type, orientation.type); |
| 43 | assert_equals(screen.orientation.angle, orientation.angle); |
| 44 | assert_not_equals(screen.orientation.type, orientationType); |
| 45 | assert_not_equals(screen.orientation.angle, orientationAngle); |
| 46 | }); |
| 47 | t.done(); |
| 48 | screen.orientation.unlock(); |
| 49 | }, function () { |
| 50 | t.step(function () { |
| 51 | assert_unreached('Unexpected orientation change'); |
| 52 | }); |
| 53 | t.done(); |
| 54 | screen.orientation.unlock(); |
| 55 | }); |
| 56 | |
| 57 | }, "Test that screen.orientation values change if the orientation changes"); |
| 58 | |
| 59 | </script> |
| 60 | </body> |
| 61 | </html> |