3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
6 function testFunction()
8 var div = document.querySelector("#my-div");
9 div.addEventListener("click", function(e) { }, false);
12 var iframe = document.createElement("iframe");
13 div.appendChild(iframe);
18 InspectorTest.eventHandler["Tracing.dataCollected"] = dataCollected;
19 InspectorTest.eventHandler["Tracing.tracingComplete"] = tracingComplete;
20 InspectorTest.sendCommand("Tracing.start", { "categories" : "disabled-by-default-devtools.timeline", "type": "" }, onStart);
22 function onStart(response)
24 InspectorTest.log("Recording started");
25 InspectorTest.sendCommand("Runtime.evaluate", { "expression": "testFunction()" }, didEvaluate);
28 function didEvaluate(response)
30 InspectorTest.sendCommand("Tracing.end", { }, onStop);
33 var devtoolsEvents = [];
34 function dataCollected(reply)
36 var allEvents = reply.params.value;
37 devtoolsEvents = devtoolsEvents.concat(allEvents.filter(function(e)
39 return e.cat === "disabled-by-default-devtools.timeline";
43 function tracingComplete(event)
45 InspectorTest.log("Tracing complete");
47 function windowEventFilter(type, e)
49 return e.name === "EventDispatch" && e.args.type === type;
52 var windowEventNames = [ "click", "beforeunload", "unload", "load" ];
53 for (var i = 0; i < windowEventNames.length; i++) {
54 var eventName = windowEventNames[i];
55 var events = devtoolsEvents.filter(windowEventFilter.bind(this, eventName));
56 if (events.length >= 1) {
57 InspectorTest.log("SUCCESS: found " + eventName + " event");
59 fail(eventName + " event is missing");
63 InspectorTest.completeTest();
67 function fail(message)
69 var formattedEvents = devtoolsEvents.map(function(e)
71 return e.name + "(" + e.args.type + ")";
73 InspectorTest.log("FAIL: " + message + " devtools.timeline events: " + JSON.stringify(formattedEvents, null, 2));
76 function onStop(response)
78 InspectorTest.log("Recording stopped");
83 <body onLoad="runTest();">
84 <div id="my-div"></div>