Skip to content

Commit 549c632

Browse files
Olli PettayOlli Pettay
Olli Pettay
authored and
Olli Pettay
committed
Bug 1744352 - Part 1: Ensure we set InitialSandboxFlags when opening or replacing toplevel BrowsingContexts, r=mccr8 a=RyanVM
Differential Revision: https://phabricator.services.mozilla.com/D139430
1 parent c708afd commit 549c632

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

Diff for: docshell/base/BrowsingContext.h

+2
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ enum class ExplicitActiveStatus : uint8_t {
123123
FIELD(Muted, bool) \
124124
/* See nsSandboxFlags.h for the possible flags. */ \
125125
FIELD(SandboxFlags, uint32_t) \
126+
/* The value of SandboxFlags when the BrowsingContext is first created. \
127+
* Used for sandboxing the initial about:blank document. */ \
126128
FIELD(InitialSandboxFlags, uint32_t) \
127129
/* A non-zero unique identifier for the browser element that is hosting \
128130
* this \

Diff for: docshell/base/CanonicalBrowsingContext.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,11 @@ void CanonicalBrowsingContext::ReplacedBy(
301301
txn.SetHistoryID(GetHistoryID());
302302
txn.SetExplicitActive(GetExplicitActive());
303303
txn.SetHasRestoreData(GetHasRestoreData());
304+
// As this is a different BrowsingContext, set InitialSandboxFlags to the
305+
// current flags in the new context so that they also apply to any initial
306+
// about:blank documents created in it.
307+
txn.SetSandboxFlags(GetSandboxFlags());
308+
txn.SetInitialSandboxFlags(GetSandboxFlags());
304309
if (aNewContext->EverAttached()) {
305310
MOZ_ALWAYS_SUCCEEDS(txn.Commit(aNewContext));
306311
} else {

Diff for: toolkit/components/windowwatcher/nsWindowWatcher.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,8 @@ nsresult nsWindowWatcher::OpenWindowInternal(
10211021
SANDBOX_PROPAGATES_TO_AUXILIARY_BROWSING_CONTEXTS) {
10221022
MOZ_ASSERT(windowIsNew, "Should only get here for new windows");
10231023
MOZ_ALWAYS_SUCCEEDS(newBC->SetSandboxFlags(activeDocsSandboxFlags));
1024+
MOZ_ALWAYS_SUCCEEDS(
1025+
newBC->SetInitialSandboxFlags(newBC->GetSandboxFlags()));
10241026
}
10251027

10261028
RefPtr<nsGlobalWindowOuter> win(

0 commit comments

Comments
 (0)