Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / dom / Element / scrollTop-scrollLeft-setters.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4     <script src="../../../resources/js-test.js"></script>
5 </head>
6 <body>
7   <div id="container" style="overflow: scroll; height: 200px; width: 200px">
8     <div style="height: 1000px; width: 1000px; border: 1px solid black;">
9       This box should force the container div to have a scrollable area to test.
10     </div>
11   </div>
12   <script type="text/javascript">
13     if (window.testRunner)
14       testRunner.dumpAsText();
15
16     var element = document.getElementById("container");
17
18     description("This test makes sure setting scrollLeft or scrollTop to\
19     an invalid value throws an exception.");
20
21     // scrollLeft /////////////////////////
22     debug('');
23     debug('scrollLeft Tests');
24     debug('');
25
26     debug("Testing - setting scrollLeft to a valid value");
27     shouldNotThrow('element.scrollLeft = 32');
28     shouldNotThrow('element.scrollLeft = 32.1');
29     shouldNotThrow('element.scrollLeft = "string"');
30     shouldNotThrow('element.scrollLeft = null');
31     shouldNotThrow('element.scrollLeft = undefined');
32     shouldNotThrow('element.scrollLeft = Infinity');
33     shouldNotThrow('element.scrollLeft = NaN');
34     shouldNotThrow('element.scrollLeft = { x: 42 }');
35     shouldNotThrow('element.scrollLeft = { x: 42, behavior: "auto" }');
36     shouldNotThrow('element.scrollLeft = { x: 42, behavior: "instant" }');
37     shouldNotThrow('element.scrollLeft = { x: 42, behavior: "smooth" }');
38
39     debug("Testing - setting scrollLeft to an invalid value");
40     shouldThrow('element.scrollLeft = { }');
41     shouldThrow('element.scrollLeft = { x: 42, behavior: "" }');
42     shouldThrow('element.scrollLeft = { x: 42, behavior: "abcd" }');
43     shouldThrow('element.scrollLeft = { behavior: "abcd" }');
44     shouldThrow('element.scrollLeft = { behavior: "smooth" }');
45     shouldThrow('element.scrollLeft = { behavior: "instant" }');
46     shouldThrow('element.scrollLeft = { behavior: "smooth" }');
47
48     // scrollTop /////////////////////////
49     debug('');
50     debug('scrollTop Tests');
51     debug('');
52
53     debug("Testing - setting scrollTop to a valid value");
54     shouldNotThrow('element.scrollTop = 32');
55     shouldNotThrow('element.scrollTop = 32.1');
56     shouldNotThrow('element.scrollTop = "string"');
57     shouldNotThrow('element.scrollTop = null');
58     shouldNotThrow('element.scrollTop = undefined');
59     shouldNotThrow('element.scrollTop = Infinity');
60     shouldNotThrow('element.scrollTop = NaN');
61     shouldNotThrow('element.scrollTop = { y: 42 }');
62     shouldNotThrow('element.scrollTop = { y: 42, behavior: "auto" }');
63     shouldNotThrow('element.scrollTop = { y: 42, behavior: "instant" }');
64     shouldNotThrow('element.scrollTop = { y: 42, behavior: "smooth" }');
65
66     debug("Testing - setting scrollTop to an invalid value");
67     shouldThrow('element.scrollTop = { }');
68     shouldThrow('element.scrollTop = { y: 42, behavior: "" }');
69     shouldThrow('element.scrollTop = { y: 42, behavior: "abcd" }');
70     shouldThrow('element.scrollTop = { behavior: "abcd" }');
71     shouldThrow('element.scrollTop = { behavior: "smooth" }');
72     shouldThrow('element.scrollTop = { behavior: "instant" }');
73     shouldThrow('element.scrollTop = { behavior: "smooth" }');
74   </script>
75 </body>
76 </html>