c3cc9d094fd6bf5c0ef2c03592a77ed1037fe8d0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / tracing / 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(callback)
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(event) { callback(); }  // do not pass event argument to the callback.
16         image.src = "resources/anotherImage.png";
17     }
18 }
19
20 function test()
21 {
22     WebInspector.inspectorView.showPanel("timeline");
23     WebInspector.inspectorView.panel("timeline")._model._currentTarget = WebInspector.targetManager.mainTarget();
24     InspectorTest.invokeAsyncWithTimeline("performActions", finish);
25
26     function finish()
27     {
28         function dumpFormattedRecord(presentationRecord, prefix)
29         {
30             var record = presentationRecord.record();
31             prefix = prefix || "";
32             // Here and below: pretend coalesced record are just not there, as coalescation is time dependent and, hence, not stable.
33             var categoryName = WebInspector.panels.timeline._uiUtils.categoryForRecord(record).name;
34             if (categoryName !== "loading" && categoryName !== "scripting")
35                 return;
36             var childPrefix = prefix;
37             // Filter out InjectedScript function call because they happen out of sync.
38             if (!presentationRecord.coalesced()
39                 && record.type() !== "GCEvent"
40                 && (record.type() !== "FunctionCall" || record.data().scriptName !== "InjectedScript")) {
41                 InspectorTest.addResult(prefix + record.type());
42                 childPrefix = childPrefix + "    ";
43             }
44             // Ignore stray paint & rendering events for better stability.
45             if (presentationRecord.presentationChildren()) {
46                 for (var i = 0; i < presentationRecord.presentationChildren().length; ++i)
47                     dumpFormattedRecord(presentationRecord.presentationChildren()[i], childPrefix);
48             }
49         }
50         var records = WebInspector.panels.timeline._currentViews[0]._rootRecord().presentationChildren();
51         for (var i = 0; i < records.length; ++i)
52             dumpFormattedRecord(records[i]);
53         InspectorTest.completeTest();
54     }
55 }
56
57 if (!window.testRunner)
58     setTimeout(performActions, 3000);
59
60 </script>
61 </head>
62
63 <body onload="runTest()">
64 <p>
65 Tests the Timeline API instrumentation of a SendRequest, ReceiveResponse etc.
66 </p>
67
68 </body>
69 </html>