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

Side by Side Diff: third_party/WebKit/LayoutTests/inspector/sass/sass-test.js

Issue 1809533003: DevTools: remove illusionary caching from String.prototype.lineEndings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: String.prototype.lineEndings -> String.prototype.computeLineEndings Created 4 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
OLDNEW
1 var initialize_SassTest = function() { 1 var initialize_SassTest = function() {
2 2
3 InspectorTest.preloadModule("sass"); 3 InspectorTest.preloadModule("sass");
4 4
5 var cssParserService = null; 5 var cssParserService = null;
6 6
7 InspectorTest.cssParserService = function() 7 InspectorTest.cssParserService = function()
8 { 8 {
9 if (!cssParserService) 9 if (!cssParserService)
10 cssParserService = new WebInspector.CSSParserService(); 10 cssParserService = new WebInspector.CSSParserService();
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 InspectorTest.addResult("Bad ranges: " + invalidNodes.length); 161 InspectorTest.addResult("Bad ranges: " + invalidNodes.length);
162 for (var node of invalidNodes) 162 for (var node of invalidNodes)
163 InspectorTest.addResult(String.sprintf(" - range: %s text: %s", nod e.range.toString(), node.text)); 163 InspectorTest.addResult(String.sprintf(" - range: %s text: %s", nod e.range.toString(), node.text));
164 } else { 164 } else {
165 InspectorTest.addResult("Ranges OK."); 165 InspectorTest.addResult("Ranges OK.");
166 } 166 }
167 return ast; 167 return ast;
168 168
169 function validate(textNode) 169 function validate(textNode)
170 { 170 {
171 if (textNode.range.extract(textNode.document.text) !== textNode.text) 171 if (textNode.document.text.extract(textNode.range) !== textNode.text)
172 invalidNodes.push(textNode); 172 invalidNodes.push(textNode);
173 } 173 }
174 } 174 }
175 175
176 InspectorTest.validateMapping = function(mapping) 176 InspectorTest.validateMapping = function(mapping)
177 { 177 {
178 InspectorTest.addResult("Mapped CSS: " + mapping._cssToSass.size); 178 InspectorTest.addResult("Mapped CSS: " + mapping._cssToSass.size);
179 InspectorTest.addResult("Mapped SCSS: " + mapping._sassToCss.size); 179 InspectorTest.addResult("Mapped SCSS: " + mapping._sassToCss.size);
180 var cssNodes = mapping._cssToSass.keysArray(); 180 var cssNodes = mapping._cssToSass.keysArray();
181 var staleCSS = 0; 181 var staleCSS = 0;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 227
228 function runTests() 228 function runTests()
229 { 229 {
230 if (!tests.length) { 230 if (!tests.length) {
231 InspectorTest.completeTest(); 231 InspectorTest.completeTest();
232 astService.dispose(); 232 astService.dispose();
233 return; 233 return;
234 } 234 }
235 var test = tests.shift(); 235 var test = tests.shift();
236 logTestName(test.name); 236 logTestName(test.name);
237 var text = astSourceMap.cssAST().document.text; 237 var text = astSourceMap.cssAST().document.text.value();
238 var edits = test(text); 238 var edits = test(text);
239 logSourceEdits(text, edits); 239 logSourceEdits(text, edits);
240 var ranges = edits.map(edit => edit.oldRange); 240 var ranges = edits.map(edit => edit.oldRange);
241 var texts = edits.map(edit => edit.newText); 241 var texts = edits.map(edit => edit.newText);
242 WebInspector.SASSProcessor.processCSSEdits(astService, astSourceMap, ran ges, texts) 242 WebInspector.SASSProcessor.processCSSEdits(astService, astSourceMap, ran ges, texts)
243 .then(onEditsDone); 243 .then(onEditsDone);
244 } 244 }
245 245
246 function onEditsDone(result) 246 function onEditsDone(result)
247 { 247 {
248 if (!result.map) { 248 if (!result.map) {
249 InspectorTest.addResult("SASSProcessor failed to process edits."); 249 InspectorTest.addResult("SASSProcessor failed to process edits.");
250 runTests(); 250 runTests();
251 return; 251 return;
252 } 252 }
253 logASTText(result.map.cssAST()); 253 logASTText(result.map.cssAST());
254 for (var sassURL of result.newSASSSources.keys()) { 254 for (var sassURL of result.newSASSSources.keys()) {
255 var ast = result.map.sassModels().get(sassURL); 255 var ast = result.map.sassModels().get(sassURL);
256 logASTText(ast); 256 logASTText(ast);
257 } 257 }
258 runTests(); 258 runTests();
259 } 259 }
260 260
261 function logASTText(ast, avoidIndent, customTitle) 261 function logASTText(ast, avoidIndent, customTitle)
262 { 262 {
263 customTitle = customTitle || ast.document.url.split("/").pop(); 263 customTitle = customTitle || ast.document.url.split("/").pop();
264 InspectorTest.addResult("===== " + customTitle + " ====="); 264 InspectorTest.addResult("===== " + customTitle + " =====");
265 var text = ast.document.text.replace(/ /g, "."); 265 var text = ast.document.text.value().replace(/ /g, ".");
266 var lines = text.split("\n"); 266 var lines = text.split("\n");
267 if (!avoidIndent) 267 if (!avoidIndent)
268 lines = indent(lines); 268 lines = indent(lines);
269 InspectorTest.addResult(lines.join("\n")); 269 InspectorTest.addResult(lines.join("\n"));
270 } 270 }
271 271
272 function logTestName(testName) 272 function logTestName(testName)
273 { 273 {
274 var titleText = " TEST: " + testName + " "; 274 var titleText = " TEST: " + testName + " ";
275 var totalLength = 80; 275 var totalLength = 80;
276 var prefixLength = ((totalLength - titleText.length) / 2)|0; 276 var prefixLength = ((totalLength - titleText.length) / 2)|0;
277 var suffixLength = totalLength - titleText.length - prefixLength; 277 var suffixLength = totalLength - titleText.length - prefixLength;
278 var prefix = new Array(prefixLength).join("-"); 278 var prefix = new Array(prefixLength).join("-");
279 var suffix = new Array(suffixLength).join("-"); 279 var suffix = new Array(suffixLength).join("-");
280 InspectorTest.addResult("\n" + prefix + titleText + suffix + "\n"); 280 InspectorTest.addResult("\n" + prefix + titleText + suffix + "\n");
281 } 281 }
282 282
283 function logSourceEdits(text, edits) 283 function logSourceEdits(text, edits)
284 { 284 {
285 var lines = []; 285 var lines = [];
286 for (var i = 0; i < edits.length; ++i) { 286 for (var i = 0; i < edits.length; ++i) {
287 var edit = edits[i]; 287 var edit = edits[i];
288 var range = edit.oldRange; 288 var range = edit.oldRange;
289 var line = String.sprintf("{%d, %d, %d, %d}", range.startLine, range .startColumn, range.endLine, range.endColumn); 289 var line = String.sprintf("{%d, %d, %d, %d}", range.startLine, range .startColumn, range.endLine, range.endColumn);
290 line += String.sprintf(" '%s' => '%s'", range.extract(text), edit.ne wText); 290 line += String.sprintf(" '%s' => '%s'", (new WebInspector.Text(text) ).extract(range), edit.newText);
291 lines.push(line); 291 lines.push(line);
292 } 292 }
293 lines = indent(lines); 293 lines = indent(lines);
294 lines.unshift("Edits:"); 294 lines.unshift("Edits:");
295 InspectorTest.addResult(lines.join("\n")); 295 InspectorTest.addResult(lines.join("\n"));
296 } 296 }
297 } 297 }
298 298
299 InspectorTest.createEdit = function(source, pattern, newText, matchNumber) 299 InspectorTest.createEdit = function(source, pattern, newText, matchNumber)
300 { 300 {
301 matchNumber = matchNumber || 0; 301 matchNumber = matchNumber || 0;
302 var re = new RegExp(pattern.escapeForRegExp(), "g"); 302 var re = new RegExp(pattern.escapeForRegExp(), "g");
303 var match; 303 var match;
304 while ((match = re.exec(source)) !== null && matchNumber) { 304 while ((match = re.exec(source)) !== null && matchNumber) {
305 --matchNumber; 305 --matchNumber;
306 } 306 }
307 if (!match) 307 if (!match)
308 return null; 308 return null;
309 var sourceRange = new WebInspector.SourceRange(match.index, match[0].length) ; 309 var sourceRange = new WebInspector.SourceRange(match.index, match[0].length) ;
310 var textRange = sourceRange.toTextRange(source); 310 var textRange = sourceRange.toTextRange(new WebInspector.Text(source));
311 return new WebInspector.SourceEdit("", textRange, newText); 311 return new WebInspector.SourceEdit("", textRange, newText);
312 } 312 }
313 313
314 } 314 }
315 315
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/sass/editing-test-suite.js ('k') | third_party/WebKit/Source/devtools/devtools.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698