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

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

Issue 441873010: DevTools: [SSP] Implement adding new rule in user stylesheet (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: minor changes Created 6 years, 4 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
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 21 matching lines...) Expand all
32 InspectorTest.completeTest(); 32 InspectorTest.completeTest();
33 return; 33 return;
34 } 34 }
35 InspectorTest.log("Expected protocol error: " + message.error.message); 35 InspectorTest.log("Expected protocol error: " + message.error.message);
36 callback(); 36 callback();
37 } 37 }
38 } 38 }
39 39
40 InspectorTest.setPropertyText = updateStyleSheetRange.bind(null, "CSS.setPropert yText"); 40 InspectorTest.setPropertyText = updateStyleSheetRange.bind(null, "CSS.setPropert yText");
41 InspectorTest.setRuleSelector = updateStyleSheetRange.bind(null, "CSS.setRuleSel ector"); 41 InspectorTest.setRuleSelector = updateStyleSheetRange.bind(null, "CSS.setRuleSel ector");
42 InspectorTest.addRule = updateStyleSheetRange.bind(null, "CSS.addRule");
42 43
43 InspectorTest.requestMainFrameId = function(callback) 44 InspectorTest.requestMainFrameId = function(callback)
44 { 45 {
45 InspectorTest.sendCommandOrDie("Page.enable", {}, pageEnabled); 46 InspectorTest.sendCommandOrDie("Page.enable", {}, pageEnabled);
46 47
47 function pageEnabled() 48 function pageEnabled()
48 { 49 {
49 InspectorTest.sendCommandOrDie("Page.getResourceTree", {}, resourceTreeL oaded); 50 InspectorTest.sendCommandOrDie("Page.getResourceTree", {}, resourceTreeL oaded);
50 } 51 }
51 52
(...skipping 26 matching lines...) Expand all
78 InspectorTest.dumpRuleMatch = function(ruleMatch) 79 InspectorTest.dumpRuleMatch = function(ruleMatch)
79 { 80 {
80 function log(indent, string) 81 function log(indent, string)
81 { 82 {
82 var indentString = Array(indent+1).join(" "); 83 var indentString = Array(indent+1).join(" ");
83 InspectorTest.log(indentString + string); 84 InspectorTest.log(indentString + string);
84 } 85 }
85 86
86 var rule = ruleMatch.rule; 87 var rule = ruleMatch.rule;
87 var matchingSelectors = ruleMatch.matchingSelectors; 88 var matchingSelectors = ruleMatch.matchingSelectors;
89 var media = rule.media || [];
90 var mediaLine = "";
91 for (var i = 0; i < media.length; ++i)
92 mediaLine += (i > 0 ? " " : "") + media[i].text;
93 var baseIndent = 0;
94 if (mediaLine.length) {
95 log(baseIndent, "@media " + mediaLine);
96 baseIndent += 4;
97 }
88 var selectorLine = ""; 98 var selectorLine = "";
89 var selectors = rule.selectorList.selectors; 99 var selectors = rule.selectorList.selectors;
90 for (var i = 0; i < selectors.length; ++i) { 100 for (var i = 0; i < selectors.length; ++i) {
91 if (i > 0) 101 if (i > 0)
92 selectorLine += ", "; 102 selectorLine += ", ";
93 var matching = matchingSelectors.indexOf(i) !== -1; 103 var matching = matchingSelectors.indexOf(i) !== -1;
94 if (matching) 104 if (matching)
95 selectorLine += "*"; 105 selectorLine += "*";
96 selectorLine += selectors[i].value; 106 selectorLine += selectors[i].value;
97 if (matching) 107 if (matching)
98 selectorLine += "*"; 108 selectorLine += "*";
99 } 109 }
100 selectorLine += " {"; 110 selectorLine += " {";
101 selectorLine += " " + rule.origin; 111 selectorLine += " " + rule.origin;
102 log(0, selectorLine); 112 log(baseIndent, selectorLine);
103 var style = rule.style; 113 var style = rule.style;
104 var cssProperties = style.cssProperties; 114 var cssProperties = style.cssProperties;
105 for (var i = 0; i < cssProperties.length; ++i) { 115 for (var i = 0; i < cssProperties.length; ++i) {
106 var cssProperty = cssProperties[i]; 116 var cssProperty = cssProperties[i];
107 var propertyLine = cssProperty.name + ": " + cssProperty.value + ";"; 117 var propertyLine = cssProperty.name + ": " + cssProperty.value + ";";
108 log(4, propertyLine); 118 log(baseIndent + 4, propertyLine);
109 } 119 }
110 log(0, "}"); 120 log(baseIndent, "}");
111 }; 121 };
112 122
113 InspectorTest.displayName = function(url) 123 InspectorTest.displayName = function(url)
114 { 124 {
115 return url.substr(url.lastIndexOf("/") + 1); 125 return url.substr(url.lastIndexOf("/") + 1);
116 }; 126 };
117 127
118 InspectorTest.loadAndDumpMatchingRulesForNode = function(nodeId, callback) 128 InspectorTest.loadAndDumpMatchingRulesForNode = function(nodeId, callback)
119 { 129 {
120 InspectorTest.sendCommandOrDie("CSS.getMatchedStylesForNode", { "nodeId": no deId }, matchingRulesLoaded); 130 InspectorTest.sendCommandOrDie("CSS.getMatchedStylesForNode", { "nodeId": no deId }, matchingRulesLoaded);
(...skipping 17 matching lines...) Expand all
138 { 148 {
139 InspectorTest.requestNodeId(documentNodeId, selector, nodeIdLoaded); 149 InspectorTest.requestNodeId(documentNodeId, selector, nodeIdLoaded);
140 150
141 function nodeIdLoaded(nodeId) 151 function nodeIdLoaded(nodeId)
142 { 152 {
143 InspectorTest.loadAndDumpMatchingRulesForNode(nodeId, callback); 153 InspectorTest.loadAndDumpMatchingRulesForNode(nodeId, callback);
144 } 154 }
145 } 155 }
146 156
147 } 157 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698