Skip to content

test: wait for beforeunload handler to be installed - #23874

Merged
zcbenz merged 1 commit into
masterfrom
wait-terminate-status
Jun 2, 2020
Merged

zcbenz merged 1 commit into
masterfrom
wait-terminate-status

Conversation

@zcbenz

@zcbenz zcbenz commented Jun 1, 2020

Copy link
Copy Markdown
Contributor

Description of Change

After the beforeunload handler is installed, the render will send a message to main process to update the terminate status of frame host (it is called SuddenTerminationStatus message). So there is a race condition when we try to close the window immediately after installing the handler.

This PR makes the test wait for a console message before closing, which should be sent after the SuddenTerminationStatus message.

There is also a cleanup of the beforeunload fixture files.

Note that this PR only changes the tests that install handler dynamically, I'll start a new PR to change the tests that hardcoded the handler in html files, if needed in future.

Release Notes

Notes: none

@zcbenz
zcbenz requested a review from deepak1556 June 1, 2020 10:42
<body>
<script type="text/javascript" charset="utf-8">
function installBeforeUnload(removeAfterNTimes) {
setTimeout(() => console.log('installed'))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it be better if this is added below the event listener, so that its more explicit about the order.

window.addEventListener('beforeunload', function handler(e) {})
setTimeout(() => console.log('installed'));

@deepak1556

Copy link
Copy Markdown
Member

it is called SuddenTerminationStatus message

TIL, wow there are so many internal details around unload handlers. Should document these findings if we get a chance.

@zcbenz
zcbenz force-pushed the wait-terminate-status branch from b9c7cd1 to d44a508 Compare June 2, 2020 01:09
@zcbenz
zcbenz merged commit 5918dd6 into master Jun 2, 2020
@release-clerk

release-clerk Bot commented Jun 2, 2020

Copy link
Copy Markdown

No Release Notes

@zcbenz
zcbenz deleted the wait-terminate-status branch June 2, 2020 02:32
@trop

trop Bot commented Jun 2, 2020

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "10-x-y", please check out #23898

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants