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="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/js-test.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 throws exception."); | 28 methods with less than 2 arguments or with an invalid third argument\ |
| 29 throws an exception."); |
29 | 30 |
30 // scrollTo ///////////////////////// | 31 // scrollTo ///////////////////////// |
31 debug(''); | 32 debug(''); |
32 debug('window.scrollTo Tests'); | 33 debug('window.scrollTo Tests'); |
33 debug(''); | 34 debug(''); |
34 | 35 |
35 debug("Testing - scrollTo with 0 arguments"); | 36 debug("Testing - scrollTo with 0 arguments"); |
36 shouldThrow('window.scrollTo()'); | 37 shouldThrow('window.scrollTo()'); |
37 reset(); | 38 reset(); |
38 | 39 |
39 debug("Testing - scrollTo with 1 argument"); | 40 debug("Testing - scrollTo with 1 argument"); |
40 shouldThrow('window.scrollTo(x)');; | 41 shouldThrow('window.scrollTo(x)');; |
41 reset(); | 42 reset(); |
42 | 43 |
43 debug("Testing - scrollTo with more than 2 arguments"); | 44 debug("Testing - scrollTo with a valid ScrollOptions argument"); |
44 window.scrollTo(x, y, 200, "text"); | 45 shouldNotThrow('window.scrollTo(x, y, { })'); |
45 shouldBe('window.scrollX', 'x'); | 46 shouldNotThrow('window.scrollTo(x, y, { behavior: "auto" })'); |
46 shouldBe('window.scrollY', 'y'); | 47 shouldNotThrow('window.scrollTo(x, y, { behavior: "instant" })'); |
47 reset(); | 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")'); |
48 | 54 |
49 // scroll ///////////////////////// | 55 // scroll ///////////////////////// |
50 debug(''); | 56 debug(''); |
51 debug('window.scroll Tests'); | 57 debug('window.scroll Tests'); |
52 debug(''); | 58 debug(''); |
53 | 59 |
54 debug("Testing - scroll with 0 arguments"); | 60 debug("Testing - scroll with 0 arguments"); |
55 shouldThrow('window.scroll()');; | 61 shouldThrow('window.scroll()');; |
56 reset(); | 62 reset(); |
57 | 63 |
58 debug("Testing - scroll with 1 argument"); | 64 debug("Testing - scroll with 1 argument"); |
59 shouldThrow('window.scroll(x)'); | 65 shouldThrow('window.scroll(x)'); |
60 reset(); | 66 reset(); |
61 | 67 |
62 debug("Testing - scroll with more than 2 arguments"); | 68 debug("Testing - scroll with a valid ScrollOptions argument"); |
63 window.scroll(x, y, 200, "text"); | 69 shouldNotThrow('window.scroll(x, y, { })'); |
64 shouldBe('window.scrollX', 'x'); | 70 shouldNotThrow('window.scroll(x, y, { behavior: "auto" })'); |
65 shouldBe('window.scrollY', 'y'); | 71 shouldNotThrow('window.scroll(x, y, { behavior: "instant" })'); |
66 reset(); | 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")'); |
67 | 78 |
68 // scrollBy ///////////////////////// | 79 // scrollBy ///////////////////////// |
69 debug(''); | 80 debug(''); |
70 debug('window.scrollBy Tests'); | 81 debug('window.scrollBy Tests'); |
71 debug(''); | 82 debug(''); |
72 | 83 |
73 debug("Testing - scrollBy with 0 arguments"); | 84 debug("Testing - scrollBy with 0 arguments"); |
74 shouldThrow('window.scrollBy()');; | 85 shouldThrow('window.scrollBy()');; |
75 reset(); | 86 reset(); |
76 | 87 |
77 debug("Testing - scrollBy with 1 argument"); | 88 debug("Testing - scrollBy with 1 argument"); |
78 shouldThrow('window.scrollBy(x)'); | 89 shouldThrow('window.scrollBy(x)'); |
79 reset(); | 90 reset(); |
80 | 91 |
81 debug("Testing - scrollBy with more than 2 arguments"); | 92 debug("Testing - scrollBy with a valid ScrollOptions argument"); |
82 window.scrollBy(x, y, 200, "text"); | 93 shouldNotThrow('window.scrollBy(x, y, { })'); |
83 shouldBe('window.scrollX', 'resetX + x'); | 94 shouldNotThrow('window.scrollBy(x, y, { behavior: "auto" })'); |
84 shouldBe('window.scrollY', 'resetY + y'); | 95 shouldNotThrow('window.scrollBy(x, y, { behavior: "instant" })'); |
85 reset(); | 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")'); |
86 </script> | 102 </script> |
87 </body> | 103 </body> |
88 </html> | 104 </html> |
OLD | NEW |