summaryrefslogtreecommitdiffstats
path: root/layout/style/test/chrome/test_bug511909.html
blob: fa28bbe8547a5dca88803d7ef9544b6171751da9 (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
<html><!--
   https://bugzilla.mozilla.org/show_bug.cgi?id=511909
   --><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>@media and @-moz-document testcases</title>
  
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>

<style type="text/css">
a {
    font-weight: bold;
}
  #pink {
    color: pink;
  }

  #green {
    color: green;
  }

  #blue {
    color: blue;
  }

pre {
   border: 1px solid black;
}
</style>

<style type="text/css">
@-moz-document regexp(".*test_bug511909.*"){
    #d {
      color: pink;
    }
}
</style>

<style type="text/css">
@media screen {
   #m {
      color: green;
   }
}
</style>

<style type="text/css">
@-moz-document regexp(".*test_bug511909.*"){
  @media screen {
      #dm {
         color: blue;
      }
   }
}
</style>

<!-- should parse -->
<style type="text/css">
@media print {
  @-moz-document regexp("not_this_url"),}
    #mx {
        color: pink;
    }
  }
}
</style>

<!-- should parse -->
<style type="text/css">
@-moz-document regexp("not_this_url"){
  @media print ,}
    #mxx {
      color: blue;
    }
  }
}
</style>

<style type="text/css">
@media screen {
  @-moz-document regexp(".*test_bug511909.*"){
      #md {
         color: green;
      }
   }
}
</style>

<style type="text/css">
@media screen {
  @-moz-document regexp(".*test_bug511909.*"){
      @media screen { 
        @-moz-document regexp(".*test_bug511909.*"){
          @media screen {
            #me {
             color: blue; 
            }
          }
        }
     }
   }
}
</style>
</head>
<body>
  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=511909">Mozilla Bug 511909</a>
  <p id="display"></p>
  <div id="content" style="display: none">
  </div>

  <script class="testbody" type="text/javascript">
    SimpleTest.waitForExplicitFinish();

    addLoadEvent(function() {
    // Ensure all the sheets are re-parsed, so that the pref applies.
    for (const sheet of Array.from(document.querySelectorAll('style'))) {
      sheet.textContent += "/* dummy */";
    }

    var pink = getComputedStyle(document.getElementById("pink"), "");
    var green = getComputedStyle(document.getElementById("green"), "");
    var blue = getComputedStyle(document.getElementById("blue"), "");

    var cs1 = getComputedStyle(document.getElementById("d"), "");
    var cs2 = getComputedStyle(document.getElementById("m"), "");
    var cs3 = getComputedStyle(document.getElementById("dm"), "");
    var cs4 = getComputedStyle(document.getElementById("md"), "");
    var cs5 = getComputedStyle(document.getElementById("mx"), "");
    var cs6 = getComputedStyle(document.getElementById("mxx"), "");
    var cs7 = getComputedStyle(document.getElementById("me"), "");

    is(cs1.color, pink.color, "@-moz-document applies");
    is(cs2.color, green.color, "@media applies");
    is(cs3.color, blue.color, "@media nested in @-moz-document applies");
    is(cs4.color, green.color, "@-moz-document nested in @media applies");
    is(cs5.color, pink.color, "broken @media nested in @-moz-document correctly handled");
    is(cs6.color, blue.color, "broken @-moz-document nested in @media correctly handled");
    is(cs7.color, blue.color, "@media nested in @-moz-document nested in @media applies");
    SimpleTest.finish();
  });
  </script>
<div>
<pre>default style
</pre>
<a id="pink">This line should be pink</a><br>
  
<a id="green">This line should be green</a><br>
  
<a id="blue">This line should be blue</a><br>
  
<pre>@-moz-document {...}
</pre>
<a id="d">This line should be pink</a><br>
<pre>@media screen {...}
</pre>
<a id="m">This line should be green</a><br>
<pre>@-moz-document {
   @media screen {...}
}
</pre>
<a id="dm">This line should be blue</a><br>
<pre>@media print {
  @-moz-document regexp("not_this_url"),}
    #mx {
        color: pink;
    }
  }
}
</pre>
<a id="mx">This line should be pink</a><br></div>
<pre>@-moz-document regexp("not_this_url"){
  @media print ,}
    #mxx {
      color: blue;
    }
  }
}
</pre>
<a id="mxx">This line should be blue</a><br>
<pre>@media screen {
  @-moz-documen {...}
}
</pre>
<a id="md">This line should be green</a><br>
<pre>@media screen {
  @-moz-document {
    @media screen {...}
  }
}
</pre>
<a id="me">This line should be blue</a><br>


</body></html>