Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(664)

Side by Side Diff: LayoutTests/fast/dom/Window/window-scroll-arguments.html

Issue 146003002: Bindings for CSSOM View smooth scroll API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 more than 2 arguments");
44 window.scrollTo(x, y, 200, "text"); 45 window.scrollTo(x, y, 200, "text");
45 shouldBe('window.scrollX', 'x'); 46 shouldBe('window.scrollX', 'x');
46 shouldBe('window.scrollY', 'y'); 47 shouldBe('window.scrollY', 'y');
47 reset(); 48 reset();
48 49
50 debug("Testing - scrollTo with a valid ScrollOptions argument");
51 shouldNotThrow('window.scrollTo(x, y, { })');
52 shouldNotThrow('window.scrollTo(x, y, { behavior: "auto" })');
53 shouldNotThrow('window.scrollTo(x, y, { behavior: "instant" })');
54 shouldNotThrow('window.scrollTo(x, y, { behavior: "smooth" })');
55
56 debug("Testing - scrollTo with an invalid ScrollOptions argument");
57 shouldThrow('window.scrollTo(x, y, { behavior: "" })');
58 shouldThrow('window.scrollTo(x, y, { behavior: "abcd" })');
59
49 // scroll ///////////////////////// 60 // scroll /////////////////////////
50 debug(''); 61 debug('');
51 debug('window.scroll Tests'); 62 debug('window.scroll Tests');
52 debug(''); 63 debug('');
53 64
54 debug("Testing - scroll with 0 arguments"); 65 debug("Testing - scroll with 0 arguments");
55 shouldThrow('window.scroll()');; 66 shouldThrow('window.scroll()');;
56 reset(); 67 reset();
57 68
58 debug("Testing - scroll with 1 argument"); 69 debug("Testing - scroll with 1 argument");
59 shouldThrow('window.scroll(x)'); 70 shouldThrow('window.scroll(x)');
60 reset(); 71 reset();
61 72
62 debug("Testing - scroll with more than 2 arguments"); 73 debug("Testing - scroll with more than 2 arguments");
63 window.scroll(x, y, 200, "text"); 74 window.scroll(x, y, 200, "text");
64 shouldBe('window.scrollX', 'x'); 75 shouldBe('window.scrollX', 'x');
65 shouldBe('window.scrollY', 'y'); 76 shouldBe('window.scrollY', 'y');
66 reset(); 77 reset();
67 78
79 debug("Testing - scroll with a valid ScrollOptions argument");
80 shouldNotThrow('window.scroll(x, y, { })');
81 shouldNotThrow('window.scroll(x, y, { behavior: "auto" })');
82 shouldNotThrow('window.scroll(x, y, { behavior: "instant" })');
83 shouldNotThrow('window.scroll(x, y, { behavior: "smooth" })');
84
85 debug("Testing - scroll with an invalid ScrollOptions argument");
86 shouldThrow('window.scroll(x, y, { behavior: "" })');
87 shouldThrow('window.scroll(x, y, { behavior: "abcd" })');
88
68 // scrollBy ///////////////////////// 89 // scrollBy /////////////////////////
69 debug(''); 90 debug('');
70 debug('window.scrollBy Tests'); 91 debug('window.scrollBy Tests');
71 debug(''); 92 debug('');
72 93
73 debug("Testing - scrollBy with 0 arguments"); 94 debug("Testing - scrollBy with 0 arguments");
74 shouldThrow('window.scrollBy()');; 95 shouldThrow('window.scrollBy()');;
75 reset(); 96 reset();
76 97
77 debug("Testing - scrollBy with 1 argument"); 98 debug("Testing - scrollBy with 1 argument");
78 shouldThrow('window.scrollBy(x)'); 99 shouldThrow('window.scrollBy(x)');
79 reset(); 100 reset();
80 101
81 debug("Testing - scrollBy with more than 2 arguments"); 102 debug("Testing - scrollBy with more than 2 arguments");
82 window.scrollBy(x, y, 200, "text"); 103 window.scrollBy(x, y, 200, "text");
83 shouldBe('window.scrollX', 'resetX + x'); 104 shouldBe('window.scrollX', 'resetX + x');
84 shouldBe('window.scrollY', 'resetY + y'); 105 shouldBe('window.scrollY', 'resetY + y');
85 reset(); 106 reset();
107
108 debug("Testing - scrollBy with a valid ScrollOptions argument");
109 shouldNotThrow('window.scrollBy(x, y, { })');
110 shouldNotThrow('window.scrollBy(x, y, { behavior: "auto" })');
111 shouldNotThrow('window.scrollBy(x, y, { behavior: "instant" })');
112 shouldNotThrow('window.scrollBy(x, y, { behavior: "smooth" })');
113
114 debug("Testing - scrollBy with an invalid ScrollOptions argument");
115 shouldThrow('window.scrollBy(x, y, { behavior: "" })');
116 shouldThrow('window.scrollBy(x, y, { behavior: "abcd" })');
86 </script> 117 </script>
87 </body> 118 </body>
88 </html> 119 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698