6190942686beb443399492700ce04634532671e2
[WebKit-https.git] / LayoutTests / css3 / scroll-snap / scroll-snap-subpixel-repeat.html
1 <!DOCTYPE html>
2 <html>
3     <head>
4         <style>
5             #gallery {
6                 height: 100px;
7                 width: 100px;
8                 overflow-x: hidden;
9                 overflow-y: auto;
10                 -webkit-scroll-snap-type: mandatory;
11                 -webkit-scroll-snap-points-y: repeat(0.0001px);
12                 margin: 0;
13                 padding: 0;
14             }
15
16             .colorBox {
17                 width: 100px;
18                 height: 100px;
19             }
20
21             #item0 { background-color: red; }
22             #item1 { background-color: green; }
23         </style>
24         <script src="../../resources/js-test-pre.js"></script>
25         <script>
26         function runTest()
27         {
28             var gallery = document.getElementById("gallery");
29
30             if (window.testRunner) {
31                 window.jsTestIsAsync = true;
32                 testRunner.dumpAsText();
33                 testRunner.waitUntilDone();
34                 setTimeout(dumpSnapOffsets, 0);
35             }
36
37             function snapOffsetsFromString(offsetsAsString)
38             {
39                 var startIndex = offsetsAsString.search(/\{/);
40                 var endIndex = offsetsAsString.search(/\}/);
41                 if (startIndex == -1 || endIndex == -1 || endIndex <= startIndex)
42                     return []
43
44                 return offsetsAsString
45                     .substring(startIndex + 1, endIndex - startIndex - 1)
46                     .trim()
47                     .split(",")
48                     .map(function(s) { return parseFloat(s.trim()) });
49             }
50
51             function dumpSnapOffsets()
52             {
53                 var offsets = snapOffsetsFromString(window.internals.scrollSnapOffsets(gallery));
54                 debug("Number of snap offsets: " + offsets.length);
55                 finishJSTest();
56             }
57         }
58         </script>
59     </head>
60     <body onload="runTest()">
61         <div id="gallery">
62             <div id="item0" class="colorBox"></div>
63             <div id="item1" class="colorBox"></div>
64         </div>
65         <div id="console"></div>
66         <script>
67         description("Tests that small positive repeat() values generates a reasonable number of snap offsets.");
68         </script>
69         <script src="../../resources/js-test-post.js"></script>
70     </body>
71 </html>