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