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

Side by Side Diff: third_party/WebKit/LayoutTests/inspector/sources/pretty-print-javascript-5-expected.txt

Issue 1835783002: DevTools: simplify WI.FormattedContentBuilder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaseline tests Created 4 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
OLDNEW
1 Verifies JavaScript pretty-printing functionality. 1 Verifies JavaScript pretty-printing functionality.
2 2
3 3
4 Running: forInFormatting 4 Running: forInFormatting
5 ====== 8< ------ 5 ====== 8< ------
6 for (var key in myMap) 6 for (var key in myMap)
7 print(key); 7 print(key);
8 8
9 ------ >8 ====== 9 ------ >8 ======
10 Correct mapping for <myMap> 10 Correct mapping for <myMap>
(...skipping 13 matching lines...) Expand all
24 rebuild(), 24 rebuild(),
25 show(), 25 show(),
26 hasNew ? refresh() : noop(); 26 hasNew ? refresh() : noop();
27 27
28 ------ >8 ====== 28 ------ >8 ======
29 Correct mapping for <noop> 29 Correct mapping for <noop>
30 Correct mapping for <hasNew> 30 Correct mapping for <hasNew>
31 31
32 Running: complexScriptFormatting 32 Running: complexScriptFormatting
33 ====== 8< ------ 33 ====== 8< ------
34 function formatted1() 34 function formatted1() {
35 {
36 var variable1 = 0; 35 var variable1 = 0;
37 } 36 }
38 37 function withComments() {
39 function withComments()
40 {
41 // comment 38 // comment
42 return "functionWithComments"; 39 return "functionWithComments";
43 } 40 }
44
45 try { 41 try {
46 onmessage = function(event) { 42 onmessage = function(event) {
47 var source = event.data; 43 var source = event.data;
48 var formattedSource = beautify(source); 44 var formattedSource = beautify(source);
49 var mapping = buildMapping(source, formattedSource); 45 var mapping = buildMapping(source, formattedSource);
50 postMessage({ 46 postMessage({
51 formattedSource: formattedSource, 47 formattedSource: formattedSource,
52 mapping: mapping 48 mapping: mapping
53 }) 49 })
54 } 50 }
55 ; 51 ;
56 function beautify(source) { 52 function beautify(source) {
57 var ast = parse.parse(source); 53 var ast = parse.parse(source);
58 var beautifyOptions = 54 var beautifyOptions = {
59 {
60 indent_level: 4, 55 indent_level: 4,
61 indent_start: 0, 56 indent_start: 0,
62 quote_keys: false, 57 quote_keys: false,
63 space_colon: false 58 space_colon: false
64 }; 59 };
65 return process.gen_code(ast, beautifyOptions) 60 return process.gen_code(ast, beautifyOptions)
66 } 61 }
67 function buildMapping(source, formattedSource) { 62 function buildMapping(source, formattedSource) {
68 var mapping = { 63 var mapping = {
69 original: [], 64 original: [],
70 formatted: [] 65 formatted: []
71 }; 66 };
72 var lastPosition = 0; 67 var lastPosition = 0;
73 var regexp = /(^|[^\\])\b((?=\D)[\$\.\w]+)\b/g; 68 var regexp = /(^|[^\\])\b((?=\D)[\$\.\w]+)\b/g;
74 while (true) 69 while (true) {
75 {
76 var match = regexp.exec(formattedSource); 70 var match = regexp.exec(formattedSource);
77 if (!match) 71 if (!match)
78 break; 72 break;
79 var position = source.indexOf(match[2], lastPosition); 73 var position = source.indexOf(match[2], lastPosition);
80 if (position === -1) 74 if (position === -1)
81 throw "No match found in original source for " + match[2]; 75 throw "No match found in original source for " + match[2];
82 mapping.original.push(position); 76 mapping.original.push(position);
83 mapping.formatted.push(match.index + match[1].length); 77 mapping.formatted.push(match.index + match[1].length);
84 lastPosition = position + match[2].length 78 lastPosition = position + match[2].length
85 } 79 }
86 return mapping 80 return mapping
87 } 81 }
88 function require() { 82 function require() {
89 return parse 83 return parse
90 } 84 }
91 var exports = {}; 85 var exports = {};
92 importScripts("UglifyJS/parse-js.js"); 86 importScripts("UglifyJS/parse-js.js");
93 var parse = exports; 87 var parse = exports;
94 var exports = {}; 88 var exports = {};
95 importScripts("UglifyJS/process.js"); 89 importScripts("UglifyJS/process.js");
96 var process = exports; 90 var process = exports;
97 } catch (e) {} 91 } catch (e) {}
98 92 function formatted2() {
99 function formatted2()
100 {
101 var variable2 = 0; 93 var variable2 = 0;
102 } 94 }
103 95
104 ------ >8 ====== 96 ------ >8 ======
105 Correct mapping for <function> 97 Correct mapping for <function>
106 Correct mapping for <formatted1> 98 Correct mapping for <formatted1>
107 Correct mapping for <variable1> 99 Correct mapping for <variable1>
108 Correct mapping for < return "functionWithComments"> 100 Correct mapping for < return "functionWithComments">
109 Correct mapping for <onmessage> 101 Correct mapping for <onmessage>
110 Correct mapping for <indent_start> 102 Correct mapping for <indent_start>
(...skipping 10 matching lines...) Expand all
121 pretty(); 113 pretty();
122 } else if (a + b) 114 } else if (a + b)
123 e(); 115 e();
124 reset(); 116 reset();
125 } 117 }
126 118
127 ------ >8 ====== 119 ------ >8 ======
128 Correct mapping for <pretty> 120 Correct mapping for <pretty>
129 Correct mapping for <reset> 121 Correct mapping for <reset>
130 122
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698