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

Side by Side 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: Fixed test Created 6 years, 9 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
(Empty)
1 function initialize_cssTest()
2 {
3
4 InspectorTest.requestMainFrameId = function(callback)
5 {
6 InspectorTest.sendCommandOrDie("Page.enable", {}, pageEnabled);
7
8 function pageEnabled()
9 {
10 InspectorTest.sendCommandOrDie("Page.getResourceTree", {}, resourceTreeL oaded);
11 }
12
13 function resourceTreeLoaded(payload)
14 {
15 callback(payload.frameTree.frame.id);
16 }
17 };
18
19 InspectorTest.requestDocumentNodeId = function(callback)
20 {
21 InspectorTest.sendCommandOrDie("DOM.getDocument", {}, onGotDocument);
22
23 function onGotDocument(result)
24 {
25 callback(result.root.nodeId);
26 }
27 };
28
29 InspectorTest.requestNodeId = function(selector, callback)
lushnikov 2014/03/04 08:22:35 Not really sure these DOM-domain and Page-domain c
30 {
31 InspectorTest.requestDocumentNodeId(onGotDocumentNodeId);
32
33 function onGotDocumentNodeId(documentNodeId)
34 {
35 InspectorTest.sendCommandOrDie("DOM.querySelector", { "nodeId": document NodeId , "selector": selector }, onGotNode);
36 }
37
38 function onGotNode(result)
39 {
40 callback(result.nodeId);
41 }
42 };
43
44 InspectorTest.dumpRuleMatch = function(ruleMatch)
45 {
46 function log(indent, string)
47 {
48 var indentString = Array(indent+1).join(" ");
49 InspectorTest.log(indentString + string);
50 }
51
52 var rule = ruleMatch.rule;
53 var matchingSelectors = ruleMatch.matchingSelectors;
54 var selectorLine = "";
55 var selectors = rule.selectorList.selectors;
56 for (var i = 0; i < selectors.length; ++i) {
57 if (i > 0)
58 selectorLine += ", ";
59 var matching = matchingSelectors.indexOf(i) !== -1;
60 if (matching)
61 selectorLine += "*";
62 selectorLine += selectors[i].value;
63 if (matching)
64 selectorLine += "*";
65 }
66 selectorLine += " {";
67 selectorLine += " " + rule.origin + (rule.sourceURL ? " (" + InspectorTes t.displayName(rule.sourceURL) + ")" : "");
68 log(0, selectorLine);
69 var style = rule.style;
70 var cssProperties = style.cssProperties;
71 for (var i = 0; i < cssProperties.length; ++i) {
72 var cssProperty = cssProperties[i];
73 var propertyLine = cssProperty.name + ": " + cssProperty.value + ";";
74 log(4, propertyLine);
75 }
76 log(0, "}");
77 };
78
79 InspectorTest.displayName = function(url)
80 {
81 return url.substr(url.lastIndexOf("/") + 1);
82 };
83
84 InspectorTest.loadAndDumpMatchingRules = function(nodeId, callback)
85 {
86 InspectorTest.requestNodeId(nodeId, nodeIdLoaded);
87
88 function nodeIdLoaded(nodeId)
89 {
90 InspectorTest.sendCommandOrDie("CSS.getMatchedStylesForNode", { "nodeId" : nodeId }, matchingRulesLoaded);
91 }
92
93 function matchingRulesLoaded(result)
94 {
95 InspectorTest.log("Dumping matched rules: ");
96 var ruleMatches = result.matchedCSSRules;
97 for (var i = 0; i < ruleMatches.length; ++i) {
98 var ruleMatch = ruleMatches[i];
99 var origin = ruleMatch.rule.origin;
100 if (origin !== "inspector" && origin !== "regular")
101 continue;
102 InspectorTest.dumpRuleMatch(ruleMatch);
103 }
104 callback();
105 }
106 }
107
108 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698