OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto
r-protocol-test.js"></script> | 3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto
r-protocol-test.js"></script> |
| 4 <script type="text/javascript" src="../../http/tests/inspector-protocol/tracing-
test.js"></script> |
4 <script> | 5 <script> |
5 | 6 |
6 function testFunction() | 7 function performActions(callback) |
7 { | 8 { |
8 var rafId1 = requestAnimationFrame(function() | 9 var rafId1 = requestAnimationFrame(function() |
9 { | 10 { |
10 evaluateInFrontend("InspectorTest.testFunctionRequestAnimationFrame(" +
rafId1 + ", " + rafId2 + ")"); | 11 evaluateInFrontend("InspectorTest.testFunctionRequestAnimationFrame(" +
rafId1 + ", " + rafId2 + ")"); |
| 12 callback(); |
11 }); | 13 }); |
12 | 14 |
13 var rafId2 = requestAnimationFrame(function() { }); | 15 var rafId2 = requestAnimationFrame(function() { }); |
14 cancelAnimationFrame(rafId2); | 16 cancelAnimationFrame(rafId2); |
15 } | 17 } |
16 | 18 |
17 function test() | 19 function test() |
18 { | 20 { |
19 InspectorTest.eventHandler["Tracing.dataCollected"] = dataCollected; | 21 InspectorTest.invokeAsyncWithTracing("performActions", finish); |
20 InspectorTest.eventHandler["Tracing.tracingComplete"] = tracingComplete; | |
21 InspectorTest.sendCommand("Tracing.start", { "categories" : "disabled-by-def
ault-devtools.timeline", "type": "" }, onStart); | |
22 | 22 |
23 var firedRaf; | 23 var firedRaf; |
24 var canceledRaf; | 24 var canceledRaf; |
25 InspectorTest.testFunctionRequestAnimationFrame = function(rafId1, rafId2) | 25 InspectorTest.testFunctionRequestAnimationFrame = function(rafId1, rafId2) |
26 { | 26 { |
27 firedRaf = rafId1; | 27 firedRaf = rafId1; |
28 canceledRaf = rafId2; | 28 canceledRaf = rafId2; |
29 InspectorTest.log("SUCCESS: testFunctionRequestAnimationFrame"); | 29 InspectorTest.log("SUCCESS: testFunctionRequestAnimationFrame"); |
30 InspectorTest.sendCommand("Tracing.end", { }, onStop); | |
31 } | 30 } |
32 | 31 |
33 function onStart(response) | 32 function finish(devtoolsEvents) |
34 { | 33 { |
35 InspectorTest.log("Recording started"); | |
36 InspectorTest.sendCommand("Runtime.evaluate", { "expression": "testFunct
ion()" }); | |
37 } | |
38 | |
39 var devtoolsEvents = []; | |
40 function dataCollected(reply) | |
41 { | |
42 var allEvents = reply.params.value; | |
43 devtoolsEvents = devtoolsEvents.concat(allEvents.filter(function(e) | |
44 { | |
45 return e.cat === "disabled-by-default-devtools.timeline"; | |
46 })); | |
47 } | |
48 | |
49 function tracingComplete(event) | |
50 { | |
51 InspectorTest.log("Tracing complete"); | |
52 | |
53 function hasRafId(id, e) { return e.args.data.id === id} | 34 function hasRafId(id, e) { return e.args.data.id === id} |
54 | 35 |
55 var raf1 = findEvent("RequestAnimationFrame", "I", hasRafId.bind(this, f
iredRaf)); | 36 var raf1 = InspectorTest.findEvent("RequestAnimationFrame", "I", hasRafI
d.bind(this, firedRaf)); |
56 var raf2 = findEvent("RequestAnimationFrame", "I", hasRafId.bind(this, c
anceledRaf)); | 37 var raf2 = InspectorTest.findEvent("RequestAnimationFrame", "I", hasRafI
d.bind(this, canceledRaf)); |
57 | 38 |
58 InspectorTest.assert(!!raf1.args.data.frame, "RequestAnimationFrame fram
e"); | 39 InspectorTest.assert(!!raf1.args.data.frame, "RequestAnimationFrame fram
e"); |
59 InspectorTest.assertEquals(raf1.args.data.frame, raf2.args.data.frame, "
RequestAnimationFrame frame match"); | 40 InspectorTest.assertEquals(raf1.args.data.frame, raf2.args.data.frame, "
RequestAnimationFrame frame match"); |
60 | 41 |
61 findEvent("CancelAnimationFrame", "I", hasRafId.bind(this, canceledRaf))
; | 42 InspectorTest.findEvent("CancelAnimationFrame", "I", hasRafId.bind(this,
canceledRaf)); |
62 findEvent("FireAnimationFrame", "X", hasRafId.bind(this, firedRaf)); | 43 InspectorTest.findEvent("FireAnimationFrame", "X", hasRafId.bind(this, f
iredRaf)); |
63 | 44 |
64 InspectorTest.log("SUCCESS: found all expected events."); | 45 InspectorTest.log("SUCCESS: found all expected events."); |
65 InspectorTest.completeTest(); | 46 InspectorTest.completeTest(); |
66 } | 47 } |
67 | |
68 function findEvent(name, ph, condition) | |
69 { | |
70 for (var i = 0; i < devtoolsEvents.length; i++) { | |
71 var e = devtoolsEvents[i]; | |
72 if (e.name === name && e.ph === ph && (!condition || condition(e))) | |
73 return e; | |
74 } | |
75 throw new Error("Couldn't find event " + name + " / " + ph + "\n\n in "
+ JSON.stringify(devtoolsEvents, null, 2)); | |
76 } | |
77 | |
78 function onStop(response) | |
79 { | |
80 InspectorTest.log("Recording stopped"); | |
81 } | |
82 } | 48 } |
83 </script> | 49 </script> |
84 </head> | 50 </head> |
85 <body onLoad="runTest();"> | 51 <body onLoad="runTest();"> |
86 <div id="myDiv">DIV</div> | 52 <div id="myDiv">DIV</div> |
87 </body> | 53 </body> |
88 </html> | 54 </html> |
OLD | NEW |