Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / screen_orientation / lockOrientation-bad-argument.html
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 var test = async_test("Test that screen.orientation.lock() throws when the input isn't valid.");
9
10 function onOrientationChangeEvent(ev) {
11     assert_unreached('Unexpected orientation change');
12 }
13
14 window.screen.orientation.addEventListener('change', test.step_func(onOrientationChangeEvent));
15
16 test.step(function() {
17     assert_equals(screen.orientation.type, 'portrait-primary');
18     assert_throws({ name: 'TypeError' }, function() {
19         screen.lock('invalid-orientation');
20     });
21
22     assert_equals(screen.orientation.type, 'portrait-primary');
23     assert_throws({ name: 'TypeError' }, function() {
24         screen.lock(null);
25     });
26
27     assert_equals(screen.orientation.type, 'portrait-primary');
28     assert_throws({ name: 'TypeError' }, function() {
29         screen.lock(undefined);
30     });
31
32     assert_equals(screen.orientation.type, 'portrait-primary');
33     assert_throws({ name: 'TypeError' }, function() {
34         screen.lock(undefined);
35     });
36
37     assert_equals(screen.orientation.type, 'portrait-primary');
38     assert_throws({ name: 'TypeError' }, function() {
39         screen.lock(123);
40     });
41
42     assert_equals(screen.orientation.type, 'portrait-primary');
43     assert_throws({ name: 'TypeError' }, function() {
44         screen.lock(window);
45     });
46
47     assert_equals(screen.orientation.type, 'portrait-primary');
48     assert_throws({ name: 'TypeError' }, function() {
49         screen.lock(['portrait-primary']);
50     });
51
52     assert_equals(screen.orientation.type, 'portrait-primary');
53     assert_throws({ name: 'TypeError' }, function() {
54         screen.lock(['portrait-primary', 'landscape-primary']);
55     });
56
57     assert_equals(screen.orientation.type, 'portrait-primary');
58     assert_throws({ name: 'TypeError' }, function() {
59         screen.lock();
60     });
61 });
62
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 }));
69
70 </script>
71 </body>
72 </html>
73