Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(854)

Unified Diff: LayoutTests/inspector-protocol/timeline/timeline-dispatchEvent.html

Issue 239303003: Add devtools trace event for event dispatching (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/inspector-protocol/timeline/timeline-dispatchEvent-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/inspector-protocol/timeline/timeline-dispatchEvent.html
diff --git a/LayoutTests/inspector-protocol/timeline/timeline-dispatchEvent.html b/LayoutTests/inspector-protocol/timeline/timeline-dispatchEvent.html
new file mode 100644
index 0000000000000000000000000000000000000000..9a9a85462d55a8bb9665a6a5ab9304e9fe9b6f66
--- /dev/null
+++ b/LayoutTests/inspector-protocol/timeline/timeline-dispatchEvent.html
@@ -0,0 +1,96 @@
+<html>
+<head>
+<script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
+<script>
+
+function testFunction()
+{
+ var div = document.querySelector("#my-div");
+ div.addEventListener("click", function(e) { }, false);
+ div.click();
+
+ var iframe = document.createElement("iframe");
+ div.appendChild(iframe);
+}
+
+function test()
+{
+ InspectorTest.eventHandler["Tracing.dataCollected"] = dataCollected;
+ InspectorTest.eventHandler["Tracing.tracingComplete"] = tracingComplete;
+ InspectorTest.sendCommand("Tracing.start", { "categories" : "disabled-by-default-devtools-timeline", "type": "" }, onStart);
+
+ function onStart(response)
+ {
+ InspectorTest.log("Recording started");
+ InspectorTest.sendCommand("Runtime.evaluate", { "expression": "testFunction()" }, didEvaluate);
+ }
+
+ function didEvaluate(response)
+ {
+ InspectorTest.sendCommand("Tracing.end", { }, onStop);
+ }
+
+ var devtoolsEvents = [];
+ function dataCollected(reply)
+ {
+ var allEvents = reply.params.value;
+ devtoolsEvents = devtoolsEvents.concat(allEvents.filter(function(e)
+ {
+ return e.cat === "disabled-by-default-devtools-timeline";
+ }));
+ }
+
+ function tracingComplete(event)
+ {
+ InspectorTest.log("Tracing complete");
+
+ var clickEvents = devtoolsEvents.filter(function(e)
+ {
+ return e.name === "EventDispatcher::dispatch" && e.args.type === "click";
+ });
+ if (clickEvents.length === 1) {
+ InspectorTest.log("SUCCESS: found click event");
+ } else {
+ fail("click event is missing");
+ }
+
+ function windowEventFilter(type, e)
+ {
+ return e.name === "DOMWindow::dispatchEvent" && e.args.type === type;
+ };
+
+ var windowEventNames = [ "beforeunload", "unload", "load" ];
+ for (var i = 0; i < windowEventNames.length; i++) {
+ var eventName = windowEventNames[i];
+ var events = devtoolsEvents.filter(windowEventFilter.bind(this, eventName));
+ if (clickEvents.length === 1) {
+ InspectorTest.log("SUCCESS: found one " + eventName + " event");
+ } else {
+ fail(eventName + " event is missing");
+ }
+ }
+
+ InspectorTest.completeTest();
+ }
+
+
+ function fail(message)
+ {
+ var formattedEvents = devtoolsEvents.map(function(e)
+ {
+ return e.name + "(" + e.args.type + ")";
+ });
+ InspectorTest.log("FAIL: " + message + " devtools-timeline events: " + JSON.stringify(formattedEvents, null, 2));
+ }
+
+ function onStop(response)
+ {
+ InspectorTest.log("Recording stopped");
+ }
+}
+</script>
+</head>
+<body onLoad="runTest();">
+<div id="my-div"></div>
+</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/inspector-protocol/timeline/timeline-dispatchEvent-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698