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

Side by Side Diff: LayoutTests/http/tests/inspector/network/network-preview-json.html

Issue 654083006: DevTools: NetworkPanel: use optimistic JSON parser for response preview. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « no previous file | LayoutTests/http/tests/inspector/network/network-preview-json-expected.txt » ('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="../inspector-test.js"></script> 3 <script src="../inspector-test.js"></script>
4 <script src="../network-test.js"></script> 4 <script src="../network-test.js"></script>
5 <script> 5 <script>
6 6
7 function test() 7 function test()
8 { 8 {
9 var testData; 9 function check(text) {
10 InspectorTest.addResult("");
11 InspectorTest.addResult("Input: " + text);
12 var parsedJSON = WebInspector.RequestJSONView.parseJSON(text);
13 if (!parsedJSON) {
14 InspectorTest.addResult("Can't parse");
15 return;
16 }
17 InspectorTest.addResult("Prefix: " + parsedJSON.prefix);
18 InspectorTest.addResult("Data: " + JSON.stringify(parsedJSON.data));
19 InspectorTest.addResult("Suffix: " + parsedJSON.suffix);
20 }
10 21
11 testData = "while(1);"; 22 check("{\"name\": \"value\"}");
12 InspectorTest.assertTrue(!WebInspector.RequestJSONView.parseJSON(testData), "Should not be able to parse \"" + testData + "\"."); 23 check("while(1); {\"name\": \"value\"}");
24 check("[,\"foo\", -4.2, true, false, null]");
25 check("[{\"foo\": {}, \"bar\": []},[[],{}]]");
26 check("/* vanilla */ run([1, 2, 3]);");
27 check("[\"A\\\"B\\u0020C\\nD\\\\E\\u04ABF\"]");
13 28
14 testData = "{\"name\": \"value\""; 29 check("<html>404 Page not found</html>");
15 InspectorTest.assertTrue(!WebInspector.RequestJSONView.parseJSON(testData), "Should not be able to parse \"" + testData + "\".");
16
17 testData = "{\"name\": \"value\"}";
18 var parsedJSON = WebInspector.RequestJSONView.parseJSON(testData);
19 InspectorTest.assertEquals(parsedJSON.prefix, "");
20 InspectorTest.assertEquals(parsedJSON.data.name, "value");
21 InspectorTest.assertEquals(parsedJSON.suffix, "");
22
23 testData = "while(1); {\"name\": \"value\"}";
24 parsedJSON = WebInspector.RequestJSONView.parseJSON(testData);
25 InspectorTest.assertEquals(parsedJSON.prefix, "while(1); ");
26 InspectorTest.assertEquals(parsedJSON.data.name, "value");
27 InspectorTest.assertEquals(parsedJSON.suffix, "");
28
29 testData = "func({)";
30 InspectorTest.assertTrue(!WebInspector.RequestJSONView.parseJSONP(testData), "Should not be able to parse \"" + testData + "\".");
31
32 testData = "func){(";
33 InspectorTest.assertTrue(!WebInspector.RequestJSONView.parseJSONP(testData), "Should not be able to parse \"" + testData + "\".");
34
35 testData = "func({\"name\": \"value\"}";
36 InspectorTest.assertTrue(!WebInspector.RequestJSONView.parseJSONP(testData), "Should not be able to parse \"" + testData + "\".");
37
38 testData = "func{\"name\": \"value\"})";
39 InspectorTest.assertTrue(!WebInspector.RequestJSONView.parseJSONP(testData), "Should not be able to parse \"" + testData + "\".");
40
41 testData = "func({\"name\": \"value\"})";
42 var parsedJSONP = WebInspector.RequestJSONView.parseJSONP(testData);
43 InspectorTest.assertEquals(parsedJSONP.prefix, "func(");
44 InspectorTest.assertEquals(parsedJSONP.data.name, "value");
45 InspectorTest.assertEquals(parsedJSONP.suffix, ")");
46 30
47 InspectorTest.completeTest(); 31 InspectorTest.completeTest();
48 } 32 }
49 </script> 33 </script>
50 </head> 34 </head>
51 <body onload="runTest()"> 35 <body onload="runTest()">
52 <p>Tests RequestJSONView ability to parse JSON passed in XHR, JSONP</p> 36 <p>Tests RequestJSONView ability to parse JSON passed in XHR, JSONP</p>
53 <a href="https://bugs.webkit.org/show_bug.cgi?id=65559">Bug 65559</a> 37 <a href="https://bugs.webkit.org/show_bug.cgi?id=65559">Bug 65559</a>
54 </body> 38 </body>
55 </html> 39 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/inspector/network/network-preview-json-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698