summaryrefslogtreecommitdiff
path: root/layout/reftests/css-display/display-contents-shadow-dom-1.html
blob: f5e49a192add3ec9e956f1fb6918dfcf2aae21f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<!DOCTYPE html>
<!--
     Any copyright is dedicated to the Public Domain.
     http://creativecommons.org/publicdomain/zero/1.0/
-->
<html class="reftest-wait" lang="en-US">
  <head>
  <title>CSS Test: CSS display:contents; in Shadow DOM</title>
  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=907396">
  <link rel="help" href="http://dev.w3.org/csswg/css-display">
<style>
html,body {
    color:black; background-color:white; font-size:16px; padding:0; margin:0;
}
.before::before {content: "a ";}
.after::after {content: " c";}
div.before::before {content: "X ";}
div.after::after {content: " Y";}
.b,.c { display:contents; }
</style>
  </head>
  <body>
    <div id="host1" class="before"></div>
    <span id="host2"></span>
    <div id="host3" class="after"></div>
    <div id="host4" class="before after"></div>
    <div id="host5" class="after"></div>
    <div id="host6" class="before"></div>
    <div id="host7"></div>
    <div id="host8" class="after"></div>
    <div id="host9" class="before after"></div>
    <div id="hostA" class="after"></div>
    <div id="hostB"></div>
    <div id="hostC"></div>
    <div id="hostD"></div>
    <div id="hostE"></div>
    <div id="hostF" class="before"></div>
    <div id="hostG"></div>
    <span id="hostH"></span>
    <div id="hostI"></div>
    <div id="hostJ"></div>
    <span id="hostK"></span>
    <div id="hostL"></div>
    <div id="hostM"><i>Two</i><b>One</b></div>
    <div id="hostN"><i class="c">Two</i><b>One</b></div>
    <div id="hostO"><i>Two</i><b class="c">One</b></div>
    <div id="hostP"><i class="c">Two</i><b class="c">One</b></div>
    <div id="hostQ" class="c" style="color:blue"><i class="c">Two</i><b class="c">One</b></div>Three
    <span id="hostR"><style scoped>:scope{color:green}</style></span>
    <div id="hostS" class="c"><span class="c">S</span></div>
    <div id="hostT" class="c">T</div>
    <div id="hostU"><span class="c">U</span></div>
    <div id="hostV" class="c" style="color:red"><b class="c" style="color:inherit">V</b></div>
    <div id="hostW" class="c" style="color:red"><b class="c" style="color:inherit">W</b></div>
    <span id="hostX" style="color:red"><b class="c" style="color:inherit">X</b></span>
    <!-- TODO(bug 1021572?) <div id="hostY" class="c" style="color:red"><b>Y</b></div> -->

   <script>
      function shadow(id) {
        return document.getElementById(id).createShadowRoot();
      }
      function span(s) {
        var e = document.createElement("span");
        var t = document.createTextNode(s);
        e.appendChild(t);
        return e;
      }
      function text(s) {
        return document.createTextNode(s);
      }
      function contents(n) {
        var e = document.createElement("z");
        e.style.display = "contents";
        e.style.color = "blue"; 
        if (n) e.appendChild(n);
        return e;
      }

      document.body.offsetHeight;

      shadow("host1").innerHTML = '<content></content> c';
      shadow("host2").innerHTML = 'a <content style="display:contents"></content> c';
      shadow("host3").innerHTML = 'a <content style="display:contents"></content>';
      shadow("host4").innerHTML = '<content style="display:contents"></content>';
      shadow("host5").innerHTML = 'a <content style="display:contents"></content>';
      shadow("host6").innerHTML = '<z style="color:blue; display:contents"><content></content></z> c';
      shadow("host7").innerHTML = 'a <content style="display:contents"></content> c';
      shadow("host8").innerHTML = 'a <z style="color:blue; display:contents"><content style="display:contents"></z></content>';
      shadow("host9").innerHTML = '<content style="display:contents"></content>';
      shadow("hostA").innerHTML = 'a <content style="display:contents"></content>';
      shadow("hostB").innerHTML = 'a <content select=".c"></content> <content select=".b"></content> B';
      shadow("hostC").innerHTML = 'A <content select=".c"></content> <content select=".b"></content> B';
      shadow("hostD").innerHTML = 'A <content select=".c"></content> <content select=".b"></content> B <content select=".b"></content>';
      shadow("hostE").innerHTML = 'A <content select=".c"></content> <content select=".b"></content> B';
      shadow("hostF").innerHTML = '<content select=".c"></content> <content select=".b"></content> B';
      shadow("hostG").innerHTML = '<content select=".b"></content>';
      shadow("hostH").innerHTML = '<content select=".b"></content>';
      shadow("hostI").innerHTML = 'A<content select=".b"></content>';
      shadow("hostJ").innerHTML = 'A<content select=".b"></content>';
      shadow("hostK").innerHTML = '<content select=".b"></content>';
      shadow("hostL").innerHTML = '<content select=".b"></content>';
      shadow("hostM").innerHTML = '<content select="b"></content><content select="i"></content>';
      shadow("hostN").innerHTML = '<content select="b"></content><content select="i"></content>';
      shadow("hostO").innerHTML = '<content select="b"></content><content select="i"></content>';
      shadow("hostP").innerHTML = '<content select="b"></content><content select="i"></content>';
      shadow("hostQ").innerHTML = '<content select="b"></content><content select="i"></content>';
      shadow("hostR").innerHTML = '<content select="span"></content>';
      shadow("hostW").innerHTML = '<z style="color:red"><content select="b"></content></z>';
      shadow("hostX").innerHTML = '<z style="color:red"><content select="b"></content></z>';
      // TODO(bug 1021572?) shadow("hostY").innerHTML = '<content select="b"><style scoped>:scope{color:green}</style></content>';

      function tweak() {
        document.body.offsetHeight;

        host1.appendChild(span("1"));
        host2.appendChild(text("2"));
        host3.appendChild(span("3"));
        host4.appendChild(text("4"));

        var e = span("5");
        e.style.display = "contents";
        host5.appendChild(e);

        host6.appendChild(span("6"));
        host7.appendChild(contents(text("7")));
        host8.appendChild(contents(span("8")));
        host9.appendChild(contents(text("9")));

        var e = contents(span("A"));
        e.style.display = "contents";
        hostA.appendChild(e);

        var e = contents(text("2"));
        e.className = "b";
        hostB.appendChild(e);
        var e = contents(text("1"));
        e.className = "c";
        hostB.appendChild(e);

        var e = contents(text("2"));
        e.className = "b after";
        hostC.appendChild(e);
        var e = contents(text("1"));
        e.className = "c  before";
        hostC.appendChild(e);

        var e = contents(text("2"));
        e.className = "b before after";
        hostD.appendChild(e);
        var e = contents(text(" 3"));
        e.className = "b before after";
        hostD.appendChild(e);
        var e = contents(text("1"));
        e.className = "c  before";
        hostD.appendChild(e);

        var e = contents(contents(text("2")));
        e.className = "before b after";
        hostE.appendChild(e);
        var e2 = contents(text("1"));
        e2.className = "c  before after";
        hostE.insertBefore(e2, e);

        var e = contents(text("2"));
        e.className = "before b after";
        hostF.appendChild(e);
        var e2 = contents(text("1"));
        e2.className = "c  before after";
        hostF.insertBefore(e2, e);

        var e = contents(contents(text("1")));
        e.className = "b";
        hostG.appendChild(e);
        var e = contents(text("2"));
        e.className = "b  before after";
        hostG.appendChild(e);

        var e = contents(contents(text("2")));
        e.className = "b";
        hostH.appendChild(e);
        var e2 = contents(text("1"));
        e2.className = "b  before after";
        hostH.insertBefore(e2, e);

        var e = contents(text("b"));
        e.className = "b";
        hostI.appendChild(e);
        var e = span("c");
        e.className = "b";
        hostI.appendChild(e);

        var e = contents(contents(text("b")));
        e.className = "b";
        hostJ.appendChild(e);
        var e = span("c");
        e.className = "b";
        hostJ.appendChild(e);

        var inner = span("b");
        inner.className = "after";
        var e = contents(contents(inner));
        e.className = "b";
        hostK.appendChild(e);
        var e = span("d");
        e.className = "b";
        hostK.appendChild(e);

        var inner = contents(null);
        inner.className = "before";
        var e = contents(inner);
        e.className = "b";
        hostL.appendChild(e);
        var e = span("b");
        e.className = "b";
        hostL.appendChild(e);

        hostR.appendChild(span("R"));

        document.body.offsetHeight;
        setTimeout(function() {
            shadow("hostS");
            shadow("hostT");
            shadow("hostU");
            shadow("hostV").innerHTML = '<z style="color:green"><content select="b"></content></z>';
            shadow("hostW").innerHTML = '<z style="color:green"><content select="b"></content></z>';
            shadow("hostX").innerHTML = '<z style="color:green"><content select="b"></content></z>';

            document.body.offsetHeight;
            document.documentElement.removeAttribute("class");
          },0);
      }

      window.addEventListener("MozReftestInvalidate", tweak, false);
    </script>
  </body>
</html>