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

Side by Side Diff: LayoutTests/inspector/elements/styles/get-set-stylesheet-text.html

Issue 1158883003: DevTools: shard inspector/elements tests for faster execution. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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
OLDNEW
(Empty)
1 <html>
2 <head>
3
4 <style>
5
6 /* An inline stylesheet */
7 body.mainpage {
8 text-decoration: none;
9 }
10 </style>
11
12 <link rel="stylesheet" href="resources/get-set-stylesheet-text.css">
13
14 <script src="../../../http/tests/inspector/inspector-test.js"></script>
15 <script src="../../../http/tests/inspector/elements-test.js"></script>
16 <script>
17
18 function test()
19 {
20 var foundStyleSheetHeader;
21 var foundStyleSheetText;
22
23 findStyleSheet();
24
25 function findStyleSheet()
26 {
27 var styleSheetHeaders = InspectorTest.cssModel.styleSheetHeaders();
28 for (var i = 0; i < styleSheetHeaders.length; ++i) {
29 styleSheetHeader = styleSheetHeaders[i];
30 if (styleSheetHeader.sourceURL.indexOf("get-set-stylesheet-text.css" ) >= 0) {
31 foundStyleSheetHeader = styleSheetHeader;
32 foundStyleSheetHeader.requestContent(callback);
33 }
34 if (!foundStyleSheetHeader)
35 InspectorTest.cssModel.addEventListener(WebInspector.CSSStyleMod el.Events.StyleSheetAdded, styleSheetAdded);
36 }
37
38 function callback(content)
39 {
40 foundStyleSheetText = content;
41 InspectorTest.runTestSuite([ testSetText, testNewElementStyles ]);
42 }
43
44 function styleSheetAdded()
45 {
46 InspectorTest.cssModel.removeEventListener(WebInspector.CSSStyleMode l.Events.StyleSheetAdded, styleSheetAdded);
47 findStyleSheet();
48 }
49 }
50
51 function testSetText(next)
52 {
53 function callback(error)
54 {
55 if (error) {
56 InspectorTest.addResult("Failed to set stylesheet text: " + erro r);
57 return;
58 }
59 }
60
61 InspectorTest.addResult("=== Original stylesheet text: ===");
62 InspectorTest.addResult(foundStyleSheetText);
63 InspectorTest.cssModel.addEventListener(WebInspector.CSSStyleModel.Event s.StyleSheetChanged, next, this);
64 InspectorTest.cssModel.setStyleSheetText(foundStyleSheetHeader.id, "h1 { COLOR: Red; }", true, callback);
65 }
66
67 function testNewElementStyles()
68 {
69 function callback(error, matchedCSSRules)
70 {
71 if (error) {
72 InspectorTest.addResult("error: " + error);
73 return;
74 }
75
76 InspectorTest.addResult("=== Matched rules for h1 after setText() == =");
77 dumpMatchesArray(matchedCSSRules);
78 InspectorTest.completeTest();
79 }
80
81 function nodeCallback(node)
82 {
83 InspectorTest.CSSAgent.getMatchedStylesForNode(node.id, true, true, callback);
84 }
85
86 InspectorTest.selectNodeWithId("inspected", nodeCallback);
87 }
88
89
90 // Data dumping
91
92 function dumpMatchesArray(rules)
93 {
94 if (!rules)
95 return;
96 for (var i = 0; i < rules.length; ++i)
97 dumpRuleOrStyle(rules[i].rule);
98 }
99
100 function dumpRuleOrStyle(ruleOrStyle)
101 {
102 if (!ruleOrStyle)
103 return;
104 var isRule = !!(ruleOrStyle.style);
105 var style = isRule ? ruleOrStyle.style : ruleOrStyle;
106 InspectorTest.addResult("");
107 InspectorTest.addResult(isRule ? "rule" : "style");
108 InspectorTest.addResult((isRule ? (ruleOrStyle.selectorList.text + ": [" + ruleOrStyle.origin + "]") : "raw style"));
109 InspectorTest.dumpStyle(style);
110 }
111 }
112 </script>
113 </head>
114
115 <body onload="runTest()">
116 <p>
117 Tests that WebInspector.CSSStyleSheet methods work as expected.
118 </p>
119 <h1 id="inspected">Inspect Me</h1>
120 </body>
121 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698