Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / inspector / network / load-resource-for-frontend.html
1 <html>
2 <head>
3 <script src="../inspector-test.js"></script>
4 <script src="../network-test.js"></script>
5 <script>
6 function test()
7 {
8     var loggedHeaders = {
9         "cache-control": true,
10         "expires": true,
11         "last-modified": true,
12         "pragma": true
13     };
14     function testLoadForURL(url, headers, next)
15     {
16         InspectorTest.recordNetwork();
17         InspectorTest.addResult("Loading resource from " + url);
18         NetworkAgent.loadResourceForFrontend(WebInspector.resourceTreeModel.mainFrame.id, url, headers, callback);
19
20         function callback(error, statusCode, headers, content)
21         {
22             if (error)
23                 InspectorTest.addResult("Failed: " + error);
24             else {
25                 InspectorTest.addResult("Success: " + statusCode);
26                 var headersArray = [];
27                 for (var name in headers) {
28                     var nameLower = name.toLowerCase();
29                     if (nameLower in loggedHeaders)
30                         headersArray.push(nameLower);
31                 }
32                 headersArray.sort();
33                 InspectorTest.addResult("Logged headers: " + headersArray.join(", "));
34                 InspectorTest.addResult("Content: \"" + content + "\"");
35             }
36             InspectorTest.runAfterPendingDispatches(dumpNetworkRequest);
37
38             function dumpNetworkRequest()
39             {
40                 WebInspector.inspectorView.showPanel("network");
41                 var request = InspectorTest.networkRequests().pop();
42                 InspectorTest.addResult("Dumping request: " + request.url);
43                 InspectorTest.addResult("  statusCode: " + request.statusCode);
44                 next();
45             }
46         }
47     }
48
49     InspectorTest.runTestSuite([
50         function testNetworkResourceNonCached(next)
51         {
52             testLoadForURL("http://localhost:8080/inspector/network/resources/resource.php", undefined, next);
53         },
54
55         function testNetworkResourceCached(next)
56         {
57             testLoadForURL("http://localhost:8080/inspector/network/resources/resource.php?cached=1", undefined, next);
58         },
59
60         function testNetworkResourceIfModifiedSince(next)
61         {
62             testLoadForURL("http://localhost:8080/inspector/network/resources/resource.php?cached=1", { "if-modified-since": new Date().toUTCString() }, next);
63         },
64
65         function testResourceFromIncorrectURL(next)
66         {
67             testLoadForURL("resource.php", undefined, next);
68         },
69
70         function testResourceFromFileScheme(next)
71         {
72             testLoadForURL("file:///var/www/index.html", undefined, next);
73         },
74
75         function testResourceWithCookie(next)
76         {
77             InspectorTest.makeSimpleXHR("GET", "http://127.0.0.1:8000/inspector/network/resources/set-cookie.php", false, callback)
78
79             function callback()
80             {
81                 testLoadForURL("http://127.0.0.1:8000/inspector/network/resources/print-cookie.php", undefined, next);
82             }
83         },
84     ]);
85 }
86 </script>
87 </head>
88 <body onload="runTest()">
89 </body>
90 </html>