Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / elements / styles-4 / styles-update-links.html
blobd478a50e26f74936bc285982f3ce39e02cee6bd4
1 <html>
2 <head>
3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../../http/tests/inspector/elements-test.js"></script>
5 <style>
6 #pseudo::after {
7 pseudo-property: "12";
8 color: red;
11 #pseudo::after {
12 border: 1px solid black;
15 #pseudo::before {
16 color: blue;
18 </style>
19 <script>
21 function test()
23 function flattenRuleRanges(rule)
25 var ranges = [];
26 var medias = rule.media || [];
27 for (var i = 0; i < medias.length; ++i) {
28 var media = medias[i];
29 if (!media.range)
30 continue;
31 ranges.push({
32 range: media.range,
33 name: "media #" + i
34 });
36 for (var i = 0; i < rule.selectors.length; ++i) {
37 var selector = rule.selectors[i];
38 if (!selector.range)
39 continue;
40 ranges.push({
41 range: selector.range,
42 name: "selector #" + i
43 });
45 if (rule.style.range) {
46 ranges.push({
47 range: rule.style.range,
48 name: "style range"
49 });
51 var properties = rule.style.allProperties;
52 for (var i = 0; i < properties.length; ++i) {
53 var property = properties[i];
54 if (!property.range)
55 continue;
56 ranges.push({
57 range: property.range,
58 name: "property >>" + property.text + "<<"
59 });
61 return ranges;
64 function compareRuleRanges(lazyRule, originalRule)
66 if (lazyRule.selectorText !== originalRule.selectorText) {
67 InspectorTest.addResult("Error: rule selectors are not equal: " + lazyRule.selectorText + " != " + originalRule.selectorText);
68 return false;
70 var flattenLazy = flattenRuleRanges(lazyRule);
71 var flattenOriginal = flattenRuleRanges(originalRule);
72 if (flattenLazy.length !== flattenOriginal.length) {
73 InspectorTest.addResult("Error: rule range amount is not equal: " + flattenLazy.length + " != " + flattenOriginal.length);
74 return false
76 for (var i = 0; i < flattenLazy.length; ++i) {
77 var lazyRange = flattenLazy[i];
78 var originalRange = flattenOriginal[i];
79 if (lazyRange.name !== originalRange.name) {
80 InspectorTest.addResult("Error: rule names are not equal: " + lazyRange.name + " != " + originalRange.name);
81 return false;
83 if (!lazyRange.range.equal(originalRange.range)) {
84 InspectorTest.addResult("Error: ranges '" + lazyRange.name + "' are not equal: " + lazyRange.range.toString() + " != " + originalRange.range.toString());
85 return false;
88 InspectorTest.addResult(flattenLazy.length + " rule ranges are equal.");
89 return true;
92 function validateRuleRanges(selector, rules, callback)
94 InspectorTest.selectNodeAndWaitForStyles("other", onOtherSelected);
96 function onOtherSelected()
98 InspectorTest.selectNodeAndWaitForStyles(selector, onContainerSelected);
101 function onContainerSelected()
103 var fetchedRules = getMatchedRules();
104 if (fetchedRules.length !== rules.length) {
105 InspectorTest.addResult(String.sprintf("Error: rules sizes are not equal! Expected: %d, actual: %d", fetchedRules.length, rules.length));
106 InspectorTest.completeTest();
107 return;
109 for (var i = 0; i < fetchedRules.length; ++i) {
110 if (!compareRuleRanges(rules[i], fetchedRules[i])) {
111 InspectorTest.completeTest();
112 return;
115 callback();
119 function getMatchedRules()
121 var rules = [];
122 for (var block of WebInspector.panels.elements.sidebarPanes.styles._sectionBlocks) {
123 for (var section of block.sections) {
124 var rule = section.rule();
125 if (rule)
126 rules.push(rule);
129 return rules;
132 InspectorTest.runTestSuite([
133 function selectInitialNode(next)
135 InspectorTest.selectNodeAndWaitForStyles("container", next);
138 function testInsertProperty(next)
140 InspectorTest.dumpSelectedElementStyles(true, false, true);
141 var treeItem = InspectorTest.getMatchedStylePropertyTreeItem("color");
142 var treeElement = treeItem.section().addNewBlankProperty(1);
143 InspectorTest.waitForStyleApplied(onPropertyInserted);
144 treeElement.applyStyleText("PROPERTY: INSERTED;", true);
146 function onPropertyInserted()
148 InspectorTest.addResult("\n\n#### AFTER PROPERTY INSERTION ####\n\n");
149 InspectorTest.dumpSelectedElementStyles(true, false, true);
150 var rules = getMatchedRules();
151 validateRuleRanges("container", rules, next);
155 function testEditSelector(next)
157 var section = WebInspector.panels.elements.sidebarPanes.styles._sectionBlocks[0].sections[3];
158 section.startEditingSelector();
159 section._selectorElement.textContent = ".should-change, .INSERTED-OTHER-SELECTOR";
160 InspectorTest.waitForSelectorCommitted(onSelectorEdited);
161 section._selectorElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
163 function onSelectorEdited()
165 InspectorTest.addResult("\n\n#### AFTER SELECTOR EDIT ####\n\n");
166 InspectorTest.dumpSelectedElementStyles(true, false, true);
167 var rules = getMatchedRules();
168 validateRuleRanges("container", rules, next);
172 function testDisableProperty(next)
174 var treeItem = InspectorTest.getMatchedStylePropertyTreeItem("border");
175 InspectorTest.waitForStyleApplied(onPropertyDisabled);
176 treeItem._toggleEnabled({ target: { checked: false }, consume: function() { } });
178 function onPropertyDisabled()
180 InspectorTest.addResult("\n\n#### AFTER PROPERTY DISABLED ####\n\n");
181 InspectorTest.dumpSelectedElementStyles(true, false, true);
182 var rules = getMatchedRules();
183 validateRuleRanges("container", rules, next);
187 function selectNodeWithPseudoElements(next)
189 InspectorTest.selectNodeAndWaitForStyles("pseudo", next);
192 function testPseudoSectionPropertyEdit(next)
194 var treeItem = InspectorTest.getMatchedStylePropertyTreeItem("pseudo-property");
195 var treeElement = treeItem.section().addNewBlankProperty(1);
196 InspectorTest.waitForStyleApplied(onPropertyInserted);
197 treeElement.applyStyleText("PROPERTY: INSERTED;", true);
199 function onPropertyInserted()
201 InspectorTest.addResult("\n\n#### AFTER PROPERTY INSERTED ####\n\n");
202 InspectorTest.dumpSelectedElementStyles(true, false, true);
203 var rules = getMatchedRules();
204 validateRuleRanges("pseudo", rules, next);
209 </script>
210 <link rel="stylesheet" href="../styles/resources/styles-update-links-2.css"></link>
211 <link rel="stylesheet" href="../styles/resources/styles-update-links.css"></link>
212 </head>
214 <body onload="runTest()">
216 Tests that removal of property following its disabling works.
217 </p>
219 <div id="container" class="left-intact should-change">
220 Red text here.
221 </div>
223 <div id="other"></div>
225 <section id="pseudo"></div>
227 </body>
228 </html>