OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <style> | 3 <style> |
4 .my-class { | 4 .my-class { |
5 min-width: 100px; | 5 min-width: 100px; |
6 background-color: red; | 6 background-color: red; |
7 } | 7 } |
8 </style> | 8 </style> |
9 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto
r-protocol-test.js"></script> | 9 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto
r-protocol-test.js"></script> |
| 10 <script type="text/javascript" src="../../http/tests/inspector-protocol/tracing-
test.js"></script> |
10 <script> | 11 <script> |
11 | 12 |
12 function testFunction() | 13 function performActions(callback) |
13 { | 14 { |
14 var div = document.querySelector("#myDiv"); | 15 var div = document.querySelector("#myDiv"); |
15 div.classList.add("my-class"); | 16 div.classList.add("my-class"); |
16 div.offsetWidth; | 17 div.offsetWidth; |
| 18 callback(); |
17 } | 19 } |
18 | 20 |
19 function test() | 21 function test() |
20 { | 22 { |
21 InspectorTest.eventHandler["Tracing.dataCollected"] = dataCollected; | 23 InspectorTest.invokeAsyncWithTracing("performActions", finish); |
22 InspectorTest.eventHandler["Tracing.tracingComplete"] = tracingComplete; | |
23 InspectorTest.sendCommand("Tracing.start", { "categories" : "disabled-by-def
ault-devtools.timeline", "type": "" }, onStart); | |
24 | 24 |
25 function onStart(response) | 25 function finish(devtoolsEvents) |
26 { | 26 { |
27 InspectorTest.log("Recording started"); | 27 var schedRecalc = InspectorTest.findEvent("ScheduleStyleRecalculation",
"I"); |
28 InspectorTest.sendCommand("Runtime.evaluate", { "expression": "testFunct
ion()" }, didEvaluate); | 28 var recalcBegin = InspectorTest.findEvent("RecalculateStyles", "B"); |
29 } | 29 var recalcEnd = InspectorTest.findEvent("RecalculateStyles", "E"); |
30 | |
31 function didEvaluate(response) | |
32 { | |
33 InspectorTest.sendCommand("Tracing.end", { }, onStop); | |
34 } | |
35 | |
36 var devtoolsEvents = []; | |
37 function dataCollected(reply) | |
38 { | |
39 var allEvents = reply.params.value; | |
40 devtoolsEvents = devtoolsEvents.concat(allEvents.filter(function(e) | |
41 { | |
42 return e.cat === "disabled-by-default-devtools.timeline"; | |
43 })); | |
44 } | |
45 | |
46 function tracingComplete(event) | |
47 { | |
48 InspectorTest.log("Tracing complete"); | |
49 | |
50 var schedRecalc = findEvent("ScheduleStyleRecalculation", "I"); | |
51 var recalcBegin = findEvent("RecalculateStyles", "B"); | |
52 var recalcEnd = findEvent("RecalculateStyles", "E"); | |
53 InspectorTest.assertEquals(schedRecalc.args.frame, recalcBegin.args.fram
e, "RecalculateStyles frame"); | 30 InspectorTest.assertEquals(schedRecalc.args.frame, recalcBegin.args.fram
e, "RecalculateStyles frame"); |
54 InspectorTest.assert(recalcEnd.args.elementCount > 0, "RecalculateStyles
elementCount"); | 31 InspectorTest.assert(recalcEnd.args.elementCount > 0, "RecalculateStyles
elementCount"); |
55 | 32 |
56 var invalidate = findEvent("InvalidateLayout", "I"); | 33 var invalidate = InspectorTest.findEvent("InvalidateLayout", "I"); |
57 var layoutBegin = findEvent("Layout", "B"); | 34 var layoutBegin = InspectorTest.findEvent("Layout", "B"); |
58 var layoutEnd = findEvent("Layout", "E"); | 35 var layoutEnd = InspectorTest.findEvent("Layout", "E"); |
59 | 36 |
60 InspectorTest.assertEquals(recalcBegin.args.frame, invalidate.args.frame
, "InvalidateLayout frame"); | 37 InspectorTest.assertEquals(recalcBegin.args.frame, invalidate.args.frame
, "InvalidateLayout frame"); |
61 | 38 |
62 var beginData = layoutBegin.args.beginData; | 39 var beginData = layoutBegin.args.beginData; |
63 InspectorTest.assertEquals(invalidate.args.frame, beginData.frame, "Layo
ut frame"); | 40 InspectorTest.assertEquals(invalidate.args.frame, beginData.frame, "Layo
ut frame"); |
64 InspectorTest.assert(beginData.dirtyObjects > 0, "dirtyObjects"); | 41 InspectorTest.assert(beginData.dirtyObjects > 0, "dirtyObjects"); |
65 InspectorTest.assert(beginData.totalObjects > 0, "totalObjects"); | 42 InspectorTest.assert(beginData.totalObjects > 0, "totalObjects"); |
66 | 43 |
67 var endData = layoutEnd.args.endData; | 44 var endData = layoutEnd.args.endData; |
68 InspectorTest.assert(endData.rootNode > 0, "rootNode id"); | 45 InspectorTest.assert(endData.rootNode > 0, "rootNode id"); |
69 InspectorTest.assert(!!endData.root , "root quad"); | 46 InspectorTest.assert(!!endData.root , "root quad"); |
70 | 47 |
71 InspectorTest.log("SUCCESS: found all expected events."); | 48 InspectorTest.log("SUCCESS: found all expected events."); |
72 InspectorTest.completeTest(); | 49 InspectorTest.completeTest(); |
73 } | 50 } |
74 | 51 |
75 function findEvent(name, ph) | |
76 { | |
77 for (var i = 0; i < devtoolsEvents.length; i++) { | |
78 var e = devtoolsEvents[i]; | |
79 if (e.name === name && e.ph === ph) | |
80 return e; | |
81 } | |
82 throw new Error("Couldn't find event " + name + " / " + ph + "\n\n in "
+ JSON.stringify(devtoolsEvents, null, 2)); | |
83 } | |
84 | |
85 function onStop(response) | |
86 { | |
87 InspectorTest.log("Recording stopped"); | |
88 } | |
89 } | 52 } |
90 </script> | 53 </script> |
91 </head> | 54 </head> |
92 <body onLoad="runTest();"> | 55 <body onLoad="runTest();"> |
93 <div id="myDiv">DIV</div> | 56 <div id="myDiv">DIV</div> |
94 </body> | 57 </body> |
95 </html> | 58 </html> |
OLD | NEW |