Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / elements / styles-4 / styles-formatting.html
blobd930097d9632af806bbeb7aa5ab6df261599af0a
1 <html>
2 <head>
4 <script src="../../../http/tests/inspector/inspector-test.js"></script>
5 <script src="../../../http/tests/inspector/elements-test.js"></script>
6 <script>
8 function test()
10 var formattedStyle;
11 var unformattedStyle;
13 InspectorTest.runTestSuite([
14 function initFormattedStyle(next)
16 function callback(styles)
18 if (!styles) {
19 InspectorTest.addResult("empty styles");
20 InspectorTest.completeTest();
21 return;
24 formattedStyle = styles.matchedCSSRules[1].style;
25 next();
28 function nodeCallback(node)
30 InspectorTest.cssModel.matchedStylesPromise(node.id, false, false).then(callback);
32 InspectorTest.selectNodeWithId("formatted", nodeCallback);
35 function testFormattedInsertStart(next)
37 formattedStyle.insertPropertyAt(0, "firstProperty", "rgba(1, 2, 3, 0)", dumpFormattedAndCallNext.bind(null, next));
40 function testFormattedRemoveStart(next)
42 formattedStyle.allProperties[0].setText("", true, true)
43 .then(dumpFormattedAndCallNext.bind(null, next));
46 function testFormattedInsertMiddle(next)
48 formattedStyle.insertPropertyAt(1, "middleProperty", "middleValue /* comment */", dumpFormattedAndCallNext.bind(null, next));
51 function testFormattedRemoveMiddle(next)
53 formattedStyle.allProperties[1].setText("", true, true)
54 .then(dumpFormattedAndCallNext.bind(null, next));
57 function testFormattedInsertEnd(next)
59 formattedStyle.insertPropertyAt(3, "endProperty", "endValue", dumpFormattedAndCallNext.bind(null, next));
62 function testFormattedRemoveEnd(next)
64 formattedStyle.allProperties[3].setText("", true, true)
65 .then(dumpFormattedAndCallNext.bind(null, next));
68 function testFormattedDisableStart(next)
70 formattedStyle.allProperties[0].setDisabled(true)
71 .then(dumpFormattedAndCallNext.bind(null, next));
74 function testFormattedDisableEnd(next)
76 formattedStyle.allProperties[2].setDisabled(true)
77 .then(dumpFormattedAndCallNext.bind(null, next));
80 function testFormattedDisableMiddle(next)
82 formattedStyle.allProperties[1].setDisabled(true)
83 .then(dumpFormattedAndCallNext.bind(null, next));
86 function testFormattedInsert1(next)
88 formattedStyle.insertPropertyAt(0, "propA", "valA", dumpFormattedAndCallNext.bind(null, next));
91 function testFormattedInsert2(next)
93 formattedStyle.insertPropertyAt(2, "propB", "valB", dumpFormattedAndCallNext.bind(null, next));
96 function testFormattedInsert3(next)
98 formattedStyle.insertPropertyAt(5, "propC", "valC", dumpFormattedAndCallNext.bind(null, next));
101 function testFormattedEnableStart(next)
103 formattedStyle.allProperties[1].setDisabled(false)
104 .then(dumpFormattedAndCallNext.bind(null, next));
107 function testFormattedEnableEnd(next)
109 formattedStyle.allProperties[4].setDisabled(false)
110 .then(dumpFormattedAndCallNext.bind(null, next));
113 function testFormattedEnableMiddle(next)
115 formattedStyle.allProperties[3].setDisabled(false)
116 .then(dumpFormattedAndCallNext.bind(null, next));
119 function testFormattedWithMeta(next)
121 formattedStyle.insertPropertyAt(0, "-webkit-animation", "linear", dumpFormattedAndCallNext.bind(null, next));
124 function testFormattedWithMetaValue(next)
126 formattedStyle.insertPropertyAt(1, "unicode-bidi", "webkit-isolate", dumpFormattedAndCallNext.bind(null, next));
129 function testFormattedWithAtoms(next)
131 formattedStyle.insertPropertyAt(0, "border-left", "1px solid rgb(1,1,1)", dumpFormattedAndCallNext.bind(null, next));
134 function initUnformattedStyle(next)
136 function callback(styles)
138 if (!styles) {
139 InspectorTest.addResult("empty styles");
140 return;
143 unformattedStyle = styles.matchedCSSRules[1].style;
144 next();
147 function nodeCallback(node)
149 InspectorTest.cssModel.matchedStylesPromise(node.id, false, false).then(callback);
151 InspectorTest.selectNodeWithId("unformatted", nodeCallback);
154 function testUnformattedInsertStart(next)
156 unformattedStyle.insertPropertyAt(0, "firstProperty", "firstValue", dumpUnformattedAndCallNext.bind(null, next));
159 function testUnformattedRemoveStart(next)
161 unformattedStyle.allProperties[0].setText("", true, true)
162 .then(dumpUnformattedAndCallNext.bind(null, next));
165 function testUnformattedInsertMiddle(next)
167 unformattedStyle.insertPropertyAt(1, "middleProperty", "middleValue", dumpUnformattedAndCallNext.bind(null, next));
170 function testUnformattedRemoveMiddle(next)
172 unformattedStyle.allProperties[1].setText("", true, true)
173 .then(dumpUnformattedAndCallNext.bind(null, next));
176 function testUnformattedInsertEnd(next)
178 unformattedStyle.insertPropertyAt(3, "endProperty", "endValue", dumpUnformattedAndCallNext.bind(null, next));
181 function testUnformattedRemoveEnd(next)
183 unformattedStyle.allProperties[3].setText("", true, true)
184 .then(dumpUnformattedAndCallNext.bind(null, next));
187 function testUnformattedDisableStart(next)
189 unformattedStyle.allProperties[0].setDisabled(true)
190 .then(dumpUnformattedAndCallNext.bind(null, next));
193 function testUnformattedDisableEnd(next)
195 unformattedStyle.allProperties[2].setDisabled(true)
196 .then(dumpUnformattedAndCallNext.bind(null, next));
199 function testUnformattedDisableMiddle(next)
201 unformattedStyle.allProperties[1].setDisabled(true)
202 .then(dumpUnformattedAndCallNext.bind(null, next));
205 function testUnformattedEnableStart(next)
207 unformattedStyle.allProperties[0].setDisabled(false)
208 .then(dumpUnformattedAndCallNext.bind(null, next));
211 function testUnformattedEnableEnd(next)
213 unformattedStyle.allProperties[2].setDisabled(false)
214 .then(dumpUnformattedAndCallNext.bind(null, next));
217 function testUnformattedEnableMiddle(next)
219 unformattedStyle.allProperties[1].setDisabled(false)
220 .then(dumpUnformattedAndCallNext.bind(null, next));
224 // Data dumping
226 function dumpFormattedAndCallNext(next, success)
228 if (!success) {
229 InspectorTest.addResult("error: operation failed.");
230 InspectorTest.completeTest();
231 return;
234 dumpStyle(formattedStyle);
235 if (next)
236 next();
239 function dumpUnformattedAndCallNext(next, success)
241 if (!success) {
242 InspectorTest.addResult("error: operation failed.");
243 InspectorTest.completeTest();
244 return;
247 dumpStyle(unformattedStyle);
248 if (next)
249 next();
252 function dumpStyle(style)
254 if (!style)
255 return;
256 InspectorTest.addResult("raw cssText:");
257 InspectorTest.addResult("{" + style.cssText + "}");
260 </script>
262 <style>
264 #formatted {
265 property1: value1;
266 property2: value2;
267 property3: value3
270 #unformatted {property1:value1;property2:value2;property3:value3;}
272 </style>
273 </head>
275 <body id="mainBody" onload="runTest()">
277 Tests that InspectorCSSAgent formats the CSS style text based on the CSS model modifications.
278 </p>
279 <div id="formatted">Formatted</div>
280 <div id="unformatted">Unformatted</div>
281 </body>
282 </html>