Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / inspector / network / har-content.html
1 <!doctype html>
2 <html>
3 <head>
4 <script src="../inspector-test.js"></script>
5 <script src="../network-test.js"></script>
6
7 <script>
8 var test = function()
9 {
10     function step1()
11     {
12         InspectorTest.makeSimpleXHR("GET", "resources/binary.data", false, step2);
13     }
14
15     function step2()
16     {
17         var writer = new WebInspector.HARWriter();
18         var stream = new InspectorTest.StringOutputStream(onSaved);
19         writer.write(stream, InspectorTest.networkRequests(), new WebInspector.Progress());
20     }
21
22     function dumpContent(content)
23     {
24         if (!content) {
25             InspectorTest.addResult("    NOT FOUND");
26             return;
27         }
28         var propertyNames = Object.keys(content);
29         propertyNames.sort();
30         for (var i = 0; i < propertyNames.length; ++i) {
31             var prop = propertyNames[i];
32             InspectorTest.addResult("    " + prop + ": " + JSON.stringify(content[prop]));
33         }
34     }
35
36     function onSaved(data)
37     {
38         var har = JSON.parse(data);
39
40         InspectorTest.addResult("initiator.css:");
41         dumpContent(findEntry(har, /\/initiator\.css$/).response.content);
42
43         InspectorTest.addResult("");
44
45         InspectorTest.addResult("binary.data:");
46         dumpContent(findEntry(har, /\/binary\.data$/).response.content);
47
48         InspectorTest.completeTest();
49     }
50
51     function findEntry(har, regexp)
52     {
53         var entries = har.log.entries;
54         for (var i = 0; i < entries.length; ++i) {
55              var entry = entries[i];
56              if (regexp.test(entry.request.url))
57                  return entry;
58         }
59         InspectorTest.addResult("FAIL: can't find resource for " + regexp);
60         return null;
61     }
62
63     InspectorTest.makeSimpleXHR("GET", "resources/initiator.css", false, step1);
64 }
65 </script>
66
67
68 </head>
69
70 <body onload="runTest()">
71 <p>
72 Tests conversion of Inspector's resource representation into HAR format.
73 </p>
74
75 </body>
76 </html>