Bug 1828643 - Make sure LOAD_TRR_DISABLED_MODE gets passed through defaultLoadFlags when browsing context is replaced r=necko-reviewers,kershaw

When the user clicks continue this time in the DoH fallback warning page
we want to set the defaultLoadFlags to LOAD_TRR_DISABLED_MODE so all of
the pages & subresources in the tab will not use TRR from that point
forward.

Setting it directly on docshell.defaultLoadFlags seems to not have the correct
behaviour when the page is using the Cross-Origin-Opener-Policy header,
as that causes the DocumentChannel to do a cross process redirect and
recreate the browsing context.

Setting the defaultLoadFlags on the browsingContext directly and
adding the field to `CanonicalBrowsingContext::ReplacedBy` seems to lead to
the expected behaviour.

Differential Revision: https://phabricator.services.mozilla.com/D176959
This commit is contained in:
Valentin Gosu 2023-05-04 10:06:44 +00:00
parent 6db4667b98
commit d245bc86c2
2 changed files with 5 additions and 1 deletions

View File

@ -330,6 +330,10 @@ void CanonicalBrowsingContext::ReplacedBy(
txn.SetDisplayMode(GetDisplayMode());
txn.SetForceDesktopViewport(GetForceDesktopViewport());
// Propagate the default load flags so that the TRR mode flags are forwarded
// to the new browsing context. See bug 1828643.
txn.SetDefaultLoadFlags(GetDefaultLoadFlags());
// As this is a different BrowsingContext, set InitialSandboxFlags to the
// current flags in the new context so that they also apply to any initial
// about:blank documents created in it.

View File

@ -232,7 +232,7 @@ export class NetErrorChild extends RemotePageChild {
}
RPMSetTRRDisabledLoadFlags() {
this.contentWindow.docShell.defaultLoadFlags |=
this.contentWindow.docShell.browsingContext.defaultLoadFlags |=
Ci.nsIRequest.LOAD_TRR_DISABLED_MODE;
}
}