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");
20 InspectorTest
.completeTest();
24 formattedStyle
= styles
.matchedCSSRules
[1].style
;
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
)
139 InspectorTest
.addResult("empty styles");
143 unformattedStyle
= styles
.matchedCSSRules
[1].style
;
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
));
226 function dumpFormattedAndCallNext(next
, success
)
229 InspectorTest
.addResult("error: operation failed.");
230 InspectorTest
.completeTest();
234 dumpStyle(formattedStyle
);
239 function dumpUnformattedAndCallNext(next
, success
)
242 InspectorTest
.addResult("error: operation failed.");
243 InspectorTest
.completeTest();
247 dumpStyle(unformattedStyle
);
252 function dumpStyle(style
)
256 InspectorTest
.addResult("raw cssText:");
257 InspectorTest
.addResult("{" + style
.cssText
+ "}");
270 #unformatted {property1:value1;property2:value2;property3:value3;}
275 <body id=
"mainBody" onload=
"runTest()">
277 Tests that InspectorCSSAgent formats the CSS style text based on the CSS model modifications.
279 <div id=
"formatted">Formatted
</div>
280 <div id=
"unformatted">Unformatted
</div>