Index: third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-dispatchEvent.js |
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-dispatchEvent.js b/third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-dispatchEvent.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..eb3514aa6ca425b34fa6c2c7730ed1e400fbfcc7 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-dispatchEvent.js |
@@ -0,0 +1,47 @@ |
+(async function() { |
+ let {page, session, Protocol} = await InspectorTest.startHTML(` |
+ <div id='my-div'></div> |
+ `, ''); |
+ |
+ function performAction() { |
+ var div = document.querySelector('#my-div'); |
+ div.addEventListener('click', function(e) { }, false); |
+ div.click(); |
+ |
+ var iframe = document.createElement('iframe'); |
+ div.appendChild(iframe); |
+ return new Promise(resolve => { |
+ iframe.onload = resolve; |
+ iframe.src = 'blank.html'; |
+ }); |
+ } |
+ |
+ (await InspectorTest.loadScript('../resources/tracing-test.js'))(session); |
+ await session.evaluate(performAction.toString()); |
+ InspectorTest.invokeAsyncWithTracing('performAction', finish); |
+ |
+ function finish(devtoolsEvents) { |
+ function windowEventFilter(type, e) { |
+ return e.name === 'EventDispatch' && e.args.data.type === type; |
+ }; |
+ |
+ var windowEventNames = [ 'click', 'beforeunload', 'unload', 'load' ]; |
+ for (var i = 0; i < windowEventNames.length; i++) { |
+ var eventName = windowEventNames[i]; |
+ var events = devtoolsEvents.filter(windowEventFilter.bind(this, eventName)); |
+ if (events.length >= 1) |
+ InspectorTest.log('SUCCESS: found ' + eventName + ' event'); |
+ else |
+ fail(eventName + ' event is missing', devtoolsEvents); |
+ } |
+ |
+ InspectorTest.completeTest(); |
+ } |
+ |
+ function fail(message, devtoolsEvents) { |
+ var formattedEvents = devtoolsEvents.map(function(e) { |
+ return e.name + (e.args.data ? '(' + e.args.data.type + ')' : ''); |
+ }); |
+ InspectorTest.log('FAIL: ' + message + ' devtools.timeline events: ' + JSON.stringify(formattedEvents, null, 2)); |
+ } |
+})(); |