This is one of the followups to the beforeunload OOPIF fix in issue 853021 . As part of that fix, I maintained the invariant that a navigating frame always sends the beforeunload IPC to the renderer, even if there's no beforeunload handler defined. We actually already have information about which frames have beforeunload handlers in the browser process: rfh->GetSuddenTerminationDisablerState(blink::kBeforeUnloadHandler), which I do use for OOPIFs. However, a bunch of tests currently assume that FrameMsg_BeforeUnload is always sent for the navigating frame itself, and DevTools might as well. We should fix these cases and not send the IPC when it's not needed. That has potential to speed navigations up a bit.
See the TODO here: https://cs.chromium.org/chromium/src/content/browser/frame_host/render_frame_host_impl.cc?l=3761&rcl=6c3c55e4139b914f554edfba8b83ecbcdc48754f
Some discussion about affected tests (found when I originally tried doing this in https://chromium-review.googlesource.com/1121586) is here: https://docs.google.com/document/d/1XmwjGNUl_PF9OgDTs0JsRe0iuGrtEk6mzDYGkkbqHKg/edit#heading=h.g01oz4k203ih. Pasting the list:
content_browsertests:
SessionHistoryTest.JavascriptHistory
content_unittests:
WebContentsImplTest.CrossSiteNavigationBackPreempted
WebContentsImplTest.CrossSiteNavigationBackOldNavigationIgnored
WebContentsImplTest.CrossSiteNavigationPreempted
WebContentsImplTest.CrossSiteUnloadHandlers
NavigatorTestWithBrowserSideNavigation.BeforeUnloadDenialCancelNavigation
RenderFrameHostManagerTest.NavigateAfterMissingSwapOutACK
WebContentsImplTest.CrossSiteNavigationNotPreemptedByFrame
RenderFrameHostManagerTest.CancelPendingProperlyDeletesOrSwaps
WebContentsImplTest.CrossSiteNotPreemptedDuringBeforeUnload
NavigatorTestWithBrowserSideNavigation.BeginNavigation
browser_tests:
WebViewTest.InterstitialPage*
MediaGalleriesInteractiveDialogTest.InvokeUi_DisplayDialog
components_unittests:
InterceptNavigationThrottleTest.IgnoreCallbackDeletesNavigation/1