summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/screen-orientation/lock-bad-argument.html
blob: df27ac21d298870720d108fb0978b580d6bf6984 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<html>
<body>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>

var test = async_test("Test that screen.orientation.lock() throws when the input isn't valid.");

function onOrientationChangeEvent(ev) {
    assert_unreached('Unexpected orientation change');
}

window.screen.orientation.addEventListener('change', test.step_func(onOrientationChangeEvent));

test.step(function() {
    assert_equals(screen.orientation.type, 'portrait-primary');
    assert_throws(new TypeError(), function() {
        screen.orientation.lock('invalid-orientation');
    });

    assert_equals(screen.orientation.type, 'portrait-primary');
    assert_throws(new TypeError(), function() {
        screen.orientation.lock(null);
    });

    assert_equals(screen.orientation.type, 'portrait-primary');
    assert_throws(new TypeError(), function() {
        screen.orientation.lock(undefined);
    });

    assert_equals(screen.orientation.type, 'portrait-primary');
    assert_throws(new TypeError(), function() {
        screen.orientation.lock(undefined);
    });

    assert_equals(screen.orientation.type, 'portrait-primary');
    assert_throws(new TypeError(), function() {
        screen.orientation.lock(123);
    });

    assert_equals(screen.orientation.type, 'portrait-primary');
    assert_throws(new TypeError(), function() {
        screen.orientation.lock(window);
    });

    assert_equals(screen.orientation.type, 'portrait-primary');
    assert_throws(new TypeError(), function() {
        screen.orientation.lock(['portrait-primary']);
    });

    assert_equals(screen.orientation.type, 'portrait-primary');
    assert_throws(new TypeError(), function() {
        screen.orientation.lock(['portrait-primary', 'landscape-primary']);
    });

    assert_equals(screen.orientation.type, 'portrait-primary');
    assert_throws(new TypeError(), function() {
        screen.orientation.lock();
    });
});

// Finish asynchronously to give events a chance to fire.
setTimeout(test.step_func(function() {
    assert_equals(screen.orientation.type, 'portrait-primary');
    screen.orientation.unlock();
    test.done();
}));

</script>
</body>
</html>