Implement the updated port/area-based Scroll Snap Module Level 1 Spec
[WebKit-https.git] / LayoutTests / css3 / scroll-snap / resources / iframe-content.html
1 <!DOCTYPE html>
2 <html>
3     <head>
4         <style>
5             .horizontalGallery {
6                 width: 400px;
7                 height: 50px;
8                 overflow-y: hidden;
9                 overflow-x: auto;
10             }
11             .horizontalGalleryDrawer {
12                 width: 3000px;
13                 height: 50px;
14             }
15             .colorBox {
16                 height: 50px;
17                 width: 400px;
18                 float: left;
19                 scroll-snap-align: start;
20             }
21
22             .noInitial {
23                 scroll-snap-type: x mandatory;
24             }
25
26             #item0 { background-color: red; }
27             #item1 { background-color: green; }
28             #item2 { background-color: blue; }
29             #item3 { background-color: aqua; }
30             #item4 { background-color: yellow; }
31             #item5 { background-color: fuchsia; }
32         </style>
33         <script>
34         top.succeeded = true;
35         </script>
36     </head>
37     <body>
38         <div style="width: 400px">
39             <div id="noInitial" class="horizontalGallery noInitial">
40                 <div class="horizontalGalleryDrawer">
41                     <div id="item0" class="colorBox"></div>
42                     <div id="item1" class="colorBox"></div>
43                     <div id="item2" class="colorBox"></div>
44                     <div id="item3" class="colorBox"></div>
45                     <div id="item4" class="colorBox"></div>
46                     <div id="item5" class="colorBox"></div>
47                 </div>
48             </div>
49         </div>
50         <div id="console"></div>
51         <script>
52
53         function shouldMatch(_a, _b, result)
54         {
55             if (typeof _a !== "string" || typeof _b !== "string")
56                 top.debug("WARN: shouldBeEqualToString() expects string arguments");
57
58             var _av;
59             try {
60                 _av = eval(_a);
61             } catch (e) {
62                 return false;
63             }
64  
65             return top.isResultCorrect(_av, _b);      
66         }
67
68         var noInitial = document.getElementById('noInitial');
69         top.succeeded = shouldMatch("window.getComputedStyle(noInitial).getPropertyValue('scroll-snap-type')", "both mandatory");
70         document.querySelectorAll(".colorBox").forEach(colorBox => {
71             window.colorBox = colorBox;
72             top.succeeded = shouldMatch("getComputedStyle(colorBox).getPropertyValue('scroll-snap-align')", "start start");
73         });
74         if (top.succeeded)
75             top.debug("iframe processed all tests successfully.");
76         else
77             top.debug("iframe processing failed.");
78         </script>
79     </body>
80 </html>
81