Commit 8c5da8e3 authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

DevTools: Try to fix broken page-frames.js test

The test was flaky a long time ago but now fails consistently.
The TracingStartedInPage trace event doesn't seem to be emitted anymore
so I replaced this with the TracingStartedInBrowser event.

That event doesn't emit nodeIds so I updated the expectation to assert
that they are undfined.

Also a drive-by cleanup to tracing-test which was trying to JSONify
the wrong variable which meant the output in case the test failed
was not helpful.

Also clean up the test itself with const, JS style etc.

Bug: 734762
Change-Id: I3f7f5665ace38525fca5967c5de6f6fba02d3d5a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1983172Reviewed-by: default avatarMathias Bynens <mathias@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728177}
parent 693492c7
......@@ -4511,8 +4511,6 @@ crbug.com/737959 http/tests/misc/object-image-load-outlives-gc-without-crashing.
crbug.com/737959 http/tests/misc/video-poster-image-load-outlives-gc-without-crashing.html [ Failure Pass Crash ]
crbug.com/734762 inspector-protocol/timeline/page-frames.js [ Failure Pass ]
# module script lacks XHTML support
crbug.com/717643 external/wpt/html/semantics/scripting-1/the-script-element/module/module-in-xhtml.xhtml [ Failure ]
crbug.com/717643 virtual/streaming-preload/external/wpt/html/semantics/scripting-1/the-script-element/module/module-in-xhtml.xhtml [ Failure ]
......
......@@ -99,7 +99,7 @@
var events = this.findEvents(name, ph, condition);
if (events.length)
return events[0];
throw new Error("Couldn't find event " + name + " / " + ph + "\n\n in " + JSON.stringify(this.devtoolsEvents, null, 2));
throw new Error("Couldn't find event " + name + " / " + ph + "\n\n in " + JSON.stringify(this._devtoolsEvents, null, 2));
}
filterEvents(callback) {
......
Tests certain trace events in iframes.
Recording started
Tracing complete
Frames in TracingStartedInPage
Frames in TracingStartedInBrowser
url: inspector-protocol/resources/inspector-protocol-page.html name: parent: undefined nodeId: undefined
url: data:text/html,<script>window.foo = 42</script> name: frame0 parent: string nodeId: number
url: data:text/html,<script>window.foo = 42</script> name: frame0 parent: string nodeId: undefined
Frames in CommitLoad events
url: about:blank name: Frame No. 1 parent: string nodeId: number
url: inspector-protocol/resources/blank.html name: parent: string nodeId: number
......
(async function(testRunner) {
var {page, session, dp} = await testRunner.startHTML(`
const {page, session, dp} = await testRunner.startHTML(`
<iframe src='data:text/html,<script>window.foo = 42</script>' name='frame0'></iframe>
`, 'Tests certain trace events in iframes.');
function performActions() {
var frame1 = document.createElement('iframe');
const frame1 = document.createElement('iframe');
frame1.name = 'Frame No. 1';
document.body.appendChild(frame1);
frame1.contentWindow.document.write('console.log("frame2")');
var frame2 = document.createElement('iframe');
const frame2 = document.createElement('iframe');
frame2.src = 'blank.html';
document.body.appendChild(frame2);
return new Promise(fulfill => { frame2.addEventListener('load', fulfill, false) });
}
var TracingHelper = await testRunner.loadScript('../resources/tracing-test.js');
var tracingHelper = new TracingHelper(testRunner, session);
var data = await tracingHelper.invokeAsyncWithTracing(performActions);
const TracingHelper = await testRunner.loadScript('../resources/tracing-test.js');
const tracingHelper = new TracingHelper(testRunner, session);
await tracingHelper.invokeAsyncWithTracing(performActions);
testRunner.log('Frames in TracingStartedInPage');
var tracingStarted = tracingHelper.findEvent('TracingStartedInPage', 'I');
for (var frame of tracingStarted.args['data']['frames'] || [])
testRunner.log('Frames in TracingStartedInBrowser');
const tracingStarted = tracingHelper.findEvent('TracingStartedInBrowser', 'I');
for (const frame of tracingStarted.args['data']['frames'] || []) {
dumpFrame(frame);
}
testRunner.log('Frames in CommitLoad events');
var commitLoads = tracingHelper.findEvents('CommitLoad', 'X');
for (var event of commitLoads)
const commitLoads = tracingHelper.findEvents('CommitLoad', 'X');
for (const event of commitLoads) {
dumpFrame(event.args['data']);
}
testRunner.completeTest();
function dumpFrame(frame) {
var url = frame.url.replace(/.*\/(([^/]*\/){2}[^/]*$)/, '$1');
const url = frame.url.replace(/.*\/(([^/]*\/){2}[^/]*$)/, '$1');
testRunner.log(`url: ${url} name: ${frame.name} parent: ${typeof frame.parent} nodeId: ${typeof frame.nodeId}`);
}
})
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment