OLD | NEW |
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 function check(jsonText) | 7 function check(jsonText) |
8 { | 8 { |
9 var result = WebInspector.RequestJSONView.parseJSON(jsonText); | 9 var result = WebInspector.JSONView.parseJSON(jsonText); |
10 InspectorTest.addResult(""); | 10 InspectorTest.addResult(""); |
11 InspectorTest.addResult("Input: " + jsonText); | 11 InspectorTest.addResult("Input: " + jsonText); |
12 if (!result) { | 12 if (!result) { |
13 InspectorTest.addResult("Invalid JSON"); | 13 InspectorTest.addResult("Invalid JSON"); |
14 } else { | 14 } else { |
15 InspectorTest.addResult("Prefix: " + result.prefix); | 15 InspectorTest.addResult("Prefix: " + result.prefix); |
16 InspectorTest.addResult("Suffix: " + result.suffix); | 16 InspectorTest.addResult("Suffix: " + result.suffix); |
17 InspectorTest.addResult("Data: " + JSON.stringify(result.data)); | 17 InspectorTest.addResult("Data: " + JSON.stringify(result.data)); |
18 } | 18 } |
19 } | 19 } |
20 | 20 |
21 check("plain text"); | 21 check("plain text"); |
22 check("{\"x\": 5, \"y\": false, \"z\":\"foo\"}"); | 22 check("{\"x\": 5, \"y\": false, \"z\":\"foo\"}"); |
23 check("{\"bar\": [,,,1, 2, 3,,,], \"baz\": {\"data\": []}}"); | 23 check("{\"bar\": [,,,1, 2, 3,,,], \"baz\": {\"data\": []}}"); |
24 check("[[],[],[]]"); | 24 check("[[],[],[]]"); |
25 check("/* GUARD */callback({\"a\": []]});"); | 25 check("/* GUARD */callback({\"a\": []]});"); |
26 check("foo({a = 5});"); | 26 check("foo({a = 5});"); |
27 check("(function(){return {\"a\": []}})()"); | 27 check("(function(){return {\"a\": []}})()"); |
28 | 28 |
29 InspectorTest.completeTest(); | 29 InspectorTest.completeTest(); |
30 } | 30 } |
31 | 31 |
32 </script> | 32 </script> |
33 </head> | 33 </head> |
34 <body onload="runTest()"> | 34 <body onload="runTest()"> |
35 <p>Tests JSON parsing.</p> | 35 <p>Tests JSON parsing.</p> |
36 </body> | 36 </body> |
37 </html> | 37 </html> |
OLD | NEW |