Repository navigation
test: wait for beforeunload handler to be installed - #23874
Merged
Merged
Conversation
deepak1556
reviewed
Jun 1, 2020
| <body> | ||
| <script type="text/javascript" charset="utf-8"> | ||
| function installBeforeUnload(removeAfterNTimes) { | ||
| setTimeout(() => console.log('installed')) |
Member
There was a problem hiding this comment.
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'));
Member
TIL, wow there are so many internal details around unload handlers. Should document these findings if we get a chance. |
zcbenz
force-pushed
the
wait-terminate-status
branch
from
June 2, 2020 01:09
b9c7cd1 to
d44a508
Compare
deepak1556
approved these changes
Jun 2, 2020
|
No Release Notes |
Contributor
|
I have automatically backported this PR to "10-x-y", please check out #23898 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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