Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / inspector / network / async-xhr-json-mime-type.html
1 <html>
2 <head>
3 <script src="../inspector-test.js"></script>
4 <script src="../network-test.js"></script>
5 <script>
6 function loadIframe(contentType)
7 {
8     iframe = document.createElement("iframe");
9     iframe.src = "resources/json.php?type=" + contentType;
10     document.body.appendChild(iframe);
11 }
12
13 function test()
14 {
15     InspectorTest.recordNetwork();
16
17     function lastRequest()
18     {
19         return InspectorTest.networkRequests().pop();
20     }
21
22     function reportRequest(request)
23     {
24         InspectorTest.addResult("request.url: " + request.url);
25         InspectorTest.addResult("request.type: " + request.resourceType());
26         InspectorTest.addResult("request.mimeType: " + request.mimeType);
27     }
28
29     function testType(contentType, callback)
30     {
31         var encodedContentType = encodeURIComponent(contentType);
32         function step2()
33         {
34             var request = lastRequest();
35             reportRequest(request)
36             request.requestContent(step3);
37         }
38         function step3()
39         {
40             var request = lastRequest();
41             InspectorTest.addResult("request.content: " + request.content);
42
43             InspectorTest.addConsoleSniffer(step4);
44             InspectorTest.evaluateInPage("loadIframe('" + encodedContentType + "')");
45         }
46         function step4()
47         {
48             var request = lastRequest();
49             reportRequest(request);
50             request.requestContent(step5);
51         }
52         function step5()
53         {
54             var request = lastRequest();
55             InspectorTest.addResult("request.content: " + request.content);
56
57             callback();
58         }
59         InspectorTest.makeSimpleXHR("GET", "resources/json.php?type=" + encodedContentType, true, step2);
60     }
61     InspectorTest.runTestSuite([
62         function test1(next)
63         {
64             testType("application/json", next);
65         },
66         function test2(next)
67         {
68             testType("application/vnd.document+json", next);
69         },
70     ]);
71 }
72 </script>
73 </head>
74 <body onload="runTest()">
75 <p>
76  Tests that the content of resources with JSON MIME types can be accessed.<br/>
77  When loaded by asynchronous XHR requests (<a href="https://bugs.webkit.org/show_bug.cgi?id=80684">Bug 80684</a>) or within iframes/documents.
78 </p>
79 </body>
80 </html>