1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
4 <script src="../../../resources/js-test.js"></script>
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">
18 resetX = window.scrollX;
19 resetY = window.scrollY;
22 if (window.testRunner)
23 testRunner.dumpAsText();
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.");
31 // scrollTo /////////////////////////
33 debug('window.scrollTo Tests');
36 debug("Testing - scrollTo with 0 arguments");
37 shouldThrow('window.scrollTo()');
40 debug("Testing - scrollTo with 1 argument");
41 shouldThrow('window.scrollTo(x)');;
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" })');
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")');
55 // scroll /////////////////////////
57 debug('window.scroll Tests');
60 debug("Testing - scroll with 0 arguments");
61 shouldThrow('window.scroll()');;
64 debug("Testing - scroll with 1 argument");
65 shouldThrow('window.scroll(x)');
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" })');
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")');
79 // scrollBy /////////////////////////
81 debug('window.scrollBy Tests');
84 debug("Testing - scrollBy with 0 arguments");
85 shouldThrow('window.scrollBy()');;
88 debug("Testing - scrollBy with 1 argument");
89 shouldThrow('window.scrollBy(x)');
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" })');
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")');