Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / Window / window-scroll-arguments.html
blobedf918e800577254907be53ee748b6cb3d1ed6e4
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;
12 var x = 25;
13 var y = 50;
15 function reset()
17 window.scrollTo(0,0);
18 resetX = window.scrollX;
19 resetY = window.scrollY;
22 if (window.testRunner)
23 testRunner.dumpAsText();
25 reset();
27 description("This test makes sure that calling the window scrolling\
28 methods with a single non-dictionary argument or with a dictionary \
29 whose 'behavior' field is invalid throws an exception.");
31 // scrollTo /////////////////////////
32 debug('');
33 debug('window.scrollTo Tests');
34 debug('');
36 debug("Testing - scrollTo with 0 arguments");
37 shouldNotThrow('window.scrollTo()');
38 reset();
40 debug("Testing - scrollTo with 1 non-dictionary argument");
41 shouldThrow('window.scrollTo(x)');;
42 reset();
44 debug("Testing - scrollTo with a valid ScrollToOptions argument");
45 shouldNotThrow('window.scrollTo({ })');
46 shouldNotThrow('window.scrollTo({ left: x })');
47 shouldNotThrow('window.scrollTo({ top: y })');
48 shouldNotThrow('window.scrollTo({ behavior: "auto" })');
49 shouldNotThrow('window.scrollTo({ behavior: "instant" })');
50 shouldNotThrow('window.scrollTo({ behavior: "smooth" })');
51 shouldNotThrow('window.scrollTo({ left: x, top: y })');
52 shouldNotThrow('window.scrollTo({ left: x, top: y, behavior: "auto" })');
53 shouldNotThrow('window.scrollTo({ left: x, top: y, behavior: "instant" })');
54 shouldNotThrow('window.scrollTo({ left: x, top: y, behavior: "smooth" })');
56 debug("Testing - scrollTo with an invalid ScrollToOptions argument");
57 shouldThrow('window.scrollTo({ behavior: "" })');
58 shouldThrow('window.scrollTo({ left: x, top: y, behavior: "abcd" })');
59 shouldThrow('window.scrollTo({ left: x, top: y, behavior: 200 })');
61 // scroll /////////////////////////
62 debug('');
63 debug('window.scroll Tests');
64 debug('');
66 debug("Testing - scroll with 0 arguments");
67 shouldNotThrow('window.scroll()');;
68 reset();
70 debug("Testing - scroll with 1 argument");
71 shouldThrow('window.scroll(x)');
72 reset();
74 debug("Testing - scroll with a valid ScrollToOptions argument");
75 shouldNotThrow('window.scroll({ })');
76 shouldNotThrow('window.scroll({ left: x })');
77 shouldNotThrow('window.scroll({ top: y })');
78 shouldNotThrow('window.scroll({ behavior: "auto" })');
79 shouldNotThrow('window.scroll({ behavior: "instant" })');
80 shouldNotThrow('window.scroll({ behavior: "smooth" })');
81 shouldNotThrow('window.scroll({ left: x, top: y })');
82 shouldNotThrow('window.scroll({ left: x, top: y, behavior: "auto" })');
83 shouldNotThrow('window.scroll({ left: x, top: y, behavior: "instant" })');
84 shouldNotThrow('window.scroll({ left: x, top: y, behavior: "smooth" })');
86 debug("Testing - scroll with an invalid ScrollToOptions argument");
87 shouldThrow('window.scroll({ behavior: "" })');
88 shouldThrow('window.scroll({ left: x, top: y, behavior: "abcd" })');
89 shouldThrow('window.scroll({ left: x, top: y, behavior: 200 })');
91 // scrollBy /////////////////////////
92 debug('');
93 debug('window.scrollBy Tests');
94 debug('');
96 debug("Testing - scrollBy with 0 arguments");
97 shouldNotThrow('window.scrollBy()');;
98 reset();
100 debug("Testing - scrollBy with 1 argument");
101 shouldThrow('window.scrollBy(x)');
102 reset();
104 debug("Testing - scrollBy with a valid ScrollOptions argument");
105 shouldNotThrow('window.scrollBy({ })');
106 shouldNotThrow('window.scrollBy({ left: x })');
107 shouldNotThrow('window.scrollBy({ top: y })');
108 shouldNotThrow('window.scrollBy({ behavior: "auto" })');
109 shouldNotThrow('window.scrollBy({ behavior: "instant" })');
110 shouldNotThrow('window.scrollBy({ behavior: "smooth" })');
111 shouldNotThrow('window.scrollBy({ left: x, top: y })');
112 shouldNotThrow('window.scrollBy({ left: x, top: y, behavior: "auto" })');
113 shouldNotThrow('window.scrollBy({ left: x, top: y, behavior: "instant" })');
114 shouldNotThrow('window.scrollBy({ left: x, top: y, behavior: "smooth" })');
116 debug("Testing - scrollBy with an invalid ScrollOptions argument");
117 shouldThrow('window.scrollBy({ behavior: "" })');
118 shouldThrow('window.scrollBy({ left: x, top: y, behavior: "abcd" })');
119 shouldThrow('window.scrollBy({ left: x, top: y, behavior: 200 })');
120 </script>
121 </body>
122 </html>