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

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

Issue 1511073002: DevTools: [SASS] introduce sass module, implement SCSS AST-builder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: introduce ASTDocument Created 5 years 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
(Empty)
1 var initialize_SassTest = function() {
2
3 InspectorTest.preloadModule("sass");
4
5 InspectorTest.dumpAST = function(ast)
6 {
7 var lines = [String.sprintf("=== AST === %s", ast.document.url)];
8 for (var i = 0; i < ast.rules.length; ++i) {
9 var rule = ast.rules[i];
10 lines.push(String.sprintf("rule %d: \"%s\"", i, rule.selector));
11 var ruleLines = dumpRule(rule);
12 lines = lines.concat(indent(ruleLines));
13 }
14 lines.push("======");
15 InspectorTest.addResult(lines.join("\n"));
16 return ast;
17
18 function dumpRule(rule)
19 {
20 var lines = [];
21 for (var i = 0; i < rule.properties.length; ++i) {
22 var property = rule.properties[i];
23 lines.push("property " + i);
24 var propertyLines = dumpProperty(property);
25 lines = lines.concat(indent(propertyLines));
26 }
27 return lines;
28 }
29
30 function dumpProperty(property)
31 {
32 var lines = [];
33 lines.push(String.sprintf("name: \"%s\"", property.name.text));
34 lines = lines.concat(indent(dumpTextNode(property.name)));
35 lines.push(String.sprintf("value: \"%s\"", property.value.text));
36 lines = lines.concat(indent(dumpTextNode(property.value)));
37 lines.push(String.sprintf("range: %s", property.range.toString()));
38 lines.push(String.sprintf("disabled: %s", property.disabled));
39 return lines;
40 }
41
42 function dumpTextNode(textNode)
43 {
44 return [String.sprintf("range: %s", textNode.range.toString())];
45 }
46
47 function indent(lines)
48 {
49 return lines.map(line => " " + line);
50 }
51 }
52
53 InspectorTest.validateASTRanges = function(ast)
54 {
55 var invalidNodes = [];
56 for (var rule of ast.rules) {
57 for (var property of rule.properties) {
58 validate(property.name);
59 validate(property.value);
60 }
61 }
62 if (invalidNodes.length) {
63 InspectorTest.addResult("Bad ranges: " + invalidNodes.length);
64 for (var node of invalidNodes)
65 InspectorTest.addResult(String.sprintf(" - range: %s text: %s", nod e.range.toString(), node.text));
66 } else {
67 InspectorTest.addResult("Ranges OK.");
68 }
69 return ast;
70
71 function validate(textNode)
72 {
73 if (textNode.range.extract(textNode.document.text) !== textNode.text)
74 invalidNodes.push(textNode);
75 }
76 }
77
78 InspectorTest.parseSCSS = function(url, text)
79 {
80 return self.runtime.instancePromise(WebInspector.TokenizerFactory)
81 .then(onTokenizer);
82
83 function onTokenizer(tokenizer)
84 {
85 return WebInspector.SASSSupport.parseSCSS(url, text, tokenizer);
86 }
87 }
88
89 }
90
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698