Bug 1873294 - Clean up logic for firing cross-process load events, r=smaug

Previously it may have been possible in some edge cases for us to send
`MaybeFireEmbedderLoadEvents` for a non-toplevel frame during docshell
tree teardown.

Differential Revision: https://phabricator.services.mozilla.com/D197825
This commit is contained in:
Nika Layzell
2024-01-08 19:30:59 +00:00
parent 407a2577f1
commit 38d90f11db
3 changed files with 6 additions and 4 deletions

View File

@@ -2197,7 +2197,7 @@ void nsDocShell::TriggerParentCheckDocShellIsEmpty() {
parent->DocLoaderIsEmpty(true);
}
if (GetBrowsingContext()->IsContentSubframe() &&
!GetBrowsingContext()->GetParent()->IsInProcess()) {
!GetBrowsingContext()->GetParentWindowContext()->IsInProcess()) {
if (BrowserChild* browserChild = BrowserChild::GetFrom(this)) {
mozilla::Unused << browserChild->SendMaybeFireEmbedderLoadEvents(
EmbedderElementEventType::NoEvent);
@@ -3381,7 +3381,8 @@ void nsDocShell::UnblockEmbedderLoadEventForFailure(bool aFireFrameErrorEvent) {
// SendMaybeFireEmbedderLoadEvents via any of the normal call paths.
// (Obviously, we must do this before any of the returns below.)
RefPtr<BrowserChild> browserChild = BrowserChild::GetFrom(this);
if (browserChild) {
if (browserChild &&
!mBrowsingContext->GetParentWindowContext()->IsInProcess()) {
mozilla::Unused << browserChild->SendMaybeFireEmbedderLoadEvents(
aFireFrameErrorEvent ? EmbedderElementEventType::ErrorEvent
: EmbedderElementEventType::NoEvent);