Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / screen_orientation / lockOrientation-bad-argument.html
blob88b2e047d860c4d4dd7753756b780d79be818c66
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <script src="../resources/testharness.js"></script>
5 <script src="../resources/testharnessreport.js"></script>
6 <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');
20 });
22 assert_equals(screen.orientation.type, 'portrait-primary');
23 assert_throws({ name: 'TypeError' }, function() {
24 screen.lock(null);
25 });
27 assert_equals(screen.orientation.type, 'portrait-primary');
28 assert_throws({ name: 'TypeError' }, function() {
29 screen.lock(undefined);
30 });
32 assert_equals(screen.orientation.type, 'portrait-primary');
33 assert_throws({ name: 'TypeError' }, function() {
34 screen.lock(undefined);
35 });
37 assert_equals(screen.orientation.type, 'portrait-primary');
38 assert_throws({ name: 'TypeError' }, function() {
39 screen.lock(123);
40 });
42 assert_equals(screen.orientation.type, 'portrait-primary');
43 assert_throws({ name: 'TypeError' }, function() {
44 screen.lock(window);
45 });
47 assert_equals(screen.orientation.type, 'portrait-primary');
48 assert_throws({ name: 'TypeError' }, function() {
49 screen.lock(['portrait-primary']);
50 });
52 assert_equals(screen.orientation.type, 'portrait-primary');
53 assert_throws({ name: 'TypeError' }, function() {
54 screen.lock(['portrait-primary', 'landscape-primary']);
55 });
57 assert_equals(screen.orientation.type, 'portrait-primary');
58 assert_throws({ name: 'TypeError' }, function() {
59 screen.lock();
60 });
61 });
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 }));
70 </script>
71 </body>
72 </html>