Update To 11.40.268.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                 var request = InspectorTest.networkRequests().pop();
41                 InspectorTest.addResult("Dumping request: " + request.url);
42                 InspectorTest.addResult("  statusCode: " + request.statusCode);
43                 next();
44             }
45         }
46     }
47
48     InspectorTest.runTestSuite([
49         function testNetworkResourceNonCached(next)
50         {
51             testLoadForURL("http://localhost:8080/inspector/network/resources/resource.php", undefined, next);
52         },
53
54         function testNetworkResourceCached(next)
55         {
56             testLoadForURL("http://localhost:8080/inspector/network/resources/resource.php?cached=1", undefined, next);
57         },
58
59         function testNetworkResourceIfModifiedSince(next)
60         {
61             testLoadForURL("http://localhost:8080/inspector/network/resources/resource.php?cached=1", { "if-modified-since": new Date().toUTCString() }, next);
62         },
63
64         function testResourceFromIncorrectURL(next)
65         {
66             testLoadForURL("resource.php", undefined, next);
67         },
68
69         function testResourceFromFileScheme(next)
70         {
71             testLoadForURL("file:///var/www/index.html", undefined, next);
72         },
73
74         function testResourceWithCookie(next)
75         {
76             InspectorTest.makeSimpleXHR("GET", "http://127.0.0.1:8000/inspector/network/resources/set-cookie.php", false, callback)
77
78             function callback()
79             {
80                 testLoadForURL("http://127.0.0.1:8000/inspector/network/resources/print-cookie.php", undefined, next);
81             }
82         },
83     ]);
84 }
85 </script>
86 </head>
87 <body onload="runTest()">
88 </body>
89 </html>