Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=376075
5 -->
6 <head>
7 <title>Test for Bug 376075</title>
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
10 </head>
11 <body>
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=376075">Mozilla Bug 376075</a>
13 <p id="display"></p>
14 <div id="content" style="display: none">
16 </div>
17 <pre id="test">
18 <script type="application/javascript">
20 /** Test for Bug 376075 **/
22 var e = document.getElementById("display");
24 var borderExtras = ";-moz-border-top-colors: none; -moz-border-right-colors: none; -moz-border-bottom-colors: none; -moz-border-left-colors: none; border-image: none";
26 // Test that we only serialize the 'border' shorthand when appropriate.
27 e.setAttribute("style", "border-left: medium solid blue; border-right: medium solid blue; border-top: medium blue solid; border-bottom: blue medium solid" + borderExtras);
28 isnot(e.style.border, "", "should be able to serialize border");
29 e.setAttribute("style", "border-left: medium solid blue; border-right: medium solid blue; border-top: medium blue solid; border-bottom: green medium solid" + borderExtras);
30 is(e.style.border, "", "should not be able to serialize border");
31 e.setAttribute("style", "border-width: 3px 3px 3px 3px; border-style: solid; border-color: green" + borderExtras);
32 isnot(e.style.border, "", "should be able to serialize border");
33 e.setAttribute("style", "border-width: 3px 3px 3px 3px; border-style: solid; border-color: green blue blue blue" + borderExtras);
34 is(e.style.border, "", "should not be able to serialize border");
35 e.setAttribute("style", "border-width: 3px 3px 3px 3px; border-style: solid; border-color: blue green blue blue" + borderExtras);
36 is(e.style.border, "", "should not be able to serialize border");
37 e.setAttribute("style", "border-width: 3px 3px 3px 3px; border-style: solid; border-color: blue blue green blue" + borderExtras);
38 is(e.style.border, "", "should not be able to serialize border");
39 e.setAttribute("style", "border-width: 3px 3px 3px 3px; border-style: solid; border-color: blue blue blue green" + borderExtras);
40 is(e.style.border, "", "should not be able to serialize border");
41 e.setAttribute("style", "border-width: 3px 2px 3px 3px; border-style: solid; border-color: green" + borderExtras);
42 is(e.style.border, "", "should not be able to serialize border");
43 e.setAttribute("style", "border-width: 3px 3px 3px 3px; border-style: solid dashed; border-color: green" + borderExtras);
44 is(e.style.border, "", "should not be able to serialize border");
46 // Test suppression of -moz-use-text-color in border shorthands.
47 e.setAttribute("style", "border: medium solid");
48 ok(e.style.border == "medium solid" ||
49 e.style.border == "solid medium",
50 "implied default color omitted serializing border");
51 ok(e.style.borderLeft == "medium solid" ||
52 e.style.borderLeft == "solid medium",
53 "implied default color omitted serializing border-left");
54 ok(e.style.cssText == "border: medium solid;" ||
55 e.style.cssText == "border: solid medium;",
56 "implied default color omitted serializing declaration");
57 e.setAttribute("style", "border-right: medium solid");
58 ok(e.style.borderRight == "medium solid" ||
59 e.style.borderRight == "solid medium",
60 "implied default color omitted serializing border-right");
61 ok(e.style.borderRight == "medium solid" ||
62 e.style.borderRight == "solid medium",
63 "implied default color omitted serializing border-right");
64 ok(e.style.cssText == "border-right: medium solid;" ||
65 e.style.cssText == "border-right: solid medium;",
66 "implied default color omitted serializing declaration");
68 // Test that we shorten box properties to the shortest possible.
69 e.setAttribute("style", "margin: 7px");
70 is(e.style.margin, "7px", "should condense to shortest possible");
71 is(e.style.cssText, "margin: 7px;", "should condense to shortest possible");
72 e.setAttribute("style", "padding: 7px 7px 7px");
73 is(e.style.padding, "7px", "should condense to shortest possible");
74 is(e.style.cssText, "padding: 7px;", "should condense to shortest possible");
75 e.setAttribute("style", "border-width: 7px 7px 7px 7px");
76 is(e.style.borderWidth, "7px", "should condense to shortest possible");
77 is(e.style.cssText, "border-width: 7px;", "should condense to shortest possible");
78 e.setAttribute("style", "margin: 7px 7px 7px 6px");
79 is(e.style.margin, "7px 7px 7px 6px", "should not condense");
80 is(e.style.cssText, "margin: 7px 7px 7px 6px;", "should not condense");
81 e.setAttribute("style", "border-style: solid dotted none dotted");
82 is(e.style.borderStyle, "solid dotted none", "should condense");
83 is(e.style.cssText, "border-style: solid dotted none;", "should condense");
84 e.setAttribute("style", "border-color: green blue");
85 is(e.style.borderColor, "green blue", "should condense");
86 is(e.style.cssText, "border-color: green blue;", "should condense");
87 e.setAttribute("style", "border-color: green blue green");
88 is(e.style.borderColor, "green blue", "should condense");
89 is(e.style.cssText, "border-color: green blue;", "should condense");
90 e.setAttribute("style", "border-color: green blue green blue");
91 is(e.style.borderColor, "green blue", "should condense");
92 is(e.style.cssText, "border-color: green blue;", "should condense");
93 e.setAttribute("style", "border-color: currentColor currentColor currentcolor CURRENTcolor");
94 is(e.style.borderColor, "currentcolor", "should condense to canonical case");
95 is(e.style.cssText, "border-color: currentcolor;", "should condense to canonical case");
96 e.setAttribute("style", "border-style: ridge none none none");
97 is(e.style.borderStyle, "ridge none none", "should condense");
98 is(e.style.cssText, "border-style: ridge none none;", "should condense");
99 e.setAttribute("style", "border-radius: 1px 1px 1px 1px");
100 is(e.style.borderRadius, "1px", "should condense to shortest possible");
101 is(e.style.cssText, "border-radius: 1px;", "should condense to shortest possible");
102 e.setAttribute("style", "border-radius: 1px 1px 1px 1px / 2px 2px 2px 2px");
103 is(e.style.borderRadius, "1px / 2px", "should condense to shortest possible");
104 is(e.style.cssText, "border-radius: 1px / 2px;", "should condense to shortest possible");
105 e.setAttribute("style", "border-radius: 1px 2px 1px 2px / 1% 2% 3% 2%");
106 is(e.style.borderRadius, "1px 2px / 1% 2% 3%", "should condense to shortest possible");
107 is(e.style.cssText, "border-radius: 1px 2px / 1% 2% 3%;", "should condense to shortest possible");
109 // Test that we refuse to serialize the 'background' and 'font'
110 // shorthands when some subproperties that can't be expressed in the
111 // shorthand syntax are present.
112 e.setAttribute("style", "font: medium serif");
113 isnot(e.style.font, "", "should have font shorthand");
114 e.setAttribute("style", "font: medium serif; font-size-adjust: 0.45");
115 is(e.style.font, "", "should not have font shorthand");
116 e.setAttribute("style", "font: medium serif; font-stretch: condensed");
117 is(e.style.font, "", "should not have font shorthand");
119 // Test that all combinations of background-clip and background-origin
120 // can be expressed in the shorthand (which wasn't the case previously).
121 e.setAttribute("style", "background: red");
122 isnot(e.style.background, "", "should have background shorthand");
123 e.setAttribute("style", "background: red; background-origin: border-box");
124 isnot(e.style.background, "", "should have background shorthand (origin:border-box)");
125 e.setAttribute("style", "background: red; background-clip: padding-box");
126 isnot(e.style.background, "", "should have background shorthand (clip:padding-box)");
127 e.setAttribute("style", "background: red; background-origin: content-box");
128 isnot(e.style.background, "", "should have background shorthand (origin:content-box)");
129 e.setAttribute("style", "background: red; background-clip: content-box");
130 isnot(e.style.background, "", "should have background shorthand (clip:content-box)");
131 e.setAttribute("style", "background: red; background-clip: content-box; background-origin: content-box;");
132 isnot(e.style.background, "", "should have background shorthand (clip:content-box;origin:content-box)");
134 // Test background-size in the background shorthand.
135 e.setAttribute("style", "background: red; background-size: 100% 100%");
136 isnot(e.style.background, "", "should have background shorthand (size:100% 100%)");
137 e.setAttribute("style", "background: red; background-size: 100% auto");
138 isnot(e.style.background, "", "should have background shorthand (size:100% auto)");
139 e.setAttribute("style", "background: red; background-size: auto 100%");
140 isnot(e.style.background, "", "should have background shorthand (size:auto 100%)");
142 // Test background-inline-policy not interacting with the background shorthand.
143 e.setAttribute("style", "background: red; -moz-background-inline-policy: each-box");
144 isnot(e.style.background, "", "should have background shorthand (-moz-background-inline-policy not relevant)");
146 // Check that we only serialize background when the lists (of layers) for
147 // the subproperties are the same length.
148 e.setAttribute("style", "background-clip: border-box, padding-box, border-box; background-origin: border-box, padding-box, padding-box; background-size: cover, auto, contain; background-color: blue; background-image: url(404.png), none, url(404-2.png); background-attachment: fixed, scroll, scroll; background-position: top left, center, 30px 50px; background-repeat: repeat-x, repeat, no-repeat");
149 isnot(e.style.background, "", "should have background shorthand (all lists length 3)");
150 e.setAttribute("style", "background-clip: border-box, padding-box, border-box, border-box; background-origin: border-box, padding-box, padding-box; background-size: cover, auto, contain; background-color: blue; background-image: url(404.png), none, url(404-2.png); background-attachment: fixed, scroll, scroll; background-position: top left, center, 30px 50px; background-repeat: repeat-x, repeat, no-repeat");
151 is(e.style.background, "", "should not have background shorthand (background-clip too long)");
152 e.setAttribute("style", "background-clip: border-box, padding-box, border-box; background-origin: padding-box, padding-box; background-size: cover, auto, contain; background-color: blue; background-image: url(404.png), none, url(404-2.png); background-attachment: fixed, scroll, scroll; background-position: top left, center, 30px 50px; background-repeat: repeat-x, repeat, no-repeat");
153 is(e.style.background, "", "should not have background shorthand (background-origin too short)");
154 e.setAttribute("style", "background-clip: border-box, padding-box, border-box; background-origin: border-box, padding-box, padding-box; background-size: cover, auto, contain; background-color: blue; background-image: url(404.png), none, url(404-2.png), none; background-attachment: fixed, scroll, scroll; background-position: top left, center, 30px 50px; background-repeat: repeat-x, repeat, no-repeat");
155 is(e.style.background, "", "should not have background shorthand (background-image too long)");
156 e.setAttribute("style", "background-clip: border-box, padding-box, border-box; background-origin: border-box, padding-box, padding-box; background-size: cover, auto, contain; background-color: blue; background-image: url(404.png), none, url(404-2.png); background-attachment: fixed, scroll; background-position: top left, center, 30px 50px; background-repeat: repeat-x, repeat, no-repeat");
157 is(e.style.background, "", "should not have background shorthand (background-attachment too short)");
158 e.setAttribute("style", "background-clip: border-box, padding-box, border-box; background-origin: border-box, padding-box, padding-box; background-size: cover, auto, contain; background-color: blue; background-image: url(404.png), none, url(404-2.png); background-attachment: fixed, scroll, scroll; background-position: top left, center, 30px 50px, bottom; background-repeat: repeat-x, repeat, no-repeat");
159 is(e.style.background, "", "should not have background shorthand (background-position too long)");
160 e.setAttribute("style", "background-clip: border-box, padding-box, border-box; background-origin: border-box, padding-box, padding-box; background-size: cover, auto, contain; background-color: blue; background-image: url(404.png), none, url(404-2.png); background-attachment: fixed, scroll, scroll; background-position: top left, center, 30px 50px; background-repeat: repeat-x, repeat");
161 is(e.style.background, "", "should not have background shorthand (background-repeat too short)");
162 e.setAttribute("style", "background-clip: border-box, padding-box, border-box; background-origin: border-box, padding-box, padding-box; background-size: cover, auto, contain, contain; background-color: blue; background-image: url(404.png), none, url(404-2.png); background-attachment: fixed, scroll, scroll; background-position: top left, center, 30px 50px; background-repeat: repeat-x, repeat, no-repeat");
163 is(e.style.background, "", "should not have background shorthand (background-size too long)");
165 // Check that we only serialize transition when the lists are the same length.
166 e.setAttribute("style", "transition-property: color, width; transition-duration: 1s, 200ms; transition-timing-function: ease-in, linear; transition-delay: 0s, 1s");
167 isnot(e.style.transition, "", "should have transition shorthand (lists same length)");
168 e.setAttribute("style", "transition-property: color, width, left; transition-duration: 1s, 200ms; transition-timing-function: ease-in, linear; transition-delay: 0s, 1s");
169 is(e.style.transition, "", "should not have transition shorthand (lists different lengths)");
170 e.setAttribute("style", "transition-property: all; transition-duration: 1s, 200ms; transition-timing-function: ease-in, linear; transition-delay: 0s, 1s");
171 is(e.style.transition, "", "should not have transition shorthand (lists different lengths)");
172 e.setAttribute("style", "transition-property: color, width; transition-duration: 1s, 200ms, 300ms; transition-timing-function: ease-in, linear; transition-delay: 0s, 1s");
173 is(e.style.transition, "", "should not have transition shorthand (lists different lengths)");
174 e.setAttribute("style", "transition-property: color, width; transition-duration: 1s, 200ms; transition-timing-function: ease-in, linear, ease-out; transition-delay: 0s, 1s");
175 is(e.style.transition, "", "should not have transition shorthand (lists different lengths)");
176 e.setAttribute("style", "transition-property: color, width; transition-duration: 1s, 200ms; transition-timing-function: ease-in, linear; transition-delay: 0s, 1s, 0s");
177 is(e.style.transition, "", "should not have transition shorthand (lists different lengths)");
179 e.setAttribute("style", "animation-name: bounce, roll; animation-duration: 1s, 200ms; animation-timing-function: ease-in, linear; animation-delay: 0s, 1s; animation-direction: normal, reverse; animation-fill-mode: forwards, backwards; animation-iteration-count: infinite, 2;");
180 isnot(e.style.animation, "", "should have animation shorthand (lists same length)");
181 e.setAttribute("style", "animation-name: bounce, roll, left; animation-duration: 1s, 200ms; animation-timing-function: ease-in, linear; animation-delay: 0s, 1s; animation-direction: normal, reverse; animation-fill-mode: forwards, backwards; animation-iteration-count: infinite, 2;");
182 is(e.style.animation, "", "should not have animation shorthand (lists different lengths)");
183 e.setAttribute("style", "animation-name: bounce; animation-duration: 1s, 200ms; animation-timing-function: ease-in, linear; animation-delay: 0s, 1s; animation-direction: normal, reverse; animation-fill-mode: forwards, backwards; animation-iteration-count: infinite, 2;");
184 is(e.style.animation, "", "should not have animation shorthand (lists different lengths)");
185 e.setAttribute("style", "animation-name: bounce, roll; animation-duration: 1s, 200ms, 300ms; animation-timing-function: ease-in, linear; animation-delay: 0s, 1s; animation-direction: normal, reverse; animation-fill-mode: forwards, backwards; animation-iteration-count: infinite, 2;");
186 is(e.style.animation, "", "should not have animation shorthand (lists different lengths)");
187 e.setAttribute("style", "animation-name: bounce, roll; animation-duration: 1s, 200ms; animation-timing-function: ease-in, linear, ease-out; animation-delay: 0s, 1s; animation-direction: normal, reverse; animation-fill-mode: forwards, backwards; animation-iteration-count: infinite, 2;");
188 is(e.style.animation, "", "should not have animation shorthand (lists different lengths)");
189 e.setAttribute("style", "animation-name: bounce, roll; animation-duration: 1s, 200ms; animation-timing-function: ease-in, linear; animation-delay: 0s, 1s, 0s; animation-direction: normal, reverse; animation-fill-mode: forwards, backwards; animation-iteration-count: infinite, 2;");
190 is(e.style.animation, "", "should not have animation shorthand (lists different lengths)");
191 e.setAttribute("style", "animation-name: bounce, roll; animation-duration: 1s, 200ms; animation-timing-function: ease-in, linear; animation-delay: 0s, 1s; animation-direction: normal; animation-fill-mode: forwards, backwards; animation-iteration-count: infinite, 2;");
192 is(e.style.animation, "", "should not have animation shorthand (lists different lengths)");
193 e.setAttribute("style", "animation-name: bounce, roll; animation-duration: 1s, 200ms; animation-timing-function: ease-in, linear; animation-delay: 0s, 1s; animation-direction: normal, reverse; animation-fill-mode: forwards, backwards, both; animation-iteration-count: infinite, 2;");
194 is(e.style.animation, "", "should not have animation shorthand (lists different lengths)");
195 e.setAttribute("style", "animation-name: bounce, roll; animation-duration: 1s, 200ms; animation-timing-function: ease-in, linear; animation-delay: 0s, 1s; animation-direction: normal, reverse; animation-fill-mode: forwards, backwards; animation-iteration-count: infinite, 2, 1;");
196 is(e.style.animation, "", "should not have animation shorthand (lists different lengths)");
198 // Check that the 'border' shorthand resets 'border-image' and
199 // '-moz-border-*-colors', but that other 'border-*' shorthands don't
200 // (bug 482692).
201 e.setAttribute("style", 'border-image: url("foo.png") 5 5 5 5 / 5 5 5 5 / 5 5 5 5 repeat repeat; border-left: medium solid green');
202 is(e.style.cssText,
203 'border-image: url("foo.png") 5 5 5 5 / 5 5 5 5 / 5 5 5 5 repeat repeat; border-left: medium solid green;',
204 "border-left does NOT reset border-image");
205 e.setAttribute("style", 'border-image: url("foo.png") 5 5 5 5; border: medium solid green');
206 is(e.style.cssText,
207 'border: medium solid green;',
208 "border DOES reset border-image");
209 e.setAttribute("style", '-moz-border-left-colors: fuchsia blue; border-left: medium solid green');
210 is(e.style.cssText,
211 '-moz-border-left-colors: fuchsia blue; border-left: medium solid green;',
212 "border-left does NOT reset -moz-border-left-colors");
213 e.setAttribute("style", '-moz-border-left-colors: fuchsia blue; border: medium solid green');
214 is(e.style.cssText,
215 'border: medium solid green;',
216 "border DOES reset -moz-border-left-colors");
218 </script>
219 </pre>
220 </body>
221 </html>