25f825ce8ef73e857428c3170b19c04e6af82782
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / dom / Window / window-scroll-arguments.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4     <script src="../../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <div style="height: 1000px; width: 1000px; border: 1px solid black;">This box should force the window to have a scrollable area to test.</div>
8 <script language="JavaScript" type="text/javascript">
9     var resetX;
10     var resetY;
11
12     var x = 25;
13     var y = 50;
14
15     function reset()
16     {
17         window.scrollTo(0,0);
18         resetX = window.scrollX;
19         resetY = window.scrollY;
20     }
21
22     if (window.testRunner)
23         testRunner.dumpAsText();
24
25     reset();
26
27     description("This test makes sure that calling the window scrolling\
28     methods with less than 2 arguments or with an invalid third argument\
29     throws an exception.");
30
31     // scrollTo /////////////////////////
32     debug('');
33     debug('window.scrollTo Tests');
34     debug('');
35
36     debug("Testing - scrollTo with 0 arguments");
37     shouldThrow('window.scrollTo()');
38     reset();
39
40     debug("Testing - scrollTo with 1 argument");
41     shouldThrow('window.scrollTo(x)');;
42     reset();
43
44     debug("Testing - scrollTo with a valid ScrollOptions argument");
45     shouldNotThrow('window.scrollTo(x, y, { })');
46     shouldNotThrow('window.scrollTo(x, y, { behavior: "auto" })');
47     shouldNotThrow('window.scrollTo(x, y, { behavior: "instant" })');
48     shouldNotThrow('window.scrollTo(x, y, { behavior: "smooth" })');
49
50     debug("Testing - scrollTo with an invalid ScrollOptions argument");
51     shouldThrow('window.scrollTo(x, y, { behavior: "" })');
52     shouldThrow('window.scrollTo(x, y, { behavior: "abcd" })');
53     shouldThrow('window.scrollTo(x, y, 200, "text")');
54
55     // scroll /////////////////////////
56     debug('');
57     debug('window.scroll Tests');
58     debug('');
59
60     debug("Testing - scroll with 0 arguments");
61     shouldThrow('window.scroll()');;
62     reset();
63
64     debug("Testing - scroll with 1 argument");
65     shouldThrow('window.scroll(x)');
66     reset();
67
68     debug("Testing - scroll with a valid ScrollOptions argument");
69     shouldNotThrow('window.scroll(x, y, { })');
70     shouldNotThrow('window.scroll(x, y, { behavior: "auto" })');
71     shouldNotThrow('window.scroll(x, y, { behavior: "instant" })');
72     shouldNotThrow('window.scroll(x, y, { behavior: "smooth" })');
73
74     debug("Testing - scroll with an invalid ScrollOptions argument");
75     shouldThrow('window.scroll(x, y, { behavior: "" })');
76     shouldThrow('window.scroll(x, y, { behavior: "abcd" })');
77     shouldThrow('window.scroll(x, y, 200, "text")');
78
79     // scrollBy /////////////////////////
80     debug('');
81     debug('window.scrollBy Tests');
82     debug('');
83
84     debug("Testing - scrollBy with 0 arguments");
85     shouldThrow('window.scrollBy()');;
86     reset();
87
88     debug("Testing - scrollBy with 1 argument");
89     shouldThrow('window.scrollBy(x)');
90     reset();
91
92     debug("Testing - scrollBy with a valid ScrollOptions argument");
93     shouldNotThrow('window.scrollBy(x, y, { })');
94     shouldNotThrow('window.scrollBy(x, y, { behavior: "auto" })');
95     shouldNotThrow('window.scrollBy(x, y, { behavior: "instant" })');
96     shouldNotThrow('window.scrollBy(x, y, { behavior: "smooth" })');
97
98     debug("Testing - scrollBy with an invalid ScrollOptions argument");
99     shouldThrow('window.scrollBy(x, y, { behavior: "" })');
100     shouldThrow('window.scrollBy(x, y, { behavior: "abcd" })');
101     shouldThrow('window.scrollBy(x, y, 200, "text")');
102 </script>
103 </body>
104 </html>