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

Side by Side Diff: third_party/WebKit/LayoutTests/inspector/network/network-json-parser.html

Issue 2570263002: DevTools: introduce API for the Common.FormatterWorkerPool. (Closed)
Patch Set: address comments Created 4 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/inspector/sources/debugger/extract-javascript-identifiers.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script src="../../http/tests/inspector/inspector-test.js"></script> 3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/network-test.js"></script> 4 <script src="../../http/tests/inspector/network-test.js"></script>
5 <script> 5 <script>
6 function test() { 6 function test() {
7 var worker = new Common.Worker("formatter_worker");
8 function check(jsonText) 7 function check(jsonText)
9 { 8 {
10 var resultData = Network.JSONView._extractJSON(jsonText); 9 var resultData = Network.JSONView._extractJSON(jsonText);
11 if (!resultData) { 10 if (!resultData) {
12 failure(); 11 failure();
13 return; 12 return;
14 } 13 }
15 14
16 worker.onmessage = success; 15 Common.formatterWorkerPool.parseJSONRelaxed(resultData.data).then(succes s);
17 worker.postMessage({method: "relaxedJSONParser", params:{content: result Data.data}});
18 16
19 function success(event) 17 function success(data)
20 { 18 {
21 var data = event.data;
22 if (data === null) { 19 if (data === null) {
23 failure(); 20 failure();
24 return; 21 return;
25 } 22 }
26 resultData.data = data; 23 resultData.data = data;
27 InspectorTest.addResult(""); 24 InspectorTest.addResult("");
28 InspectorTest.addResult("Input: " + cleanData(jsonText)); 25 InspectorTest.addResult("Input: " + cleanData(jsonText));
29 26
30 InspectorTest.addResult("Prefix: " + cleanData(resultData.prefix)); 27 InspectorTest.addResult("Prefix: " + cleanData(resultData.prefix));
31 InspectorTest.addResult("Suffix: " + cleanData(resultData.suffix)); 28 InspectorTest.addResult("Suffix: " + cleanData(resultData.suffix));
(...skipping 21 matching lines...) Expand all
53 function cleanData(data) 50 function cleanData(data)
54 { 51 {
55 return data.replace(/\0/g, "**NULL**").replace(/\r/g, "**CR**"); 52 return data.replace(/\0/g, "**NULL**").replace(/\r/g, "**CR**");
56 } 53 }
57 function runNext() 54 function runNext()
58 { 55 {
59 if (currentTestIndex < tests.length) { 56 if (currentTestIndex < tests.length) {
60 currentTestIndex++; 57 currentTestIndex++;
61 check(tests[currentTestIndex - 1]); 58 check(tests[currentTestIndex - 1]);
62 } else { 59 } else {
63 worker.terminate();
64 InspectorTest.completeTest(); 60 InspectorTest.completeTest();
65 } 61 }
66 } 62 }
67 63
68 var currentTestIndex = 0; 64 var currentTestIndex = 0;
69 var tests = [ 65 var tests = [
70 "plain text", 66 "plain text",
71 "{\"x\": 5, \"y\": false, \"z\":\"foo\"}", 67 "{\"x\": 5, \"y\": false, \"z\":\"foo\"}",
72 "{\"bar\": [,,,1, 2, 3,,,], \"baz\": {\"data\": []}}", 68 "{\"bar\": [,,,1, 2, 3,,,], \"baz\": {\"data\": []}}",
73 "[[],[],[]]", 69 "[[],[],[]]",
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 ]; 168 ];
173 runNext(); 169 runNext();
174 } 170 }
175 171
176 </script> 172 </script>
177 </head> 173 </head>
178 <body onload="runTest()"> 174 <body onload="runTest()">
179 <p>Tests JSON parsing.</p> 175 <p>Tests JSON parsing.</p>
180 </body> 176 </body>
181 </html> 177 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/inspector/sources/debugger/extract-javascript-identifiers.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698