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

Side by Side Diff: third_party/WebKit/LayoutTests/inspector-protocol/css/css-set-style-text.html

Issue 1694433003: DevTools: [CSS] Add CSS.setMultipleStyleTexts command to CSS domain (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: %zu is not cross-platform - do not use. Created 4 years, 10 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
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <link rel="stylesheet" href="resources/set-style-text.css"/> 3 <link rel="stylesheet" href="resources/set-style-text.css"/>
4 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto r-protocol-test.js"></script> 4 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto r-protocol-test.js"></script>
5 <script type="text/javascript" src="../../http/tests/inspector-protocol/css-prot ocol-test.js"></script> 5 <script type="text/javascript" src="../../http/tests/inspector-protocol/css-prot ocol-test.js"></script>
6 <script type="text/javascript" src="../../http/tests/inspector-protocol/dom-prot ocol-test.js"></script> 6 <script type="text/javascript" src="../../http/tests/inspector-protocol/dom-prot ocol-test.js"></script>
7 <script type="text/javascript"> 7 <script type="text/javascript">
8 8
9 function removeRule() 9 function removeRule()
10 { 10 {
11 document.styleSheets[0].removeRule(0); 11 document.styleSheets[0].removeRule(0);
12 } 12 }
13 13
14 function test() 14 function test()
15 { 15 {
16 var setStyleText; 16 var setStyleTexts;
17 var verifyProtocolError; 17 var verifyProtocolError;
18 var dumpStyleSheet;
19 var documentNodeId; 18 var documentNodeId;
20 var styleSheetId; 19 var styleSheetId;
21 20
22 InspectorTest.requestDocumentNodeId(onDocumentNodeId); 21 InspectorTest.requestDocumentNodeId(onDocumentNodeId);
23 22
24 function onDocumentNodeId(nodeId) 23 function onDocumentNodeId(nodeId)
25 { 24 {
26 documentNodeId = nodeId; 25 documentNodeId = nodeId;
27 InspectorTest.eventHandler["CSS.styleSheetAdded"] = styleSheetAdded; 26 InspectorTest.eventHandler["CSS.styleSheetAdded"] = styleSheetAdded;
28 InspectorTest.sendCommandOrDie("CSS.enable", {}); 27 InspectorTest.sendCommandOrDie("CSS.enable", {});
29 } 28 }
30 29
31 function styleSheetAdded(result) 30 function styleSheetAdded(result)
32 { 31 {
33 styleSheetId = result.params.header.styleSheetId; 32 styleSheetId = result.params.header.styleSheetId;
34 setStyleText = InspectorTest.setStyleText.bind(InspectorTest, styleSheet Id, false); 33 setStyleTexts = InspectorTest.setStyleTexts.bind(InspectorTest, styleShe etId, false);
35 verifyProtocolError = InspectorTest.setStyleText.bind(InspectorTest, sty leSheetId, true); 34 verifyProtocolError = InspectorTest.setStyleTexts.bind(InspectorTest, st yleSheetId, true);
36 dumpStyleSheet = InspectorTest.dumpStyleSheetText.bind(null, styleSheetI d);
37 InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheetId: styleSheetId }, onInitialStyleSheetText); 35 InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheetId: styleSheetId }, onInitialStyleSheetText);
38 } 36 }
39 37
40 function dumpAndCall(next) 38 function dumpAndCall(next)
41 { 39 {
42 return InspectorTest.loadAndDumpMatchingRules.bind(InspectorTest, docume ntNodeId, "#test", next); 40 return InspectorTest.loadAndDumpMatchingRules.bind(InspectorTest, docume ntNodeId, "#test", next);
43 } 41 }
44 42
45 function dumpUndoAndNext(next) 43 function dumpUndoAndNext(next)
46 { 44 {
47 return InspectorTest.loadAndDumpMatchingRules.bind(InspectorTest, docume ntNodeId, "#test", InspectorTest.undoAndNext(next)); 45 return InspectorTest.loadAndDumpMatchingRules.bind(InspectorTest, docume ntNodeId, "#test", InspectorTest.undoAndNext(next));
48 } 46 }
49 47
50 function onInitialStyleSheetText(result) 48 function onInitialStyleSheetText(result)
51 { 49 {
52 InspectorTest.log("==== Initial style sheet text ===="); 50 InspectorTest.log("==== Initial style sheet text ====");
53 InspectorTest.log(result.text); 51 InspectorTest.log(result.text);
54 InspectorTest.runTestSuite(testSuite); 52 InspectorTest.runTestSuite(testSuite);
55 } 53 }
56 54
57 var testSuite = [ 55 var testSuite = [
58 function testBasicSetStyle(next) 56 function testBasicSetStyle(next)
59 { 57 {
60 setStyleText({ 58 setStyleTexts([{
61 styleSheetId: styleSheetId, 59 styleSheetId: styleSheetId,
62 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0 }, 60 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0 },
63 text: "\n content: 'EDITED';\n", 61 text: "\n content: 'EDITED';\n",
64 }, dumpUndoAndNext(next)); 62 }], dumpUndoAndNext(next));
65 }, 63 },
66 64
67 function testSetStyleTwice(next) 65 function testSetStyleTwice(next)
68 { 66 {
69 setStyleText({ 67 setStyleTexts([{
70 styleSheetId: styleSheetId, 68 styleSheetId: styleSheetId,
71 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0 }, 69 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0 },
72 text: "\n color: green;\n padding: 0 4px;\n cursor: poi nter\n", 70 text: "\n color: green;\n padding: 0 4px;\n cursor: poi nter\n",
73 }, dumpAndCall(step2)); 71 }], dumpAndCall(step2));
74 72
75 function step2() 73 function step2()
76 { 74 {
77 setStyleText({ 75 setStyleTexts([{
78 styleSheetId: styleSheetId, 76 styleSheetId: styleSheetId,
79 range: { startLine: 0, startColumn: 7, endLine: 4, endColumn : 0 }, 77 range: { startLine: 0, startColumn: 7, endLine: 4, endColumn : 0 },
80 text: "\n color: green;\n padding: 0 6px;\n cursor: pointer\n", 78 text: "\n color: green;\n padding: 0 6px;\n cursor: pointer\n",
81 }, dumpAndCall(step3)); 79 }], dumpAndCall(step3));
82 } 80 }
83 81
84 function step3() 82 function step3()
85 { 83 {
86 setStyleText({ 84 setStyleTexts([{
87 styleSheetId: styleSheetId, 85 styleSheetId: styleSheetId,
88 range: { startLine: 0, startColumn: 7, endLine: 4, endColumn : 0 }, 86 range: { startLine: 0, startColumn: 7, endLine: 4, endColumn : 0 },
89 text: "\n color: green;\n padding: 0 8px;\n cursor: pointer\n", 87 text: "\n color: green;\n padding: 0 8px;\n cursor: pointer\n",
90 }, dumpUndoAndNext(next)); 88 }], dumpUndoAndNext(next));
91 } 89 }
92 }, 90 },
93 91
94 function testSetStylePoorContent(next) 92 function testSetStylePoorContent(next)
95 { 93 {
96 verifyProtocolError({ 94 verifyProtocolError([{
97 styleSheetId: styleSheetId, 95 styleSheetId: styleSheetId,
98 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0 }, 96 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0 },
99 text: "}", 97 text: "}",
100 }, dumpUndoAndNext(next)); 98 }], dumpUndoAndNext(next));
101 }, 99 },
102 100
103 function testSetStyleInMedia(next) 101 function testSetStyleInMedia(next)
104 { 102 {
105 setStyleText({ 103 setStyleTexts([{
106 styleSheetId: styleSheetId, 104 styleSheetId: styleSheetId,
107 range: { startLine: 13, startColumn: 11, endLine: 15, endColumn: 4 }, 105 range: { startLine: 13, startColumn: 11, endLine: 15, endColumn: 4 },
108 text: "\n content: 'EDITED';\n color: red;\n /** foo */\n ", 106 text: "\n content: 'EDITED';\n color: red;\n /** foo */\n ",
109 }, dumpUndoAndNext(next)); 107 }], dumpUndoAndNext(next));
110 }, 108 },
111 109
112 function testDeleteStyleBody(next) 110 function testDeleteStyleBody(next)
113 { 111 {
114 setStyleText({ 112 setStyleTexts([{
115 styleSheetId: styleSheetId, 113 styleSheetId: styleSheetId,
116 range: { startLine: 13, startColumn: 11, endLine: 15, endColumn: 4 }, 114 range: { startLine: 13, startColumn: 11, endLine: 15, endColumn: 4 },
117 text: "", 115 text: "",
118 }, dumpUndoAndNext(next)); 116 }], dumpUndoAndNext(next));
119 }, 117 },
120 118
121 function testSetStylePoorRange(next) 119 function testSetStylePoorRange(next)
122 { 120 {
123 verifyProtocolError({ 121 verifyProtocolError([{
124 styleSheetId: styleSheetId, 122 styleSheetId: styleSheetId,
125 range: { startLine: 11, startColumn: 11, endLine: 15, endColumn: 4 }, 123 range: { startLine: 11, startColumn: 11, endLine: 15, endColumn: 4 },
126 text: "\n content: 'EDITED';\n", 124 text: "\n content: 'EDITED';\n",
127 }, dumpUndoAndNext(next)); 125 }], dumpUndoAndNext(next));
128 }, 126 },
129 127
130 function testSetStyleOpenComment(next) 128 function testSetStyleOpenComment(next)
131 { 129 {
132 verifyProtocolError({ 130 verifyProtocolError([{
133 styleSheetId: styleSheetId, 131 styleSheetId: styleSheetId,
134 range: { startLine: 13, startColumn: 11, endLine: 15, endColumn: 4 }, 132 range: { startLine: 13, startColumn: 11, endLine: 15, endColumn: 4 },
135 text: "\n content: 'EDITED'/* ;\n", 133 text: "\n content: 'EDITED'/* ;\n",
136 }, dumpUndoAndNext(next)); 134 }], dumpUndoAndNext(next));
137 }, 135 },
138 136
139 function testSetStyleOfRemovedRule(next) 137 function testSetStyleOfRemovedRule(next)
140 { 138 {
141 InspectorTest.sendCommandOrDie("Runtime.evaluate", {expression: "rem oveRule()"}, mutateRule); 139 InspectorTest.sendCommandOrDie("Runtime.evaluate", {expression: "rem oveRule()"}, mutateRule);
142 function mutateRule() 140 function mutateRule()
143 { 141 {
144 setStyleText({ 142 setStyleTexts([{
145 styleSheetId: styleSheetId, 143 styleSheetId: styleSheetId,
146 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn : 0 }, 144 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn : 0 },
147 text: "\n content: 'EDITED';\n", 145 text: "\n content: 'EDITED';\n",
148 }, dumpUndoAndNext(next)); 146 }], dumpUndoAndNext(next));
149 } 147 }
150 } 148 }
151 ]; 149 ];
152 } 150 }
153 151
154 </script> 152 </script>
155 </head> 153 </head>
156 <body onload="runTest();"> 154 <body onload="runTest();">
157 <p>The test verifies functionality of protocol method CSS.setStyleText.</p> 155 <p>The test verifies functionality of protocol method CSS.setStyleTexts.</p>
158 <article id="test"></article> 156 <article id="test"></article>
159 </body> 157 </body>
160 </html> 158 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698