Repository navigation
test: fix flaky beforeunload tests - #23699
Conversation
|
The beforeunload tests only seem to be flaky on master, so I'm not backporting this to old branches. |
3f897d0 to
8b789f3
Compare
If the beforeunload handler returns a non-null value then the renderer will put the page into paused state to run the javascript dialog, I don't know if this is the scenario you had encountered.
TIL, chromium seems to let the FrameTreeNode navigator handle it https://source.chromium.org/chromium/chromium/src/+/master:content/browser/frame_host/render_frame_host_impl.cc;l=3033 . But since the FrameTreeNode is very much alive, wonder if we can propose a patch in upstream to notify the |
8b789f3 to
ddf9f6d
Compare
|
No Release Notes |
|
I have automatically backported this PR to "10-x-y", please check out #23766 |
Description of Change
The
beforeunloadtests are flaky for following reasons:beforeunloadhandler to block window closing if there is no user interaction. (The purpose is to block ads.)beforeunloadhandler sometimes do not work.For 1), in our tests we rely on
BrowserWindow.closeandWebContents.loadURLto triggerbeforeunloadevent, and they used to imply user interaction. After recent Chromium upgrades, they no longer imply so. The tests are still passing for most times because we are running lots ofexecuteJavaScriptand other APIs that make Chromium think there is user interaction.For 2), I'm still very confused of it and I'm not even sure whether it is a correct statement, I only ran into it for a few times when testing and it went away once I tried to debug it.
So in order to fix the
beforeunloadtests, this PR does:closeandloadURLas user interaction to recover old behaviors.BeforeUnloadFiredevent ofWebContentsinstead of IPC messages to detect ifbeforeunloadhas ran.BeforeUnloadFiredfor navigations, some tests are usingconsole-messageto get signals frombeforeunloadhandler, which is still more robust than sending IPC messages directly.window.close()directly in the web pages, otherwise Chromium might not allowbeforeunloadto block closing.Release Notes
Notes: none