Bug 1701001 - Part 2: Add "is popup" field to browsing context. r=smaug

Add BrowsingContext::FieldValues.mIsPopupRequested, and pass "is popup"
value calculated before opening window/tab to BrowsingContext::CreateDetached.

Other code path that is unrelated to content-priv window.open uses the
default value false.

Differential Revision: https://phabricator.services.mozilla.com/D129411
This commit is contained in:
Tooru Fujisawa
2021-11-05 23:07:40 +00:00
parent b55930f157
commit 4b4b4f1547
10 changed files with 55 additions and 30 deletions

View File

@@ -294,7 +294,7 @@ bool BrowsingContext::SameOriginWithTop() {
already_AddRefed<BrowsingContext> BrowsingContext::CreateDetached(
nsGlobalWindowInner* aParent, BrowsingContext* aOpener,
BrowsingContextGroup* aSpecificGroup, const nsAString& aName, Type aType,
bool aCreatedDynamically) {
bool aIsPopupRequested, bool aCreatedDynamically) {
if (aParent) {
MOZ_DIAGNOSTIC_ASSERT(aParent->GetWindowContext());
MOZ_DIAGNOSTIC_ASSERT(aParent->GetBrowsingContext()->mType == aType);
@@ -410,6 +410,8 @@ already_AddRefed<BrowsingContext> BrowsingContext::CreateDetached(
fields.mAllowJavascript = inherit ? inherit->GetAllowJavascript() : true;
fields.mIsPopupRequested = aIsPopupRequested;
if (!parentBC) {
fields.mShouldDelayMediaFromStart =
StaticPrefs::media_block_autoplay_until_in_foreground();
@@ -454,7 +456,7 @@ already_AddRefed<BrowsingContext> BrowsingContext::CreateIndependent(
"BCs created in the content process must be related to "
"some BrowserChild");
RefPtr<BrowsingContext> bc(
CreateDetached(nullptr, nullptr, nullptr, u""_ns, aType));
CreateDetached(nullptr, nullptr, nullptr, u""_ns, aType, false));
bc->mWindowless = bc->IsContent();
bc->mEmbeddedByThisProcess = true;
bc->EnsureAttached();