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

Side by Side Diff: LayoutTests/http/tests/inspector-protocol/css-protocol-test.js

Issue 1211813002: DevTools: allow injecting CSS rules without breaking styles sidebar. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review comments addressed. Created 5 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | LayoutTests/http/tests/inspector-protocol/resources/protocol-test.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 function initialize_cssTest() 1 function initialize_cssTest()
2 { 2 {
3 3
4 InspectorTest.dumpStyleSheetText = function(styleSheetId, callback) 4 InspectorTest.dumpStyleSheetText = function(styleSheetId, callback)
5 { 5 {
6 InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheetId: styl eSheetId }, onStyleSheetText); 6 InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheetId: styl eSheetId }, onStyleSheetText);
7 function onStyleSheetText(result) 7 function onStyleSheetText(result)
8 { 8 {
9 InspectorTest.log("==== Style sheet text ===="); 9 InspectorTest.log("==== Style sheet text ====");
10 InspectorTest.log(result.text); 10 InspectorTest.log(result.text);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 selectorLine += ", "; 85 selectorLine += ", ";
86 var matching = matchingSelectors.indexOf(i) !== -1; 86 var matching = matchingSelectors.indexOf(i) !== -1;
87 if (matching) 87 if (matching)
88 selectorLine += "*"; 88 selectorLine += "*";
89 selectorLine += selectors[i].value; 89 selectorLine += selectors[i].value;
90 if (matching) 90 if (matching)
91 selectorLine += "*"; 91 selectorLine += "*";
92 } 92 }
93 selectorLine += " {"; 93 selectorLine += " {";
94 selectorLine += " " + rule.origin; 94 selectorLine += " " + rule.origin;
95 if (!rule.style.styleSheetId)
96 selectorLine += " readonly";
95 indentLog(baseIndent, selectorLine); 97 indentLog(baseIndent, selectorLine);
96 InspectorTest.dumpStyle(rule.style, baseIndent); 98 InspectorTest.dumpStyle(rule.style, baseIndent);
97 indentLog(baseIndent, "}"); 99 indentLog(baseIndent, "}");
98 }; 100 };
99 101
100 InspectorTest.dumpStyle = function(style, baseIndent) 102 InspectorTest.dumpStyle = function(style, baseIndent)
101 { 103 {
102 if (!style) 104 if (!style)
103 return; 105 return;
104 var cssProperties = style.cssProperties; 106 var cssProperties = style.cssProperties;
105 for (var i = 0; i < cssProperties.length; ++i) { 107 for (var i = 0; i < cssProperties.length; ++i) {
106 var cssProperty = cssProperties[i]; 108 var cssProperty = cssProperties[i];
107 var propertyLine = cssProperty.name + ": " + cssProperty.value + ";"; 109 var propertyLine = cssProperty.name + ": " + cssProperty.value + ";";
108 indentLog(baseIndent + 4, propertyLine); 110 indentLog(baseIndent + 4, propertyLine);
109 } 111 }
110 } 112 }
111 113
112 InspectorTest.displayName = function(url) 114 InspectorTest.displayName = function(url)
113 { 115 {
114 return url.substr(url.lastIndexOf("/") + 1); 116 return url.substr(url.lastIndexOf("/") + 1);
115 }; 117 };
116 118
117 InspectorTest.loadAndDumpMatchingRulesForNode = function(nodeId, callback) 119 InspectorTest.loadAndDumpMatchingRulesForNode = function(nodeId, callback, omitL og)
118 { 120 {
119 InspectorTest.sendCommandOrDie("CSS.getMatchedStylesForNode", { "nodeId": no deId }, matchingRulesLoaded); 121 InspectorTest.sendCommandOrDie("CSS.getMatchedStylesForNode", { "nodeId": no deId }, matchingRulesLoaded);
120 122
121 function matchingRulesLoaded(result) 123 function matchingRulesLoaded(result)
122 { 124 {
123 InspectorTest.log("Dumping matched rules: "); 125 if (!omitLog)
126 InspectorTest.log("Dumping matched rules: ");
124 dumpRuleMatches(result.matchedCSSRules); 127 dumpRuleMatches(result.matchedCSSRules);
125 InspectorTest.log("Dumping inherited rules: "); 128 if (!omitLog)
129 InspectorTest.log("Dumping inherited rules: ");
126 for (var inheritedEntry of result.inherited) { 130 for (var inheritedEntry of result.inherited) {
127 InspectorTest.dumpStyle(inheritedEntry.inlineStyle); 131 InspectorTest.dumpStyle(inheritedEntry.inlineStyle);
128 dumpRuleMatches(inheritedEntry.matchedCSSRules); 132 dumpRuleMatches(inheritedEntry.matchedCSSRules);
129 } 133 }
130 callback(); 134 callback();
131 } 135 }
132 136
133 function dumpRuleMatches(ruleMatches) 137 function dumpRuleMatches(ruleMatches)
134 { 138 {
135 for (var ruleMatch of ruleMatches) { 139 for (var ruleMatch of ruleMatches) {
136 var origin = ruleMatch.rule.origin; 140 var origin = ruleMatch.rule.origin;
137 if (origin !== "inspector" && origin !== "regular") 141 if (origin !== "inspector" && origin !== "regular")
138 continue; 142 continue;
139 InspectorTest.dumpRuleMatch(ruleMatch); 143 InspectorTest.dumpRuleMatch(ruleMatch);
140 } 144 }
141 } 145 }
142 } 146 }
143 147
144 InspectorTest.loadAndDumpMatchingRules = function(documentNodeId, selector, call back) 148 InspectorTest.loadAndDumpMatchingRules = function(documentNodeId, selector, call back, omitLog)
145 { 149 {
146 InspectorTest.requestNodeId(documentNodeId, selector, nodeIdLoaded); 150 InspectorTest.requestNodeId(documentNodeId, selector, nodeIdLoaded);
147 151
148 function nodeIdLoaded(nodeId) 152 function nodeIdLoaded(nodeId)
149 { 153 {
150 InspectorTest.loadAndDumpMatchingRulesForNode(nodeId, callback); 154 InspectorTest.loadAndDumpMatchingRulesForNode(nodeId, callback, omitLog) ;
151 } 155 }
152 } 156 }
153 157
154 } 158 }
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/inspector-protocol/resources/protocol-test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698