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 a single non-dictionary argument or with a dictionary \
29 whose 'behavior' field is invalid throws an exception.");
31 // scrollTo /////////////////////////
33 debug('window.scrollTo Tests');
36 debug("Testing - scrollTo with 0 arguments");
37 shouldNotThrow('window.scrollTo()');
40 debug("Testing - scrollTo with 1 non-dictionary argument");
41 shouldThrow('window.scrollTo(x)');;
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 /////////////////////////
63 debug('window.scroll Tests');
66 debug("Testing - scroll with 0 arguments");
67 shouldNotThrow('window.scroll()');;
70 debug("Testing - scroll with 1 argument");
71 shouldThrow('window.scroll(x)');
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 /////////////////////////
93 debug('window.scrollBy Tests');
96 debug("Testing - scrollBy with 0 arguments");
97 shouldNotThrow('window.scrollBy()');;
100 debug("Testing - scrollBy with 1 argument");
101 shouldThrow('window.scrollBy(x)');
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 })');