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

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

Issue 1182483004: DevTools: [CSS] getMatchedStylesForNode should return styles inherited through shadow boundary (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebaseline Created 5 years, 6 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/inspector-protocol/css/css-add-rule-expected.txt » ('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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 { 50 {
51 InspectorTest.sendCommandOrDie("Page.getResourceTree", {}, resourceTreeL oaded); 51 InspectorTest.sendCommandOrDie("Page.getResourceTree", {}, resourceTreeL oaded);
52 } 52 }
53 53
54 function resourceTreeLoaded(payload) 54 function resourceTreeLoaded(payload)
55 { 55 {
56 callback(payload.frameTree.frame.id); 56 callback(payload.frameTree.frame.id);
57 } 57 }
58 }; 58 };
59 59
60 function indentLog(indent, string)
61 {
62 var indentString = Array(indent+1).join(" ");
63 InspectorTest.log(indentString + string);
64 }
65
60 InspectorTest.dumpRuleMatch = function(ruleMatch) 66 InspectorTest.dumpRuleMatch = function(ruleMatch)
61 { 67 {
62 function log(indent, string)
63 {
64 var indentString = Array(indent+1).join(" ");
65 InspectorTest.log(indentString + string);
66 }
67 68
68 var rule = ruleMatch.rule; 69 var rule = ruleMatch.rule;
69 var matchingSelectors = ruleMatch.matchingSelectors; 70 var matchingSelectors = ruleMatch.matchingSelectors;
70 var media = rule.media || []; 71 var media = rule.media || [];
71 var mediaLine = ""; 72 var mediaLine = "";
72 for (var i = 0; i < media.length; ++i) 73 for (var i = 0; i < media.length; ++i)
73 mediaLine += (i > 0 ? " " : "") + media[i].text; 74 mediaLine += (i > 0 ? " " : "") + media[i].text;
74 var baseIndent = 0; 75 var baseIndent = 0;
75 if (mediaLine.length) { 76 if (mediaLine.length) {
76 log(baseIndent, "@media " + mediaLine); 77 indentLog(baseIndent, "@media " + mediaLine);
77 baseIndent += 4; 78 baseIndent += 4;
78 } 79 }
79 var selectorLine = ""; 80 var selectorLine = "";
80 var selectors = rule.selectorList.selectors; 81 var selectors = rule.selectorList.selectors;
81 for (var i = 0; i < selectors.length; ++i) { 82 for (var i = 0; i < selectors.length; ++i) {
82 if (i > 0) 83 if (i > 0)
83 selectorLine += ", "; 84 selectorLine += ", ";
84 var matching = matchingSelectors.indexOf(i) !== -1; 85 var matching = matchingSelectors.indexOf(i) !== -1;
85 if (matching) 86 if (matching)
86 selectorLine += "*"; 87 selectorLine += "*";
87 selectorLine += selectors[i].value; 88 selectorLine += selectors[i].value;
88 if (matching) 89 if (matching)
89 selectorLine += "*"; 90 selectorLine += "*";
90 } 91 }
91 selectorLine += " {"; 92 selectorLine += " {";
92 selectorLine += " " + rule.origin; 93 selectorLine += " " + rule.origin;
93 log(baseIndent, selectorLine); 94 indentLog(baseIndent, selectorLine);
94 var style = rule.style; 95 InspectorTest.dumpStyle(rule.style, baseIndent);
96 indentLog(baseIndent, "}");
97 };
98
99 InspectorTest.dumpStyle = function(style, baseIndent)
100 {
101 if (!style)
102 return;
95 var cssProperties = style.cssProperties; 103 var cssProperties = style.cssProperties;
96 for (var i = 0; i < cssProperties.length; ++i) { 104 for (var i = 0; i < cssProperties.length; ++i) {
97 var cssProperty = cssProperties[i]; 105 var cssProperty = cssProperties[i];
98 var propertyLine = cssProperty.name + ": " + cssProperty.value + ";"; 106 var propertyLine = cssProperty.name + ": " + cssProperty.value + ";";
99 log(baseIndent + 4, propertyLine); 107 indentLog(baseIndent + 4, propertyLine);
100 } 108 }
101 log(baseIndent, "}"); 109 }
102 };
103 110
104 InspectorTest.displayName = function(url) 111 InspectorTest.displayName = function(url)
105 { 112 {
106 return url.substr(url.lastIndexOf("/") + 1); 113 return url.substr(url.lastIndexOf("/") + 1);
107 }; 114 };
108 115
109 InspectorTest.loadAndDumpMatchingRulesForNode = function(nodeId, callback) 116 InspectorTest.loadAndDumpMatchingRulesForNode = function(nodeId, callback)
110 { 117 {
111 InspectorTest.sendCommandOrDie("CSS.getMatchedStylesForNode", { "nodeId": no deId }, matchingRulesLoaded); 118 InspectorTest.sendCommandOrDie("CSS.getMatchedStylesForNode", { "nodeId": no deId }, matchingRulesLoaded);
112 119
113 function matchingRulesLoaded(result) 120 function matchingRulesLoaded(result)
114 { 121 {
115 InspectorTest.log("Dumping matched rules: "); 122 InspectorTest.log("Dumping matched rules: ");
116 var ruleMatches = result.matchedCSSRules; 123 dumpRuleMatches(result.matchedCSSRules);
117 for (var i = 0; i < ruleMatches.length; ++i) { 124 InspectorTest.log("Dumping inherited rules: ");
118 var ruleMatch = ruleMatches[i]; 125 for (var inheritedEntry of result.inherited) {
126 InspectorTest.dumpStyle(inheritedEntry.inlineStyle);
127 dumpRuleMatches(inheritedEntry.matchedCSSRules);
128 }
129 callback();
130 }
131
132 function dumpRuleMatches(ruleMatches)
133 {
134 for (var ruleMatch of ruleMatches) {
119 var origin = ruleMatch.rule.origin; 135 var origin = ruleMatch.rule.origin;
120 if (origin !== "inspector" && origin !== "regular") 136 if (origin !== "inspector" && origin !== "regular")
121 continue; 137 continue;
122 InspectorTest.dumpRuleMatch(ruleMatch); 138 InspectorTest.dumpRuleMatch(ruleMatch);
123 } 139 }
124 callback();
125 } 140 }
126 } 141 }
127 142
128 InspectorTest.loadAndDumpMatchingRules = function(documentNodeId, selector, call back) 143 InspectorTest.loadAndDumpMatchingRules = function(documentNodeId, selector, call back)
129 { 144 {
130 InspectorTest.requestNodeId(documentNodeId, selector, nodeIdLoaded); 145 InspectorTest.requestNodeId(documentNodeId, selector, nodeIdLoaded);
131 146
132 function nodeIdLoaded(nodeId) 147 function nodeIdLoaded(nodeId)
133 { 148 {
134 InspectorTest.loadAndDumpMatchingRulesForNode(nodeId, callback); 149 InspectorTest.loadAndDumpMatchingRulesForNode(nodeId, callback);
135 } 150 }
136 } 151 }
137 152
138 } 153 }
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/inspector-protocol/css/css-add-rule-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698