| OLD | NEW |
| (Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto
r-protocol-test.js"></script> |
| 4 <script> |
| 5 |
| 6 function testFunction() |
| 7 { |
| 8 var div = document.querySelector("#my-div"); |
| 9 div.addEventListener("click", function(e) { }, false); |
| 10 div.click(); |
| 11 |
| 12 var iframe = document.createElement("iframe"); |
| 13 div.appendChild(iframe); |
| 14 } |
| 15 |
| 16 function test() |
| 17 { |
| 18 InspectorTest.eventHandler["Tracing.dataCollected"] = dataCollected; |
| 19 InspectorTest.eventHandler["Tracing.tracingComplete"] = tracingComplete; |
| 20 InspectorTest.sendCommand("Tracing.start", { "categories" : "disabled-by-def
ault-devtools-timeline", "type": "" }, onStart); |
| 21 |
| 22 function onStart(response) |
| 23 { |
| 24 InspectorTest.log("Recording started"); |
| 25 InspectorTest.sendCommand("Runtime.evaluate", { "expression": "testFunct
ion()" }, didEvaluate); |
| 26 } |
| 27 |
| 28 function didEvaluate(response) |
| 29 { |
| 30 InspectorTest.sendCommand("Tracing.end", { }, onStop); |
| 31 } |
| 32 |
| 33 var devtoolsEvents = []; |
| 34 function dataCollected(reply) |
| 35 { |
| 36 var allEvents = reply.params.value; |
| 37 devtoolsEvents = devtoolsEvents.concat(allEvents.filter(function(e) |
| 38 { |
| 39 return e.cat === "disabled-by-default-devtools-timeline"; |
| 40 })); |
| 41 } |
| 42 |
| 43 function tracingComplete(event) |
| 44 { |
| 45 InspectorTest.log("Tracing complete"); |
| 46 |
| 47 var clickEvents = devtoolsEvents.filter(function(e) |
| 48 { |
| 49 return e.name === "EventDispatcher::dispatch" && e.args.type === "cl
ick"; |
| 50 }); |
| 51 if (clickEvents.length === 1) { |
| 52 InspectorTest.log("SUCCESS: found click event"); |
| 53 } else { |
| 54 fail("click event is missing"); |
| 55 } |
| 56 |
| 57 function windowEventFilter(type, e) |
| 58 { |
| 59 return e.name === "DOMWindow::dispatchEvent" && e.args.type === type
; |
| 60 }; |
| 61 |
| 62 var windowEventNames = [ "beforeunload", "unload", "load" ]; |
| 63 for (var i = 0; i < windowEventNames.length; i++) { |
| 64 var eventName = windowEventNames[i]; |
| 65 var events = devtoolsEvents.filter(windowEventFilter.bind(this, even
tName)); |
| 66 if (clickEvents.length === 1) { |
| 67 InspectorTest.log("SUCCESS: found one " + eventName + " event"); |
| 68 } else { |
| 69 fail(eventName + " event is missing"); |
| 70 } |
| 71 } |
| 72 |
| 73 InspectorTest.completeTest(); |
| 74 } |
| 75 |
| 76 |
| 77 function fail(message) |
| 78 { |
| 79 var formattedEvents = devtoolsEvents.map(function(e) |
| 80 { |
| 81 return e.name + "(" + e.args.type + ")"; |
| 82 }); |
| 83 InspectorTest.log("FAIL: " + message + " devtools-timeline events: " + J
SON.stringify(formattedEvents, null, 2)); |
| 84 } |
| 85 |
| 86 function onStop(response) |
| 87 { |
| 88 InspectorTest.log("Recording stopped"); |
| 89 } |
| 90 } |
| 91 </script> |
| 92 </head> |
| 93 <body onLoad="runTest();"> |
| 94 <div id="my-div"></div> |
| 95 </body> |
| 96 </html> |
| OLD | NEW |