4 <script src="../../http/tests/inspector/inspector-test.js"></script>
5 <script src="../../http/tests/inspector/elements-test.js"></script>
13 InspectorTest.runTestSuite([
14 function initFormattedStyle(next)
16 function callback(styles)
19 InspectorTest.addResult("empty styles");
23 formattedStyle = styles.matchedCSSRules[1].style;
27 function nodeCallback(node)
29 WebInspector.cssModel.getMatchedStylesAsync(node.id, undefined, false, false, callback);
31 InspectorTest.selectNodeWithId("formatted", nodeCallback);
34 function testFormattedInsertStart(next)
36 formattedStyle.insertPropertyAt(0, "firstProperty", "firstValue", dumpFormattedAndCallNext.bind(null, next));
39 function testFormattedRemoveStart(next)
41 formattedStyle.allProperties[0].setText("", true, true, dumpFormattedAndCallNext.bind(null, next));
44 function testFormattedInsertMiddle(next)
46 formattedStyle.insertPropertyAt(1, "middleProperty", "middleValue", dumpFormattedAndCallNext.bind(null, next));
49 function testFormattedRemoveMiddle(next)
51 formattedStyle.allProperties[1].setText("", true, true, dumpFormattedAndCallNext.bind(null, next));
54 function testFormattedInsertEnd(next)
56 formattedStyle.insertPropertyAt(3, "endProperty", "endValue", dumpFormattedAndCallNext.bind(null, next));
59 function testFormattedRemoveEnd(next)
61 formattedStyle.allProperties[3].setText("", true, true, dumpFormattedAndCallNext.bind(null, next));
64 function testFormattedDisableStart(next)
66 formattedStyle.allProperties[0].setDisabled(true, dumpFormattedAndCallNext.bind(null, next));
69 function testFormattedDisableEnd(next)
71 formattedStyle.allProperties[2].setDisabled(true, dumpFormattedAndCallNext.bind(null, next));
74 function testFormattedDisableMiddle(next)
76 formattedStyle.allProperties[1].setDisabled(true, dumpFormattedAndCallNext.bind(null, next));
79 function testFormattedInsert1(next)
81 formattedStyle.insertPropertyAt(0, "propA", "valA", dumpFormattedAndCallNext.bind(null, next));
84 function testFormattedInsert2(next)
86 formattedStyle.insertPropertyAt(2, "propB", "valB", dumpFormattedAndCallNext.bind(null, next));
89 function testFormattedInsert3(next)
91 formattedStyle.insertPropertyAt(5, "propC", "valC", dumpFormattedAndCallNext.bind(null, next));
94 function testFormattedEnableStart(next)
96 formattedStyle.allProperties[1].setDisabled(false, dumpFormattedAndCallNext.bind(null, next));
99 function testFormattedEnableEnd(next)
101 formattedStyle.allProperties[4].setDisabled(false, dumpFormattedAndCallNext.bind(null, next));
104 function testFormattedEnableMiddle(next)
106 formattedStyle.allProperties[3].setDisabled(false, dumpFormattedAndCallNext.bind(null, next));
109 function initUnformattedStyle(next)
111 function callback(styles)
114 InspectorTest.addResult("empty styles");
118 unformattedStyle = styles.matchedCSSRules[1].style;
122 function nodeCallback(node)
124 WebInspector.cssModel.getMatchedStylesAsync(node.id, undefined, false, false, callback);
126 InspectorTest.selectNodeWithId("unformatted", nodeCallback);
129 function testUnformattedInsertStart(next)
131 unformattedStyle.insertPropertyAt(0, "firstProperty", "firstValue", dumpUnformattedAndCallNext.bind(null, next));
134 function testUnformattedRemoveStart(next)
136 unformattedStyle.allProperties[0].setText("", true, true, dumpUnformattedAndCallNext.bind(null, next));
139 function testUnformattedInsertMiddle(next)
141 unformattedStyle.insertPropertyAt(1, "middleProperty", "middleValue", dumpUnformattedAndCallNext.bind(null, next));
144 function testUnformattedRemoveMiddle(next)
146 unformattedStyle.allProperties[1].setText("", true, true, dumpUnformattedAndCallNext.bind(null, next));
149 function testUnformattedInsertEnd(next)
151 unformattedStyle.insertPropertyAt(3, "endProperty", "endValue", dumpUnformattedAndCallNext.bind(null, next));
154 function testUnformattedRemoveEnd(next)
156 unformattedStyle.allProperties[3].setText("", true, true, dumpUnformattedAndCallNext.bind(null, next));
159 function testUnformattedDisableStart(next)
161 unformattedStyle.allProperties[0].setDisabled(true, dumpUnformattedAndCallNext.bind(null, next));
164 function testUnformattedDisableEnd(next)
166 unformattedStyle.allProperties[2].setDisabled(true, dumpUnformattedAndCallNext.bind(null, next));
169 function testUnformattedDisableMiddle(next)
171 unformattedStyle.allProperties[1].setDisabled(true, dumpUnformattedAndCallNext.bind(null, next));
174 function testUnformattedEnableStart(next)
176 unformattedStyle.allProperties[0].setDisabled(false, dumpUnformattedAndCallNext.bind(null, next));
179 function testUnformattedEnableEnd(next)
181 unformattedStyle.allProperties[2].setDisabled(false, dumpUnformattedAndCallNext.bind(null, next));
184 function testUnformattedEnableMiddle(next)
186 unformattedStyle.allProperties[1].setDisabled(false, dumpUnformattedAndCallNext.bind(null, next));
192 function dumpFormattedAndCallNext(next, style)
195 InspectorTest.addResult("error: empty style");
196 InspectorTest.completeTest();
199 formattedStyle = style;
205 function dumpUnformattedAndCallNext(next, style)
208 InspectorTest.addResult("error: empty style");
209 InspectorTest.completeTest();
212 unformattedStyle = style;
218 function dumpStyle(style)
222 InspectorTest.addResult("raw cssText:");
223 InspectorTest.addResult("{" + style.cssText + "}");
236 #unformatted {property1:value1;property2:value2;property3:value3;}
241 <body id="mainBody" onload="runTest()">
243 Tests that InspectorCSSAgent formats the CSS style text based on the CSS model modifications.
245 <div id="formatted">Formatted</div>
246 <div id="unformatted">Unformatted</div>