Chromium Code Reviews| Index: LayoutTests/http/tests/inspector/network/json-preview.html |
| diff --git a/LayoutTests/http/tests/inspector/network/json-preview.html b/LayoutTests/http/tests/inspector/network/json-preview.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d1f7e87bff5dc8026b4eb95302a82d457e8656ce |
| --- /dev/null |
| +++ b/LayoutTests/http/tests/inspector/network/json-preview.html |
| @@ -0,0 +1,88 @@ |
| +<html> |
|
vsevik
2013/12/16 10:01:19
This is still a 99% copy-paste of another test.
It
sof
2013/12/16 10:35:32
Hmm. We have to test that XHR over JSON types gene
|
| +<head> |
| +<script src="../inspector-test.js"></script> |
| +<script src="../network-test.js"></script> |
| +<script> |
| +function loadIframe(contentType) |
| +{ |
| + iframe = document.createElement("iframe"); |
| + iframe.src = "resources/json.php?type=" + contentType; |
| + document.body.appendChild(iframe); |
| +} |
| + |
| +function test() |
| +{ |
| + InspectorTest.recordNetwork(); |
| + |
| + var networkPanel = WebInspector.showPanel("network"); |
| + |
| + function lastRequest() |
| + { |
| + return networkPanel.requests[networkPanel.requests.length - 1]; |
| + } |
| + |
| + function reportRequest(request) |
| + { |
| + InspectorTest.addResult("request.url: " + request.url); |
| + InspectorTest.addResult("request.type: " + request.type); |
| + InspectorTest.addResult("request.mimeType: " + request.mimeType); |
| + } |
| + |
| + function testPreviewer(request) |
| + { |
| + var previewView = new WebInspector.RequestPreviewView(request, null); |
| + var previewer = previewView._createPreviewView(); |
| + InspectorTest.addResult("resource.content: " + request.content); |
| + InspectorTest.addResult("Request previewer is JSON: " + (previewer instanceof WebInspector.RequestJSONView)); |
| + } |
| + |
| + function testType(contentType, callback) |
| + { |
| + var encodedContentType = encodeURIComponent(contentType); |
| + function step2() |
| + { |
| + var request = lastRequest(); |
| + reportRequest(request); |
| + request.requestContent(step3); |
| + } |
| + function step3() |
| + { |
| + var request = lastRequest(); |
| + testPreviewer(request); |
| + |
| + InspectorTest.addConsoleSniffer(step4); |
| + InspectorTest.evaluateInPage("loadIframe('" + encodedContentType + "')"); |
| + } |
| + function step4() |
| + { |
| + var request = lastRequest(); |
| + reportRequest(request); |
| + request.requestContent(step5); |
| + } |
| + function step5() |
| + { |
| + var request = lastRequest(); |
| + testPreviewer(request); |
| + |
| + callback(); |
| + } |
| + InspectorTest.makeSimpleXHR("GET", "resources/json.php?type=" + encodedContentType, true, step2); |
| + } |
| + InspectorTest.runTestSuite([ |
| + function test1(next) |
| + { |
| + testType("application/json", next); |
| + }, |
| + function test2(next) |
| + { |
| + testType("application/vnd.document+json", next); |
| + }, |
| + ]); |
| +} |
| +</script> |
| +</head> |
| +<body onload="runTest()"> |
| +<p>Tests that resources with JSON MIME types are previewed with the JSON viewer.</p> |
| +</p> |
| +</body> |
| +</html> |