Web Inspector: implement import/export for timeline data.
[WebKit-https.git] / LayoutTests / inspector / timeline / timeline-load.html
1 <html>
2 <head>
3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="timeline-test.js"></script>
5 <script>
6
7 function test()
8 {
9     WebInspector.showPanel("timeline");
10     InspectorTest.addSniffer(WebInspector.TimelineModel.prototype, "_importNextChunk", importNextChunk);
11     InspectorFrontendHost.saveAs = saveAs;
12     var data = [
13         {"startTime":1310749854316.8408,"data":{"identifier":43,"url":"http://www.webkit.org/","requestMethod":"GET"},"type":"ResourceSendRequest","usedHeapSize":1819936,"totalHeapSize":7629120},
14         {"startTime":1310749855118.9329,"data":{"identifier":43,"statusCode":200,"mimeType":"text/html"},"children":[],"endTime":1310749855118.968,"type":"ResourceReceiveResponse","usedHeapSize":1819936,"totalHeapSize":7629120},
15         {"startTime":1310749855136.245,"data":{"identifier":44,"url":"http://www.webkit.org/css/main.css","requestMethod":"GET"},"type":"ResourceSendRequest","usedHeapSize":2367192,"totalHeapSize":7629120},
16         {"startTime":1310749855136.655,"data":{"identifier":45,"url":"http://www.webkit.org/css/green.css","requestMethod":"GET"},"type":"ResourceSendRequest","usedHeapSize":2367192,"totalHeapSize":7629120},
17         {"startTime":1310749855137.023,"data":{"identifier":46,"url":"http://www.webkit.org/css/blue.css","requestMethod":"GET"},"type":"ResourceSendRequest","usedHeapSize":2367192,"totalHeapSize":7629120},
18         {"startTime":1310749855137.342,"data":{"identifier":47,"url":"http://www.webkit.org/css/yellow.css","requestMethod":"GET"},"type":"ResourceSendRequest","usedHeapSize":2367192,"totalHeapSize":7629120},
19         {"startTime":1310749855137.656,"data":{"identifier":48,"url":"http://www.webkit.org/css/pink.css","requestMethod":"GET"},"type":"ResourceSendRequest","usedHeapSize":2367192,"totalHeapSize":7629120},
20         {"startTime":1310749855137.989,"data":{"identifier":49,"url":"http://www.webkit.org/css/purple.css","requestMethod":"GET"},"type":"ResourceSendRequest","usedHeapSize":2367192,"totalHeapSize":7629120},
21         {"startTime":1310749855138.308,"data":{"identifier":50,"url":"http://www.webkit.org/css/gray.css","requestMethod":"GET"},"type":"ResourceSendRequest","usedHeapSize":2367192,"totalHeapSize":7629120}];
22
23     WebInspector.panels.timeline._model._importNextChunk(data, 0);
24
25     function importNextChunk()
26     {
27         WebInspector.panels.timeline._model._exportToFile();
28     }
29
30     function saveAs(name, saveData)
31     {
32         saveData = JSON.parse(saveData);
33         saveData.shift(); // strip version info
34         if (JSON.stringify(data) == JSON.stringify(saveData))
35             InspectorTest.addResult("passed");
36         else
37             InspectorTest.addResult("saved data is not equal to restored");
38         InspectorTest.completeTest();
39     }
40 }
41
42 </script>
43 </head>
44
45 <body onload="runTest()">
46 <p>
47 Tests the Timeline save/load functionality.
48 </p>
49
50 </body>
51 </html>