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

Unified Diff: third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-dispatchEvent.js

Issue 2942573003: [DevTools] New harness for inspector-protocol layout tests (Closed)
Patch Set: Protocol -> dp Created 3 years, 6 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
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..890af8524718ca7e1ceea925d5d9dc466c1ad9da
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/timeline/timeline-dispatchEvent.js
@@ -0,0 +1,47 @@
+(async function(testRunner) {
+ let {page, session, dp} = await testRunner.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';
+ });
+ }
+
+ var tracingHelper = (await testRunner.loadScript('../resources/tracing-test.js'))(testRunner, session);
+ await session.evaluate(performAction.toString());
+ tracingHelper.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)
+ testRunner.log('SUCCESS: found ' + eventName + ' event');
+ else
+ fail(eventName + ' event is missing', devtoolsEvents);
+ }
+
+ testRunner.completeTest();
+ }
+
+ function fail(message, devtoolsEvents) {
+ var formattedEvents = devtoolsEvents.map(function(e) {
+ return e.name + (e.args.data ? '(' + e.args.data.type + ')' : '');
+ });
+ testRunner.log('FAIL: ' + message + ' devtools.timeline events: ' + JSON.stringify(formattedEvents, null, 2));
+ }
+})

Powered by Google App Engine
This is Rietveld 408576698