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

Side by Side Diff: LayoutTests/inspector/elements/styles/styles-new-API.html

Issue 198053011: DevTools: [CSS] remove StyleId and RuleId types from protocol.json (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: address @apavlov comments Created 6 years, 8 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 <html> 1 <html>
2 <head> 2 <head>
3 3
4 <link rel="stylesheet" href="resources/styles-new-API.css"> 4 <link rel="stylesheet" href="resources/styles-new-API.css">
5 5
6 <script src="../../../http/tests/inspector/inspector-test.js"></script> 6 <script src="../../../http/tests/inspector/inspector-test.js"></script>
7 <script src="../../../http/tests/inspector/elements-test.js"></script> 7 <script src="../../../http/tests/inspector/elements-test.js"></script>
8 <script src="styles-test.js"></script> 8 <script src="styles-test.js"></script>
9 <script> 9 <script>
10 10
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 InspectorTest.addResult("=== Stylesheet-for-inline-style modific ation result ==="); 143 InspectorTest.addResult("=== Stylesheet-for-inline-style modific ation result ===");
144 InspectorTest.addResult(error); 144 InspectorTest.addResult(error);
145 next(); 145 next();
146 } 146 }
147 147
148 function textCallback(inlineStyle, error, result) 148 function textCallback(inlineStyle, error, result)
149 { 149 {
150 InspectorTest.addResult(""); 150 InspectorTest.addResult("");
151 InspectorTest.addResult("=== Stylesheet-for-inline-style text == ="); 151 InspectorTest.addResult("=== Stylesheet-for-inline-style text == =");
152 InspectorTest.addResult(result); 152 InspectorTest.addResult(result);
153 CSSAgent.setStyleSheetText(inlineStyle.styleId.styleSheetId, "", setTextCallback); 153 CSSAgent.setStyleSheetText(inlineStyle.styleSheetId, "", setText Callback);
154 } 154 }
155 155
156 function callback(error, inlineStyle, attributesStyle) 156 function callback(error, inlineStyle, attributesStyle)
157 { 157 {
158 if (error) { 158 if (error) {
159 InspectorTest.addResult("error: " + error); 159 InspectorTest.addResult("error: " + error);
160 return; 160 return;
161 } 161 }
162 InspectorTest.addResult(""); 162 InspectorTest.addResult("");
163 InspectorTest.addResult("=== Attributes style for table ==="); 163 InspectorTest.addResult("=== Attributes style for table ===");
164 InspectorTest.dumpStyle(attributesStyle); 164 InspectorTest.dumpStyle(attributesStyle);
165 CSSAgent.getStyleSheetText(inlineStyle.styleId.styleSheetId, tex tCallback.bind(this, inlineStyle)); 165 CSSAgent.getStyleSheetText(inlineStyle.styleSheetId, textCallbac k.bind(this, inlineStyle));
166 } 166 }
167 167
168 function nodeCallback(node) 168 function nodeCallback(node)
169 { 169 {
170 CSSAgent.getInlineStylesForNode(node.id, callback); 170 CSSAgent.getInlineStylesForNode(node.id, callback);
171 } 171 }
172 InspectorTest.nodeWithId("thetable", nodeCallback); 172 InspectorTest.nodeWithId("thetable", nodeCallback);
173 }, 173 },
174 174
175 function test_styleSheets(next) 175 function test_styleSheets(next)
176 { 176 {
177 var newStyleSheetText = 177 var newStyleSheetText =
178 "body.mainpage {" + 178 "body.mainpage {" +
179 " text-decoration: strikethrough;" + 179 " text-decoration: strikethrough;" +
180 " badproperty: 2badvalue2;" + 180 " badproperty: 2badvalue2;" +
181 "}" + 181 "}" +
182 "body {" + 182 "body {" +
183 " text-align: justify;" + 183 " text-align: justify;" +
184 "}"; 184 "}";
185 185
186 function didSetStyleText(error, style) 186 function didSetStyleText(error, style)
187 { 187 {
188 if (error) { 188 if (error) {
189 InspectorTest.addResult("error: " + error); 189 InspectorTest.addResult("error: " + error);
190 InspectorTest.completeTest(); 190 InspectorTest.completeTest();
191 return; 191 return;
192 } 192 }
193 InspectorTest.addResult(""); 193 InspectorTest.addResult("");
194 InspectorTest.addResult("=== After style text set ==="); 194 InspectorTest.addResult("=== After style text set ===");
195 loadAndDumpStyleSheet(style.styleId.styleSheetId, next); 195 loadAndDumpStyleSheet(style.styleSheetId, next);
196 } 196 }
197 197
198 function collapseToStart(range) 198 function collapseToStart(range)
199 { 199 {
200 return { 200 return {
201 startLine: range.startLine, 201 startLine: range.startLine,
202 startColumn: range.startColumn, 202 startColumn: range.startColumn,
203 endLine: range.startLine, 203 endLine: range.startLine,
204 endColumn: range.startColumn, 204 endColumn: range.startColumn,
205 }; 205 };
206 } 206 }
207 207
208 function setStyleText(rule) 208 function setStyleText(rule)
209 { 209 {
210 CSSAgent.setPropertyText(rule.style.styleId.styleSheetId, rule.s tyle.cssProperties[1].range, ""); 210 CSSAgent.setPropertyText(rule.style.styleSheetId, rule.style.css Properties[1].range, "");
211 CSSAgent.setPropertyText(rule.style.styleId.styleSheetId, rule.s tyle.cssProperties[0].range, ""); 211 CSSAgent.setPropertyText(rule.style.styleSheetId, rule.style.css Properties[0].range, "");
212 212
213 // This operation should not update the style as the new propert y text is not parsable. 213 // This operation should not update the style as the new propert y text is not parsable.
214 CSSAgent.setPropertyText(rule.style.styleId.styleSheetId, collap seToStart(rule.style.range), "zzz;"); 214 CSSAgent.setPropertyText(rule.style.styleSheetId, collapseToStar t(rule.style.range), "zzz;");
215 CSSAgent.setPropertyText(rule.style.styleId.styleSheetId, collap seToStart(rule.style.range), "color: white; background: black;", didSetStyleText ); 215 CSSAgent.setPropertyText(rule.style.styleSheetId, collapseToStar t(rule.style.range), "color: white; background: black;", didSetStyleText);
216 } 216 }
217 217
218 function didSetSelector(error, rule) 218 function didSetSelector(error, rule)
219 { 219 {
220 if (error) { 220 if (error) {
221 InspectorTest.addResult("error: " + error); 221 InspectorTest.addResult("error: " + error);
222 InspectorTest.completeTest(); 222 InspectorTest.completeTest();
223 return; 223 return;
224 } 224 }
225 InspectorTest.addResult(""); 225 InspectorTest.addResult("");
226 InspectorTest.addResult("=== After selector set ==="); 226 InspectorTest.addResult("=== After selector set ===");
227 loadAndDumpStyleSheet(rule.ruleId.styleSheetId, setStyleText.bin d(this, rule)); 227 loadAndDumpStyleSheet(rule.styleSheetId, setStyleText.bind(this, rule));
228 } 228 }
229 229
230 function setRuleSelector(rule) 230 function setRuleSelector(rule)
231 { 231 {
232 var orm = WebInspector.CSSRule.parsePayload(WebInspector.cssMode l, rule); 232 var orm = WebInspector.CSSRule.parsePayload(WebInspector.cssMode l, rule);
233 CSSAgent.setRuleSelector(orm.id.styleSheetId, orm.selectorRange, "html *, body[foo=\"bar\"]", didSetSelector); 233 CSSAgent.setRuleSelector(orm.styleSheetId, orm.selectorRange, "h tml *, body[foo=\"bar\"]", didSetSelector);
234 } 234 }
235 235
236 function onMatchedStylesForNode(error, matchedStyles) 236 function onMatchedStylesForNode(error, matchedStyles)
237 { 237 {
238 if (error) { 238 if (error) {
239 InspectorTest.addResult("error: " + error); 239 InspectorTest.addResult("error: " + error);
240 InspectorTest.completeTest(); 240 InspectorTest.completeTest();
241 return; 241 return;
242 } 242 }
243 for (var i = 0; i < matchedStyles.length; ++i) { 243 for (var i = 0; i < matchedStyles.length; ++i) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 } 297 }
298 CSSAgent.getMatchedStylesForNode(bodyId, false, false, didGetSty les); 298 CSSAgent.getMatchedStylesForNode(bodyId, false, false, didGetSty les);
299 } 299 }
300 300
301 function ruleAdded(error, rule) 301 function ruleAdded(error, rule)
302 { 302 {
303 if (error) { 303 if (error) {
304 InspectorTest.addResult("error: " + error); 304 InspectorTest.addResult("error: " + error);
305 return; 305 return;
306 } 306 }
307 CSSAgent.setPropertyText(rule.style.styleId.styleSheetId, { 307 CSSAgent.setPropertyText(rule.style.styleSheetId, {
308 startLine: rule.style.range.startLine, 308 startLine: rule.style.range.startLine,
309 startColumn: rule.style.range.startColumn, 309 startColumn: rule.style.range.startColumn,
310 endLine: rule.style.range.startLine, 310 endLine: rule.style.range.startLine,
311 endColumn: rule.style.range.startColumn 311 endColumn: rule.style.range.startColumn
312 }, "font-family: serif;", didSetStyleText); 312 }, "font-family: serif;", didSetStyleText);
313 } 313 }
314 314
315 function viaInspectorStyleSheetCreated(error, styleSheetId) 315 function viaInspectorStyleSheetCreated(error, styleSheetId)
316 { 316 {
317 if (error) { 317 if (error) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 // height : 100% ; 368 // height : 100% ;
369 // border: 1px solid; 369 // border: 1px solid;
370 // border-width: 2px; 370 // border-width: 2px;
371 // background-color : #33FF33; 371 // background-color : #33FF33;
372 // googles: abra; 372 // googles: abra;
373 // foo: .bar; 373 // foo: .bar;
374 // -moz-goog: 1***; 374 // -moz-goog: 1***;
375 // border-width: 0px; 375 // border-width: 0px;
376 // padding-top: 1px; [d] 376 // padding-top: 1px; [d]
377 377
378 var styleId = matchedCSSRules[1].rule.style.styleId;
379 var orm = WebInspector.CSSStyleDeclaration.parsePayload(WebInspe ctor.cssModel, matchedCSSRules[1].rule.style); 378 var orm = WebInspector.CSSStyleDeclaration.parsePayload(WebInspe ctor.cssModel, matchedCSSRules[1].rule.style);
380 orm.propertyAt(0).setDisabled(true, step1); 379 orm.propertyAt(0).setDisabled(true, step1);
381 380
382 function step1(orm) 381 function step1(orm)
383 { 382 {
384 orm.propertyAt(7).setDisabled(true, step2); 383 orm.propertyAt(7).setDisabled(true, step2);
385 } 384 }
386 385
387 function step2(orm) 386 function step2(orm)
388 { 387 {
389 CSSAgent.setPropertyText(orm.id.styleSheetId, orm.propertyAt (7).range.collapseToStart(), "font-size: 12px;", parseStylePayload.bind(null, st ep3)); 388 CSSAgent.setPropertyText(orm.styleSheetId, orm.propertyAt(7) .range.collapseToStart(), "font-size: 12px;", parseStylePayload.bind(null, step3 ));
390 } 389 }
391 390
392 function step3(orm) 391 function step3(orm)
393 { 392 {
394 CSSAgent.setPropertyText(orm.id.styleSheetId, orm.propertyAt (9).range.collapseToStart(), "font-size: 14px;", parseStylePayload.bind(null, st ep4)); 393 CSSAgent.setPropertyText(orm.styleSheetId, orm.propertyAt(9) .range.collapseToStart(), "font-size: 14px;", parseStylePayload.bind(null, step4 ));
395 } 394 }
396 395
397 function step4(orm) 396 function step4(orm)
398 { 397 {
399 orm.propertyAt(9).setDisabled(true, step5); 398 orm.propertyAt(9).setDisabled(true, step5);
400 } 399 }
401 400
402 function step5(orm) 401 function step5(orm)
403 { 402 {
404 CSSAgent.setPropertyText(orm.id.styleSheetId, orm.propertyAt (8).range, "border-width: 1px;", parseStylePayload.bind(null, step6)); 403 CSSAgent.setPropertyText(orm.styleSheetId, orm.propertyAt(8) .range, "border-width: 1px;", parseStylePayload.bind(null, step6));
405 } 404 }
406 405
407 function step6(orm) 406 function step6(orm)
408 { 407 {
409 orm.propertyAt(8).setDisabled(false, step7); 408 orm.propertyAt(8).setDisabled(false, step7);
410 } 409 }
411 410
412 function step7(orm) 411 function step7(orm)
413 { 412 {
414 CSSAgent.setPropertyText(orm.id.styleSheetId, orm.propertyAt (3).range, "", parseStylePayload.bind(null, step8)); 413 CSSAgent.setPropertyText(orm.styleSheetId, orm.propertyAt(3) .range, "", parseStylePayload.bind(null, step8));
415 } 414 }
416 415
417 function step8(orm) 416 function step8(orm)
418 { 417 {
419 orm.propertyAt(9).setDisabled(false, didDisableProperty); 418 orm.propertyAt(9).setDisabled(false, didDisableProperty);
420 } 419 }
421 420
422 // height : 100% ; [d] 421 // height : 100% ; [d]
423 // border: 1px solid; 422 // border: 1px solid;
424 // border-width: 2px; 423 // border-width: 2px;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 485
487 <body id="mainBody" class="main1 main2 mainpage" onload="runTest()" style="font- weight: normal; width: 85%; background-image: url(bar.png)"> 486 <body id="mainBody" class="main1 main2 mainpage" onload="runTest()" style="font- weight: normal; width: 85%; background-image: url(bar.png)">
488 <p> 487 <p>
489 Tests that InspectorCSSAgent API methods work as expected. 488 Tests that InspectorCSSAgent API methods work as expected.
490 </p> 489 </p>
491 <table width="50%" id="thetable"> 490 <table width="50%" id="thetable">
492 </table> 491 </table>
493 <h1 id="toggle">H1</h1> 492 <h1 id="toggle">H1</h1>
494 </body> 493 </body>
495 </html> 494 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698