Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / timeline / timeline-receive-response-event.html
1 <html>
2 <head>
3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/timeline-test.js"></script>
5 <script>
6
7 function performActions()
8 {
9     var image = new Image();
10     image.onload = bar;
11     image.src = "resources/anImage.png";
12
13     function bar() {
14         var image = new Image();
15         image.onload = function() { testRunner.evaluateInWebInspector(0, "window.step2()"); }
16         image.src = "resources/anotherImage.png";
17     }
18 }
19
20 function test()
21 {
22     WebInspector.inspectorView.showPanel("timeline");
23     WebInspector.panels.timeline._model._collectionEnabled = true;
24
25     TimelineAgent.start(step1);
26
27     function step1()
28     {
29         InspectorTest.evaluateInPage("performActions()");
30     }
31
32     window.step2 = function()
33     {
34         TimelineAgent.stop(step3);
35     }
36
37     function step3()
38     {
39         function dumpFormattedRecord(presentationRecord, prefix)
40         {
41             var record = presentationRecord.record();
42             prefix = prefix || "";
43             // Here and below: pretend coalesced record are just not there, as coalescation is time dependent and, hence, not stable.
44             if (!presentationRecord.coalesced() && record.type() !== "GCEvent")
45                 InspectorTest.addResult(prefix + record.type());
46             // Ignore stray paint & rendering events for better stability.
47             if (record.category().name !== "loading" && record.category().name !== "scripting")
48                 return;
49             if (presentationRecord.presentationChildren()) {
50                 var childPrefix = prefix + (presentationRecord.coalesced() ? "" : "    ");
51                 for (var i = 0; i < presentationRecord.presentationChildren().length; ++i)
52                     dumpFormattedRecord(presentationRecord.presentationChildren()[i], childPrefix);
53             }
54         }
55         WebInspector.panels.timeline._model._collectionEnabled = false;
56
57         var records = WebInspector.panels.timeline._currentViews[0]._rootRecord().presentationChildren();
58         for (var i = 0; i < records.length; ++i)
59             dumpFormattedRecord(records[i]);
60         InspectorTest.completeTest();
61     }
62 }
63
64 if (!window.testRunner)
65     setTimeout(performActions, 3000);
66
67 </script>
68 </head>
69
70 <body onload="runTest()">
71 <p>
72 Tests the Timeline API instrumentation of a SendRequest, ReceiveResponse etc.
73 </p>
74
75 </body>
76 </html>