Skip to content

Commit

Permalink
DevTools: Try to fix broken page-frames.js test
Browse files Browse the repository at this point in the history
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/+/1983172
Reviewed-by: Mathias Bynens <mathias@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728177}
  • Loading branch information
psmarshall authored and Commit Bot committed Jan 3, 2020
1 parent 693492c commit 8c5da8e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 0 additions & 2 deletions third_party/blink/web_tests/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
(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}`);
}
})

0 comments on commit 8c5da8e

Please sign in to comment.