Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Unified Diff: LayoutTests/inspector-protocol/css/css-protocol-test.js

Issue 177963004: DevTools: Split creating inspector stylesheet and adding a new rule into stylesheet in protocol. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Comments addressed Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
new file mode 100644
index 0000000000000000000000000000000000000000..6b8f65e505e4dc2cb811630653344fbc1a99ae21
--- /dev/null
+++ b/LayoutTests/inspector-protocol/css/css-protocol-test.js
@@ -0,0 +1,68 @@
+function initialize_cssTest()
+{
+
+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;
+ var selectorLine = "";
+ var selectors = rule.selectorList.selectors;
+ for (var i = 0; i < selectors.length; ++i) {
+ if (i > 0)
+ selectorLine += ", ";
+ var matching = matchingSelectors.indexOf(i) !== -1;
+ if (matching)
+ selectorLine += "*";
+ selectorLine += selectors[i].value;
+ if (matching)
+ selectorLine += "*";
+ }
+ selectorLine += " {";
+ selectorLine += " " + rule.origin + (rule.sourceURL ? " (" + InspectorTest.displayName(rule.sourceURL) + ")" : "");
+ log(0, selectorLine);
+ 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);
+ }
+ log(0, "}");
+};
+
+InspectorTest.displayName = function(url)
+{
+ return url.substr(url.lastIndexOf("/") + 1);
+};
+
+InspectorTest.loadAndDumpMatchingRules = function(nodeId, callback)
+{
+ InspectorTest.requestNodeId(nodeId, nodeIdLoaded);
+
+ function nodeIdLoaded(nodeId)
+ {
+ InspectorTest.sendCommandOrDie("CSS.getMatchedStylesForNode", { "nodeId": nodeId }, matchingRulesLoaded);
+ }
+
+ function matchingRulesLoaded(result)
+ {
+ InspectorTest.log("Dumping matched rules: ");
+ var ruleMatches = result.matchedCSSRules;
+ for (var i = 0; i < ruleMatches.length; ++i) {
+ var ruleMatch = ruleMatches[i];
+ var origin = ruleMatch.rule.origin;
+ if (origin !== "inspector" && origin !== "regular")
+ continue;
+ InspectorTest.dumpRuleMatch(ruleMatch);
+ }
+ callback();
+ }
+}
+
+}

Powered by Google App Engine
This is Rietveld 408576698