Chromium Code Reviews| Index: LayoutTests/inspector-protocol/css/css-protocol-test.js |
| diff --git a/LayoutTests/inspector-protocol/css/css-protocol-test.js b/LayoutTests/inspector-protocol/css/css-protocol-test.js |
| index 4c83d841aadaf89e46d520de7d9e0efa8c6ec57f..78021126bf1f5ca7a221bd5a1382721b8bd9d608 100644 |
| --- a/LayoutTests/inspector-protocol/css/css-protocol-test.js |
| +++ b/LayoutTests/inspector-protocol/css/css-protocol-test.js |
| @@ -41,13 +41,15 @@ InspectorTest.requestNodeId = function(selector, callback) |
| } |
| }; |
| +function logIndent(string, indent) |
| +{ |
| + indent = indent || 0; |
| + var indentString = Array(indent+1).join(" "); |
| + InspectorTest.log(indentString + string); |
| +} |
| + |
| InspectorTest.dumpRuleMatch = function(ruleMatch) |
| { |
| - function log(indent, string) |
| - { |
| - var indentString = Array(indent+1).join(" "); |
| - InspectorTest.log(indentString + string); |
| - } |
| var rule = ruleMatch.rule; |
| var matchingSelectors = ruleMatch.matchingSelectors; |
| @@ -65,17 +67,47 @@ InspectorTest.dumpRuleMatch = function(ruleMatch) |
| } |
| selectorLine += " {"; |
| selectorLine += " " + rule.origin + (rule.sourceURL ? " (" + InspectorTest.displayName(rule.sourceURL) + ")" : ""); |
| - log(0, selectorLine); |
| + logIndent(selectorLine, 0); |
| var style = rule.style; |
| var cssProperties = style.cssProperties; |
| for (var i = 0; i < cssProperties.length; ++i) { |
| var cssProperty = cssProperties[i]; |
| var propertyLine = cssProperty.name + ": " + cssProperty.value + ";"; |
| - log(4, propertyLine); |
| + logIndent(propertyLine, 4); |
| } |
| - log(0, "}"); |
| + logIndent("}"); |
| }; |
| +function dumpProperties(properties, indent) |
|
vsevik
2014/03/13 10:44:51
We could probably reuse it on dumpRuleMatch
|
| +{ |
| + for (var i = 0; i < properties.length; ++i) { |
| + var property = properties[i]; |
| + if (!property.range) |
| + continue; |
| + var propertyText = property.name + ": " + property.value + (property.important ? " !important" : ""); |
| + if (property.disabled) |
| + propertyText = "/* " + propertyText + " */"; |
| + logIndent(propertyText, indent); |
| + } |
| +} |
| + |
| +InspectorTest.dumpRule = function(rule) |
| +{ |
| + function selectorValues(selector) |
| + { |
| + return selector.value; |
| + } |
| + var selector = rule.selectorList.selectors.map(selectorValues).join(", "); |
| + logIndent(selector + " {"); |
| + dumpProperties(rule.style.cssProperties, 4); |
| + logIndent("}"); |
| +} |
| + |
| +InspectorTest.dumpStyle = function(style) |
| +{ |
| + dumpProperties(style.cssProperties, 0); |
| +} |
| + |
| InspectorTest.displayName = function(url) |
| { |
| return url.substr(url.lastIndexOf("/") + 1); |
| @@ -105,4 +137,4 @@ InspectorTest.loadAndDumpMatchingRules = function(nodeId, callback) |
| } |
| } |
| -} |
| +} |