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

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: fix glitch 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 <html>
2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto r-protocol-test.js"></script>
4 <script type="text/javascript" src="css-protocol-test.js"></script>
5 <script type="text/javascript" src="edit-range-utils.js"></script>
6 <script type="text/javascript">
7 function test()
8 {
9 InspectorTest.eventHandler["CSS.styleSheetAdded"] = styleSheetAdded;
10 InspectorTest.sendCommandOrDie("CSS.enable", {});
11
12 var editStyleSheet;
13 var checkProtocolError;
14 var dumpStyleSheet;
15
16 function styleSheetAdded(result)
17 {
18 var styleSheetId = result.params.header.styleSheetId;
19 editStyleSheet = InspectorTest.editStyleSheet.bind(null, styleSheetId);
20 checkProtocolError = InspectorTest.checkProtocolError.bind(null, styleSh eetId);
21 dumpStyleSheet = InspectorTest.dumpStyleSheetText.bind(null, styleSheetI d);
22 InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheetId: styleSheetId }, onInitialStyleSheetText);
23 }
24
25 function onInitialStyleSheetText(result)
26 {
27 InspectorTest.log("==== Initial style sheet text ====");
28 InspectorTest.log(result.text);
29 InspectorTest.runTestSuite(testSuite);
30 }
31
32 var testSuite = [
33 function testEditSelector(next)
34 {
35 editStyleSheet({
36 range: { startLine: 0, startColumn: 0, endLine: 0, endColumn: 1 },
37 text: ".EDITED-SELECTOR"
38 }, InspectorTest.undoAndNext(next));
vsevik 2014/03/13 10:44:51 Can we make a simple InspectorTest.domUndo(callbac
39 },
40
41 function testEditSubSelector(next)
42 {
43 editStyleSheet({
44 range: { startLine: 4, startColumn: 6, endLine: 4, endColumn: 10 },
45 text: ".EDITED-SELECTOR"
46 }, InspectorTest.undoAndNext(next));
47 },
48
49 function testBreakingCommentEditSelector(next)
50 {
51 checkProtocolError({
52 range: { startLine: 12, startColumn: 12, endLine: 12, endColumn: 12 },
53 text: "/*<--OPENED COMMENT"
54 }, next);
55 },
56
57 function testInsertInSelectorStart(next)
58 {
59 editStyleSheet({
60 range: { startLine: 4, startColumn: 0, endLine: 4, endColumn: 0 },
61 text: "head, "
62 }, InspectorTest.undoAndNext(next));
63 },
64
65 function testValidEditPseudoClass(next)
66 {
67 editStyleSheet({
68 range: { startLine: 12, startColumn: 8, endLine: 12, endColumn: 14 },
69 text: "line"
70 }, InspectorTest.undoAndNext(next));
71 },
72
73 function testInvalidPseudoClass(next)
74 {
75 checkProtocolError({
76 range: { startLine: 12, startColumn: 2, endLine: 12, endColumn: 7 },
77 text: "not-sure-which"
78 }, next);
79 },
80
81 function testEditProperty(next)
82 {
83 editStyleSheet({
84 range: { startLine: 7, startColumn: 4, endLine: 7, endColumn: 14 },
85 text: "content: 'EDITED PROPERTY';"
86 }, InspectorTest.undoAndNext(next));
87 },
88
89 function testBreakingCommentEditProperty(next)
90 {
91 checkProtocolError({
92 range: { startLine: 8, startColumn: 4, endLine: 8, endColumn: 14 },
93 text: "/*<--OPENED COMMENT"
94 }, next);
95 },
96
97 function testInsertFirstProperty(next)
98 {
99 editStyleSheet({
100 range: { startLine: 6, startColumn: 4, endLine: 6, endColumn: 4 },
101 text: "content: 'INSERTED PROPERTY';"
102 }, InspectorTest.undoAndNext(next));
103 },
104
105 function testInsertLastProperty(next)
106 {
107 editStyleSheet({
108 range: { startLine: 10, startColumn: 0, endLine: 10, endColumn: 0 },
109 text: "content: 'INSERTED PROPERTY';"
110 }, InspectorTest.undoAndNext(next));
111 },
112
113 function testInsertMultipleProperties(next)
114 {
115 editStyleSheet({
116 range: { startLine: 8, startColumn: 0, endLine: 8, endColumn: 0 },
117 text: "content: 'INSERTED #1';content: 'INSERTED #2';"
118 }, InspectorTest.undoAndNext(next));
119 },
120
121 function testInsertPropertyInEmptyRule(next)
122 {
123 editStyleSheet({
124 range: { startLine: 16, startColumn: 13, endLine: 16, endColumn: 13 },
125 text: "content: 'INSERTED PROPERTY';"
126 }, InspectorTest.undoAndNext(next));
127 },
128
129 function testInsertPropertyOutsideRule(next)
130 {
131 checkProtocolError({
132 range: { startLine: 10, startColumn: 1, endLine: 10, endColumn: 1 },
133 text: "content: 'INSERTED PROPERTY';"
134 }, next);
135 },
136
137 function testInsertBreakingPropertyInLastEmptyRule(next)
138 {
139 checkProtocolError({
140 range: { startLine: 16, startColumn: 13, endLine: 16, endColumn: 13 },
141 text: "content: 'INSERTED PROPERTY'/*"
142 }, next);
143 },
144
145 function testDisableProperty(next)
146 {
147 editStyleSheet({
148 range: { startLine: 7, startColumn: 4, endLine: 7, endColumn: 14 },
149 text: "/* margin: 0; */"
150 }, InspectorTest.undoAndNext(next));
151 },
152
153 function testInsertEmptyFirstRule(next)
154 {
155 editStyleSheet({
156 range: { startLine: 0, startColumn: 0, endLine: 0, endColumn: 0 },
157 text: "div {}\n"
158 }, InspectorTest.undoAndNext(next), true);
159 },
160
161 function testInsertEmptyLastRule(next)
162 {
163 editStyleSheet({
164 range: { startLine: 17, startColumn: 1, endLine: 17, endColumn: 1 },
165 text: "div { }"
166 }, InspectorTest.undoAndNext(next), true);
167 },
168
169 function testRedo(next)
170 {
171 editStyleSheet({
172 range: { startLine: 11, startColumn: 0, endLine: 11, endColumn: 0 },
173 text: "div { content: 'INSERTED RULE'; }"
174 }, InspectorTest.undoAndNext(redo));
175
176 function redo()
177 {
178 InspectorTest.sendCommandOrDie("DOM.redo", null, dumpStyleSheet. bind(null, InspectorTest.undoAndNext(next)));
179 }
180 },
181
182 function testInvalidParameters(next)
183 {
184 checkProtocolError({
185 range: { startLine: "three", startColumn: 0, endLine: 4, endColu mn: 0 },
186 text: "no matter what is here"
187 }, next);
188 },
189
190 function testNegativeRangeParameters(next)
191 {
192 checkProtocolError({
193 range: { startLine: -1, startColumn: -1, endLine: 1, endColumn: 0 },
194 text: "a:hover { color: blue }"
195 }, next);
196 },
197
198 function testStartLineOutOfBounds(next)
199 {
200 checkProtocolError({
201 range: { startLine: 100, startColumn: 0, endLine: 100, endColumn : 0 },
202 text: "a:hover { color: blue }"
203 }, next);
204 },
205
206 function testEndLineOutOfBounds(next)
207 {
208 checkProtocolError({
209 range: { startLine: 0, startColumn: 0, endLine: 100, endColumn: 0 },
210 text: "a:hover { color: blue }"
211 }, next);
212 },
213
214 function testStartColumnBeyondLastLineCharacter(next)
215 {
216 checkProtocolError({
217 range: { startLine: 3, startColumn: 1000, endLine: 3, endColumn: 1000 },
218 text: "a:hover { color: blue }"
219 }, next);
220 },
221
222 function testEndColumnBeyondLastLineCharacter(next)
223 {
224 checkProtocolError({
225 range: { startLine: 3, startColumn: 0, endLine: 3, endColumn: 10 00 },
226 text: "a:hover { color: blue }"
227 }, next);
228 },
229
230 function testInsertBeyondLastCharacterOfLastLine(next)
231 {
232 checkProtocolError({
233 range: { startLine: 3, startColumn: 1, endLine: 3, endColumn: 1 },
234 text: "a:hover { color: blue }"
235 }, next);
236 },
237
238 function testReversedRange(next)
239 {
240 checkProtocolError({
241 range: { startLine: 2, startColumn: 0, endLine: 0, endColumn: 0 },
242 text: "a:hover { color: blue }"
243 }, next);
244 },
245 ];
246 }
247
248 </script>
249 <link rel="stylesheet" href="resources/edit-range.css"/>
250 </head>
251 <body onload="runTest();">
252 </body>
253 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698