4 <script src=
"../resources/testharness.js"></script>
5 <script src=
"../resources/testharnessreport.js"></script>
8 var test
= async_test("Test that screen.orientation.lock() throws when the input isn't valid.");
10 function onOrientationChangeEvent(ev
) {
11 assert_unreached('Unexpected orientation change');
14 window
.screen
.orientation
.addEventListener('change', test
.step_func(onOrientationChangeEvent
));
16 test
.step(function() {
17 assert_equals(screen
.orientation
.type
, 'portrait-primary');
18 assert_throws({ name
: 'TypeError' }, function() {
19 screen
.lock('invalid-orientation');
22 assert_equals(screen
.orientation
.type
, 'portrait-primary');
23 assert_throws({ name
: 'TypeError' }, function() {
27 assert_equals(screen
.orientation
.type
, 'portrait-primary');
28 assert_throws({ name
: 'TypeError' }, function() {
29 screen
.lock(undefined);
32 assert_equals(screen
.orientation
.type
, 'portrait-primary');
33 assert_throws({ name
: 'TypeError' }, function() {
34 screen
.lock(undefined);
37 assert_equals(screen
.orientation
.type
, 'portrait-primary');
38 assert_throws({ name
: 'TypeError' }, function() {
42 assert_equals(screen
.orientation
.type
, 'portrait-primary');
43 assert_throws({ name
: 'TypeError' }, function() {
47 assert_equals(screen
.orientation
.type
, 'portrait-primary');
48 assert_throws({ name
: 'TypeError' }, function() {
49 screen
.lock(['portrait-primary']);
52 assert_equals(screen
.orientation
.type
, 'portrait-primary');
53 assert_throws({ name
: 'TypeError' }, function() {
54 screen
.lock(['portrait-primary', 'landscape-primary']);
57 assert_equals(screen
.orientation
.type
, 'portrait-primary');
58 assert_throws({ name
: 'TypeError' }, function() {
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();