OLD | NEW |
| (Empty) |
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 src="../../tracing-test.js"></script> | |
6 <script> | |
7 | |
8 function test() | |
9 { | |
10 function runTestWithDataAndCheck(input, expectedOutput) | |
11 { | |
12 var model = InspectorTest.tracingTimelineModel; | |
13 | |
14 function createFileReader(file, delegate) | |
15 { | |
16 return new InspectorTest.FakeFileReader(input, delegate, model.saveT
oFile.bind(model)); | |
17 } | |
18 | |
19 function createFileWriter() | |
20 { | |
21 return new InspectorTest.StringOutputStream(checkSaveData); | |
22 } | |
23 | |
24 function checkSaveData(output) | |
25 { | |
26 var saveData = JSON.parse(output); | |
27 InspectorTest.assertEquals(JSON.stringify(expectedOutput), JSON.stri
ngify(saveData), "saved data is not equal to restored"); | |
28 } | |
29 | |
30 InspectorTest.override(model, "_createFileReader", createFileReader); | |
31 InspectorTest.override(model, "_createFileWriter", createFileWriter); | |
32 | |
33 model.loadFromFile({}, new WebInspector.Progress()); | |
34 } | |
35 | |
36 function runTestOnMalformedInput(input) | |
37 { | |
38 InspectorTest.tracingModel.reset(); | |
39 var model = InspectorTest.tracingTimelineModel; | |
40 model.reset(); | |
41 function createFileReader(file, delegate) | |
42 { | |
43 return new InspectorTest.FakeFileReader(input, delegate, checkLoaded
Data); | |
44 } | |
45 | |
46 function checkLoadedData(data) | |
47 { | |
48 InspectorTest.assertTrue(model.isEmpty()); | |
49 } | |
50 | |
51 InspectorTest.override(model, "_createFileReader", createFileReader); | |
52 model.loadFromFile({}, new WebInspector.Progress()); | |
53 } | |
54 | |
55 InspectorTest.runTestSuite([ | |
56 function testNormal(next) | |
57 { | |
58 var data = [{"args":{"number":32},"cat":"__metadata","name":"num_cpu
s","ph":"M","pid":32127,"tid":0,"ts":0}, | |
59 {"args":{"sort_index":-5},"cat":"__metadata","name":"process_sor
t_index","ph":"M","pid":32127,"tid":12,"ts":0}, | |
60 {"args":{"name":"Renderer"},"cat":"__metadata","name":"process_n
ame","ph":"M","pid":32127,"tid":12,"ts":0}, | |
61 {"args":{"sort_index":-1},"cat":"__metadata","name":"thread_sort
_index","ph":"M","pid":32127,"tid":11,"ts":0}, | |
62 {"args":{},"cat":"disabled-by-default-devtools.timeline","name":
"Program","ph":"B","pid":32120,"tid":9,"ts":95904702436,"tts":1161841}, | |
63 {"args":{"number":32},"cat":"__metadata","name":"num_cpus","ph":
"M","pid":32120,"tid":0,"ts":0}, | |
64 {"args":{"sort_index":-5},"cat":"__metadata","name":"process_sor
t_index","ph":"M","pid":32120,"tid":10,"ts":0}, | |
65 {"args":{"name":"Renderer"},"cat":"__metadata","name":"process_n
ame","ph":"M","pid":32120,"tid":10,"ts":0}, | |
66 {"args":{"sort_index":-1},"cat":"__metadata","name":"thread_sort
_index","ph":"M","pid":32120,"tid":9,"ts":0}, | |
67 {"args":{"name":"CrRendererMain"},"cat":"__metadata","name":"thr
ead_name","ph":"M","pid":32120,"tid":9,"ts":0}, | |
68 {"args":{"data":{"frame":"0x1cfa1f6a4000","scriptId":"52","scrip
tLine":664,"scriptName":"http://example.com/foo.js"}},"cat":"disabled-by-default
-devtools.timeline","dur":21,"name":"FunctionCall","ph":"X","pid":32169,"tdur":2
0,"tid":35,"ts":95904848776,"tts":2613659}, | |
69 {"args":{"stack":[]},"cat":"disabled-by-default-devtools.timelin
e.stack","name":"CallStack","ph":"I","pid":32169,"s":"g","tid":35,"ts":959048487
83,"tts":2613665}, | |
70 {"args":{"data":{"frame":"0x1cfa1f6a4000","scriptId":"52","scrip
tLine":664,"scriptName":"http://example.com/foo.js"}},"cat":"disabled-by-default
-devtools.timeline","dur":20,"name":"FunctionCall","ph":"X","pid":32169,"tdur":1
8,"tid":35,"ts":95904848821,"tts":2613704}, | |
71 {"args":{"stack":[]},"cat":"disabled-by-default-devtools.timelin
e.stack","name":"CallStack","ph":"I","pid":32169,"s":"g","tid":35,"ts":959048488
27,"tts":2613710}, | |
72 {"args":{"data":{"frame":"0x1cfa1f6a4000","scriptId":"52","scrip
tLine":664,"scriptName":"http://example.com/foo.js"}},"cat":"disabled-by-default
-devtools.timeline","dur":19,"name":"FunctionCall","ph":"X","pid":32169,"tdur":1
8,"tid":35,"ts":95904848866,"tts":2613749}, | |
73 {"args":{"stack":[]},"cat":"disabled-by-default-devtools.timelin
e.stack","name":"CallStack","ph":"I","pid":32169,"s":"g","tid":35,"ts":959048488
72,"tts":2613755}, | |
74 {"args":{"data":{"frame":"0x1cfa1f6a4000","scriptId":"52","scrip
tLine":664,"scriptName":"http://example.com/foo.js"}},"cat":"disabled-by-default
-devtools.timeline","dur":19,"name":"FunctionCall","ph":"X","pid":32169,"tdur":1
9,"tid":35,"ts":95904848909,"tts":2613791}, | |
75 {"args":{"stack":[]},"cat":"disabled-by-default-devtools.timelin
e.stack","name":"CallStack","ph":"I","pid":32169,"s":"g","tid":35,"ts":959048489
15,"tts":2613797}, | |
76 {"args":{"data":{"frame":"0x1cfa1f6a4000","scriptId":"52","scrip
tLine":664,"scriptName":"http://example.com/foo.js"}},"cat":"disabled-by-default
-devtools.timeline","dur":21,"name":"FunctionCall","ph":"X","pid":32169,"tdur":1
9,"tid":35,"ts":95904848954,"tts":2613837}, | |
77 {"args":{"stack":[]},"cat":"disabled-by-default-devtools.timelin
e.stack","name":"CallStack","ph":"I","pid":32169,"s":"g","tid":35,"ts":959048489
61,"tts":2613843}, | |
78 {"args":{"sessionId":"26.5"},"cat":"disabled-by-default-devtools
.timeline","name":"TracingStartedInPage","ph":"I","pid":32157,"s":"g","tid":26,"
ts":95904694459,"tts":1432596}, | |
79 {"args":{"layerTreeId":1,"sessionId":"26.5"},"cat":"disabled-by-
default-devtools.timeline","name":"SetLayerTreeId","ph":"I","pid":32157,"s":"g",
"tid":26,"ts":95904694693,"tts":1432692}, | |
80 {"args":{},"cat":"disabled-by-default-devtools.timeline","name":
"Program","ph":"E","pid":32157,"tid":26,"ts":95904694731,"tts":1432729}, | |
81 {"args":{},"cat":"disabled-by-default-devtools.timeline","name":
"Program","ph":"B","pid":32157,"tid":26,"ts":95904694789,"tts":1432787}, | |
82 {"args":{"data":{"type":"beforeunload"}},"cat":"disabled-by-defa
ult-devtools.timeline","dur":16,"name":"EventDispatch","ph":"X","pid":32157,"tdu
r":13,"tid":26,"ts":95904695027,"tts":1433025}, | |
83 {"args":{"data":{"frame":"0x30acf4ca4000","requestId":"26.422","
requestMethod":"GET","url":"http://localhost/bar.html?ws=E16865E8B9D1"}},"cat":"
disabled-by-default-devtools.timeline","name":"ResourceSendRequest","ph":"I","pi
d":32157,"s":"g","tid":26,"ts":95904695434,"tts":1433433}, | |
84 {"args":{"stack":null},"cat":"disabled-by-default-devtools.timel
ine.stack","name":"CallStack","ph":"I","pid":32157,"s":"g","tid":26,"ts":9590469
5455,"tts":1433453}, | |
85 {"args":{},"cat":"disabled-by-default-devtools.timeline","name":
"Program","ph":"E","pid":32157,"tid":26,"ts":95904695551,"tts":1433549}, | |
86 {"args":{},"cat":"disabled-by-default-devtools.timeline","name":
"Program","ph":"B","pid":32157,"tid":26,"ts":95904696695,"tts":1433692}, | |
87 {"args":{},"cat":"disabled-by-default-devtools.timeline","name":
"Program","ph":"E","pid":32157,"tid":26,"ts":95904696737,"tts":1433733}, | |
88 {"args":{"data":{"frame":"0x30acf4ca4000","mimeType":"text/html"
,"requestId":"26.422","statusCode":200}},"cat":"disabled-by-default-devtools.tim
eline","name":"ResourceReceiveResponse","ph":"I","pid":32157,"s":"g","tid":26,"t
s":95904699823,"tts":1433961}, | |
89 {"args":{"data":{"frame":"0x30acf4ca4000","identifier":406}},"ca
t":"disabled-by-default-devtools.timeline","name":"WebSocketDestroy","ph":"I","p
id":32157,"s":"g","tid":26,"ts":95904701483,"tts":1435612}, | |
90 {"args":{"stack":null},"cat":"disabled-by-default-devtools.timel
ine.stack","name":"CallStack","ph":"I","pid":32157,"s":"g","tid":26,"ts":9590470
1489,"tts":1435618}, | |
91 {"args":{"number":32},"cat":"__metadata","name":"num_cpus","ph":
"M","pid":32072,"tid":0,"ts":0}, | |
92 {"args":{"sort_index":-6},"cat":"__metadata","name":"process_sor
t_index","ph":"M","pid":32072,"tid":32096,"ts":0}, | |
93 {"args":{"name":"Browser"},"cat":"__metadata","name":"process_na
me","ph":"M","pid":32072,"tid":32096,"ts":0}, | |
94 {"args":{"name":"CrBrowserMain"},"cat":"__metadata","name":"thre
ad_name","ph":"M","pid":32072,"tid":32072,"ts":0} | |
95 ]; | |
96 var input = JSON.stringify(data); | |
97 runTestWithDataAndCheck(input, data); | |
98 next(); | |
99 }, | |
100 | |
101 function testBroken(next) | |
102 { | |
103 var data = [{"args":{"number":32},"cat":"__metadata","name":"num_cpu
s","ph":"M","pid":32127,"tid":0,"ts":0,"t\"y}p}e\\":"UnknownRecordType"}]; | |
104 runTestOnMalformedInput(JSON.stringify(data)); | |
105 next(); | |
106 }, | |
107 | |
108 function testMalformedJSON(next) | |
109 { | |
110 runTestOnMalformedInput("]"); | |
111 next(); | |
112 } | |
113 ]); | |
114 } | |
115 | |
116 </script> | |
117 </head> | |
118 | |
119 <body onload="runTest()"> | |
120 <p> | |
121 Tests tracing based Timeline save/load functionality. | |
122 </p> | |
123 </body> | |
124 </html> | |
OLD | NEW |