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

Side by Side Diff: LayoutTests/inspector-protocol/timeline/timeline-dispatchEvent.html

Issue 391413003: DevTools: [Timeline] extract common infrastructure from tracing tests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: syntax error was fixed Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 performAction(callback)
7 { 8 {
8 var div = document.querySelector("#my-div"); 9 var div = document.querySelector("#my-div");
9 div.addEventListener("click", function(e) { }, false); 10 div.addEventListener("click", function(e) { }, false);
10 div.click(); 11 div.click();
11 12
12 var iframe = document.createElement("iframe"); 13 var iframe = document.createElement("iframe");
13 div.appendChild(iframe); 14 div.appendChild(iframe);
15 callback();
14 } 16 }
15 17
16 function test() 18 function test()
17 { 19 {
18 InspectorTest.eventHandler["Tracing.dataCollected"] = dataCollected; 20 InspectorTest.invokeAsyncWithTracing("performAction", finish);
19 InspectorTest.eventHandler["Tracing.tracingComplete"] = tracingComplete;
20 InspectorTest.sendCommand("Tracing.start", { "categories" : "disabled-by-def ault-devtools.timeline", "type": "" }, onStart);
21 21
22 function onStart(response) 22 function finish(devtoolsEvents)
23 { 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 function windowEventFilter(type, e) 24 function windowEventFilter(type, e)
48 { 25 {
49 return e.name === "EventDispatch" && e.args.data.type === type; 26 return e.name === "EventDispatch" && e.args.data.type === type;
50 }; 27 };
51 28
52 var windowEventNames = [ "click", "beforeunload", "unload", "load" ]; 29 var windowEventNames = [ "click", "beforeunload", "unload", "load" ];
53 for (var i = 0; i < windowEventNames.length; i++) { 30 for (var i = 0; i < windowEventNames.length; i++) {
54 var eventName = windowEventNames[i]; 31 var eventName = windowEventNames[i];
55 var events = devtoolsEvents.filter(windowEventFilter.bind(this, even tName)); 32 var events = devtoolsEvents.filter(windowEventFilter.bind(this, even tName));
56 if (events.length >= 1) { 33 if (events.length >= 1) {
57 InspectorTest.log("SUCCESS: found " + eventName + " event"); 34 InspectorTest.log("SUCCESS: found " + eventName + " event");
58 } else { 35 } else {
59 fail(eventName + " event is missing"); 36 fail(eventName + " event is missing", devtoolsEvents);
60 } 37 }
61 } 38 }
62 39
63 InspectorTest.completeTest(); 40 InspectorTest.completeTest();
64 } 41 }
65 42
66 43 function fail(message, devtoolsEvents)
67 function fail(message)
68 { 44 {
69 var formattedEvents = devtoolsEvents.map(function(e) 45 var formattedEvents = devtoolsEvents.map(function(e)
70 { 46 {
71 return e.name + "(" + e.args.data.type + ")"; 47 return e.name + "(" + e.args.data.type + ")";
72 }); 48 });
73 InspectorTest.log("FAIL: " + message + " devtools.timeline events: " + J SON.stringify(formattedEvents, null, 2)); 49 InspectorTest.log("FAIL: " + message + " devtools.timeline events: " + J SON.stringify(formattedEvents, null, 2));
74 } 50 }
75
76 function onStop(response)
77 {
78 InspectorTest.log("Recording stopped");
79 }
80 } 51 }
81 </script> 52 </script>
82 </head> 53 </head>
83 <body onLoad="runTest();"> 54 <body onLoad="runTest();">
84 <div id="my-div"></div> 55 <div id="my-div"></div>
85 </body> 56 </body>
86 </html> 57 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698