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

Side by Side Diff: LayoutTests/inspector-protocol/css/css-edit-range.html

Issue 172593003: DevTools: [CSS] Add CSS.editRangeInStyleSheetText() to the protocol (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: address comments Created 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 <html>
2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/resource s/protocol-test.js"></script>
4 <script type="text/javascript">
5 function test()
6 {
7 InspectorTest.eventHandler["CSS.styleSheetAdded"] = styleSheetAdded;
8 InspectorTest.sendCommandAndBailOnError("CSS.enable", {});
9
10 var styleSheetId;
11
12 function styleSheetAdded(result)
13 {
14 styleSheetId = result.params.header.styleSheetId;
15 InspectorTest.sendCommandAndBailOnError("CSS.getStyleSheetText", { style SheetId: styleSheetId }, onInitialStyleSheetText);
16 }
17
18 function onInitialStyleSheetText(result)
19 {
20 InspectorTest.log("==== Initial style sheet text ====");
21 InspectorTest.log(result.text);
22 InspectorTest.runTestSuite(testSuite);
23 }
24
25 var testSuite = [
26 function testInsertText(next)
27 {
28 editStyleSheetAndDump({
29 range: { startLine: 0, startColumn: 0, endLine: 0, endColumn: 0 },
30 text: "* { border: 1px }"
31 }, next);
32 },
33
34 function testMultiLineEdit(next)
35 {
36 editStyleSheetAndDump({
37 range: { startLine: 1, startColumn: 5, endLine: 3, endColumn: 0 },
38 text: "\n background-color: blue;\n font-size: 12px;\n"
39 }, next);
40 },
41
42 function testReplaceText(next)
43 {
44 editStyleSheetAndDump({
45 range: { startLine: 1, startColumn: 0, endLine: 1, endColumn: 3 },
46 text: "p, span:hover"
47 }, next);
48 },
49
50 function testInsertInTheEnd(next)
51 {
52 editStyleSheetAndDump({
53 range: { startLine: 4, startColumn: 1, endLine: 4, endColumn: 1 },
54 text: "\n* { box-sizing: border-box; }"
55 }, next);
56 },
57
58 function testRemoveText(next)
59 {
60 editStyleSheetAndDump({
61 range: { startLine: 3, startColumn: 0, endLine: 4, endColumn: 0 },
62 text: ""
63 }, next);
64 },
65
66 function testInvalidParameters(next)
67 {
68 ensureProtocolError({
69 range: { startLine: "three", startColumn: 0, endLine: 4, endColu mn: 0 },
70 text: "no matter what is here"
71 }, next);
72 },
73
74 function testNegativeRangeParameters(next)
75 {
76 ensureProtocolError({
77 range: { startLine: -1, startColumn: -1, endLine: 1, endColumn: 2 },
78 text: "a:hover { color: blue }"
79 }, next);
80 },
81
82 function testOutOfBoundsRangeParametersNoCrash(next)
apavlov 2014/02/21 14:37:55 What about the range: - ending on the last line pa
lushnikov 2014/02/23 16:07:07 Done.
83 {
84 ensureProtocolError({
85 range: { startLine: 0, startColumn: 0, endLine: 100, endColumn: 100 },
86 text: "a:hover { color: blue }"
87 }, next);
88 },
89
90 function testReversedRange(next)
91 {
92 ensureProtocolError({
93 range: { startLine: 2, startColumn: 0, endLine: 0, endColumn: 0 },
94 text: "a:hover { color: blue }"
95 }, next);
96 }
97 ];
98
99 function editStyleSheetAndDump(options, callback)
100 {
101 options.styleSheetId = styleSheetId;
102 InspectorTest.sendCommandAndBailOnError("CSS.editRangeInStyleSheetText", options, onEditDone);
103 function onEditDone()
104 {
105 InspectorTest.sendCommandAndBailOnError("CSS.getStyleSheetText", { s tyleSheetId: styleSheetId }, onStyleSheetText);
106 }
107 function onStyleSheetText(result)
108 {
109 InspectorTest.log("==== Style sheet text ====");
110 InspectorTest.log(result.text);
111 callback();
112 }
113 }
114
115 function ensureProtocolError(options, next)
apavlov 2014/02/21 14:37:55 "ensure..." methods usually initialize something l
lushnikov 2014/02/23 16:07:07 Done.
116 {
117 options.styleSheetId = styleSheetId;
118 InspectorTest.sendCommand("CSS.editRangeInStyleSheetText", options, call back);
119
120 function callback(message)
121 {
122 if (!message.error) {
123 InspectorTest.log("ERROR: protocol method call did not raise exp ected error. Instead, the following message received: " + JSON.stringify(message ));
apavlov 2014/02/21 14:37:55 received -> was received
lushnikov 2014/02/23 16:07:07 Done.
124 InspectorTest.completeTest();
125 return;
126 }
127 InspectorTest.log("Expected protocol error: " + message.error.messag e);
128 next();
129 }
130 }
131
132 }
133
134 </script>
135 <link rel="stylesheet" href="resources/edit-range.css"/>
136 </head>
137 <body onload="runTest();">
138 </body>
139 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698