| 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 or with an invalid third argument\ | 28 methods with a single non-dictionary argument or with a dictionary \ |
| 29 throws an exception."); | 29 whose 'behavior' field is invalid throws an exception."); |
| 30 | 30 |
| 31 // scrollTo ///////////////////////// | 31 // scrollTo ///////////////////////// |
| 32 debug(''); | 32 debug(''); |
| 33 debug('window.scrollTo Tests'); | 33 debug('window.scrollTo Tests'); |
| 34 debug(''); | 34 debug(''); |
| 35 | 35 |
| 36 debug("Testing - scrollTo with 0 arguments"); | 36 debug("Testing - scrollTo with 0 arguments"); |
| 37 shouldThrow('window.scrollTo()'); | 37 shouldNotThrow('window.scrollTo()'); |
| 38 reset(); | 38 reset(); |
| 39 | 39 |
| 40 debug("Testing - scrollTo with 1 argument"); | 40 debug("Testing - scrollTo with 1 non-dictionary argument"); |
| 41 shouldThrow('window.scrollTo(x)');; | 41 shouldThrow('window.scrollTo(x)');; |
| 42 reset(); | 42 reset(); |
| 43 | 43 |
| 44 debug("Testing - scrollTo with a valid ScrollOptions argument"); | 44 debug("Testing - scrollTo with a valid ScrollToOptions argument"); |
| 45 shouldNotThrow('window.scrollTo(x, y, { })'); | 45 shouldNotThrow('window.scrollTo({ })'); |
| 46 shouldNotThrow('window.scrollTo(x, y, { behavior: "auto" })'); | 46 shouldNotThrow('window.scrollTo({ left: x })'); |
| 47 shouldNotThrow('window.scrollTo(x, y, { behavior: "instant" })'); | 47 shouldNotThrow('window.scrollTo({ top: y })'); |
| 48 shouldNotThrow('window.scrollTo(x, y, { behavior: "smooth" })'); | 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" })'); |
| 49 | 55 |
| 50 debug("Testing - scrollTo with an invalid ScrollOptions argument"); | 56 debug("Testing - scrollTo with an invalid ScrollToOptions argument"); |
| 51 shouldThrow('window.scrollTo(x, y, { behavior: "" })'); | 57 shouldThrow('window.scrollTo({ behavior: "" })'); |
| 52 shouldThrow('window.scrollTo(x, y, { behavior: "abcd" })'); | 58 shouldThrow('window.scrollTo({ left: x, top: y, behavior: "abcd" })'); |
| 53 shouldThrow('window.scrollTo(x, y, 200, "text")'); | 59 shouldThrow('window.scrollTo({ left: x, top: y, behavior: 200 })'); |
| 54 | 60 |
| 55 // scroll ///////////////////////// | 61 // scroll ///////////////////////// |
| 56 debug(''); | 62 debug(''); |
| 57 debug('window.scroll Tests'); | 63 debug('window.scroll Tests'); |
| 58 debug(''); | 64 debug(''); |
| 59 | 65 |
| 60 debug("Testing - scroll with 0 arguments"); | 66 debug("Testing - scroll with 0 arguments"); |
| 61 shouldThrow('window.scroll()');; | 67 shouldNotThrow('window.scroll()');; |
| 62 reset(); | 68 reset(); |
| 63 | 69 |
| 64 debug("Testing - scroll with 1 argument"); | 70 debug("Testing - scroll with 1 argument"); |
| 65 shouldThrow('window.scroll(x)'); | 71 shouldThrow('window.scroll(x)'); |
| 66 reset(); | 72 reset(); |
| 67 | 73 |
| 68 debug("Testing - scroll with a valid ScrollOptions argument"); | 74 debug("Testing - scroll with a valid ScrollToOptions argument"); |
| 69 shouldNotThrow('window.scroll(x, y, { })'); | 75 shouldNotThrow('window.scroll({ })'); |
| 70 shouldNotThrow('window.scroll(x, y, { behavior: "auto" })'); | 76 shouldNotThrow('window.scroll({ left: x })'); |
| 71 shouldNotThrow('window.scroll(x, y, { behavior: "instant" })'); | 77 shouldNotThrow('window.scroll({ top: y })'); |
| 72 shouldNotThrow('window.scroll(x, y, { behavior: "smooth" })'); | 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" })'); |
| 73 | 85 |
| 74 debug("Testing - scroll with an invalid ScrollOptions argument"); | 86 debug("Testing - scroll with an invalid ScrollToOptions argument"); |
| 75 shouldThrow('window.scroll(x, y, { behavior: "" })'); | 87 shouldThrow('window.scroll({ behavior: "" })'); |
| 76 shouldThrow('window.scroll(x, y, { behavior: "abcd" })'); | 88 shouldThrow('window.scroll({ left: x, top: y, behavior: "abcd" })'); |
| 77 shouldThrow('window.scroll(x, y, 200, "text")'); | 89 shouldThrow('window.scroll({ left: x, top: y, behavior: 200 })'); |
| 78 | 90 |
| 79 // scrollBy ///////////////////////// | 91 // scrollBy ///////////////////////// |
| 80 debug(''); | 92 debug(''); |
| 81 debug('window.scrollBy Tests'); | 93 debug('window.scrollBy Tests'); |
| 82 debug(''); | 94 debug(''); |
| 83 | 95 |
| 84 debug("Testing - scrollBy with 0 arguments"); | 96 debug("Testing - scrollBy with 0 arguments"); |
| 85 shouldThrow('window.scrollBy()');; | 97 shouldNotThrow('window.scrollBy()');; |
| 86 reset(); | 98 reset(); |
| 87 | 99 |
| 88 debug("Testing - scrollBy with 1 argument"); | 100 debug("Testing - scrollBy with 1 argument"); |
| 89 shouldThrow('window.scrollBy(x)'); | 101 shouldThrow('window.scrollBy(x)'); |
| 90 reset(); | 102 reset(); |
| 91 | 103 |
| 92 debug("Testing - scrollBy with a valid ScrollOptions argument"); | 104 debug("Testing - scrollBy with a valid ScrollOptions argument"); |
| 93 shouldNotThrow('window.scrollBy(x, y, { })'); | 105 shouldNotThrow('window.scrollBy({ })'); |
| 94 shouldNotThrow('window.scrollBy(x, y, { behavior: "auto" })'); | 106 shouldNotThrow('window.scrollBy({ left: x })'); |
| 95 shouldNotThrow('window.scrollBy(x, y, { behavior: "instant" })'); | 107 shouldNotThrow('window.scrollBy({ top: y })'); |
| 96 shouldNotThrow('window.scrollBy(x, y, { behavior: "smooth" })'); | 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" })'); |
| 97 | 115 |
| 98 debug("Testing - scrollBy with an invalid ScrollOptions argument"); | 116 debug("Testing - scrollBy with an invalid ScrollOptions argument"); |
| 99 shouldThrow('window.scrollBy(x, y, { behavior: "" })'); | 117 shouldThrow('window.scrollBy({ behavior: "" })'); |
| 100 shouldThrow('window.scrollBy(x, y, { behavior: "abcd" })'); | 118 shouldThrow('window.scrollBy({ left: x, top: y, behavior: "abcd" })'); |
| 101 shouldThrow('window.scrollBy(x, y, 200, "text")'); | 119 shouldThrow('window.scrollBy({ left: x, top: y, behavior: 200 })'); |
| 102 </script> | 120 </script> |
| 103 </body> | 121 </body> |
| 104 </html> | 122 </html> |
| OLD | NEW |