Bug 1611961 - Move UserActivationState from BrowsingContext to WindowContext; r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D83126
This commit is contained in:
Edgar Chen 2020-08-06 10:25:00 +00:00
parent 36b7c933aa
commit d2c2f39bd2
13 changed files with 171 additions and 132 deletions

View File

@ -1068,7 +1068,9 @@ bool BrowsingContext::IsSandboxedFrom(BrowsingContext* aTarget) {
// If SANDBOXED_TOPLEVEL_NAVIGATION_USER_ACTIVATION flag is not on, we are not
// sandboxed from our top if we have user interaction.
if (!(sandboxFlags & SANDBOXED_TOPLEVEL_NAVIGATION_USER_ACTIVATION) &&
HasValidTransientUserGestureActivation() && aTarget == Top()) {
mCurrentWindowContext &&
mCurrentWindowContext->HasValidTransientUserGestureActivation() &&
aTarget == Top()) {
return false;
}
@ -1159,60 +1161,6 @@ JSObject* BrowsingContext::ReadStructuredClone(JSContext* aCx,
return val.toObjectOrNull();
}
void BrowsingContext::NotifyUserGestureActivation() {
// Return value of setting synced field should be checked. See bug 1656492.
Unused << SetUserActivationState(UserActivation::State::FullActivated);
}
void BrowsingContext::NotifyResetUserGestureActivation() {
// Return value of setting synced field should be checked. See bug 1656492.
Unused << SetUserActivationState(UserActivation::State::None);
}
bool BrowsingContext::HasBeenUserGestureActivated() {
return GetUserActivationState() != UserActivation::State::None;
}
bool BrowsingContext::HasValidTransientUserGestureActivation() {
MOZ_ASSERT(mIsInProcess);
if (GetUserActivationState() != UserActivation::State::FullActivated) {
MOZ_ASSERT(mUserGestureStart.IsNull(),
"mUserGestureStart should be null if the document hasn't ever "
"been activated by user gesture");
return false;
}
MOZ_ASSERT(!mUserGestureStart.IsNull(),
"mUserGestureStart shouldn't be null if the document has ever "
"been activated by user gesture");
TimeDuration timeout = TimeDuration::FromMilliseconds(
StaticPrefs::dom_user_activation_transient_timeout());
return timeout <= TimeDuration() ||
(TimeStamp::Now() - mUserGestureStart) <= timeout;
}
bool BrowsingContext::ConsumeTransientUserGestureActivation() {
MOZ_ASSERT(mIsInProcess);
if (!HasValidTransientUserGestureActivation()) {
return false;
}
BrowsingContext* top = Top();
top->PreOrderWalk([&](BrowsingContext* aContext) {
if (aContext->GetUserActivationState() ==
UserActivation::State::FullActivated) {
// Updating user activation state on a discarded context has no effect.
Unused << aContext->SetUserActivationState(
UserActivation::State::HasBeenActivated);
}
});
return true;
}
bool BrowsingContext::CanSetOriginAttributes() {
// A discarded BrowsingContext has already been destroyed, and cannot modify
// its OriginAttributes.
@ -2050,23 +1998,6 @@ void BrowsingContext::DidSet(FieldIndex<IDX_GVInaudibleAutoplayRequestStatus>) {
"browsing context");
}
void BrowsingContext::DidSet(FieldIndex<IDX_UserActivationState>) {
MOZ_ASSERT_IF(!mIsInProcess, mUserGestureStart.IsNull());
USER_ACTIVATION_LOG("Set user gesture activation %" PRIu8
" for %s browsing context 0x%08" PRIx64,
static_cast<uint8_t>(GetUserActivationState()),
XRE_IsParentProcess() ? "Parent" : "Child", Id());
if (mIsInProcess) {
USER_ACTIVATION_LOG(
"Set user gesture start time for %s browsing context 0x%08" PRIx64,
XRE_IsParentProcess() ? "Parent" : "Child", Id());
mUserGestureStart =
(GetUserActivationState() == UserActivation::State::FullActivated)
? TimeStamp::Now()
: TimeStamp();
}
}
void BrowsingContext::DidSet(FieldIndex<IDX_IsActive>, bool aOldValue) {
if (!IsTop() || aOldValue == GetIsActive() ||
!StaticPrefs::dom_suspend_inactive_enabled()) {

View File

@ -495,29 +495,6 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
// This function would be called when its corresponding document is activated
// by user gesture, and we would set the flag in the top level browsing
// context.
void NotifyUserGestureActivation();
// This function would be called when we want to reset the user gesture
// activation flag of the top level browsing context.
void NotifyResetUserGestureActivation();
// Return true if its corresponding document has been activated by user
// gesture.
bool HasBeenUserGestureActivated();
// Return true if its corresponding document has transient user gesture
// activation and the transient user gesture activation haven't yet timed
// out.
bool HasValidTransientUserGestureActivation();
// Return true if the corresponding document has valid transient user gesture
// activation and the transient user gesture activation had been consumed
// successfully.
bool ConsumeTransientUserGestureActivation();
// Return the window proxy object that corresponds to this browsing context.
inline JSObject* GetWindowProxy() const { return mWindowProxy; }
inline JSObject* GetUnbarrieredWindowProxy() const {
@ -727,7 +704,6 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
return true;
}
void DidSet(FieldIndex<IDX_UserActivationState>);
void DidSet(FieldIndex<IDX_IsActive>, bool aOldValue);
// Ensure that we only set the flag on the top level browsingContext.

View File

@ -395,14 +395,15 @@ void CanonicalBrowsingContext::CanonicalDiscard() {
}
void CanonicalBrowsingContext::NotifyStartDelayedAutoplayMedia() {
if (!GetCurrentWindowGlobal()) {
WindowContext* windowContext = GetCurrentWindowContext();
if (!windowContext) {
return;
}
// As this function would only be called when user click the play icon on the
// tab bar. That's clear user intent to play, so gesture activate the browsing
// tab bar. That's clear user intent to play, so gesture activate the window
// context so that the block-autoplay logic allows the media to autoplay.
NotifyUserGestureActivation();
windowContext->NotifyUserGestureActivation();
AUTOPLAY_LOG("NotifyStartDelayedAutoplayMedia for chrome bc 0x%08" PRIx64,
Id());
StartDelayedAutoplayMediaComponents();

View File

@ -10,6 +10,7 @@
#include "mozilla/dom/WindowGlobalParent.h"
#include "mozilla/dom/SyncedContextInlines.h"
#include "mozilla/dom/BrowsingContext.h"
#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/ClearOnShutdown.h"
#include "nsIScriptError.h"
@ -25,6 +26,11 @@ template class syncedcontext::Transaction<WindowContext>;
static LazyLogModule gWindowContextLog("WindowContext");
extern mozilla::LazyLogModule gUserInteractionPRLog;
#define USER_ACTIVATION_LOG(msg, ...) \
MOZ_LOG(gUserInteractionPRLog, LogLevel::Debug, (msg, ##__VA_ARGS__))
using WindowContextByIdMap = nsDataHashtable<nsUint64HashKey, WindowContext*>;
static StaticAutoPtr<WindowContextByIdMap> gWindowContexts;
@ -191,6 +197,23 @@ bool WindowContext::CanSet(
return CheckOnlyOwningProcessCanSet(aSource);
}
void WindowContext::DidSet(FieldIndex<IDX_UserActivationState>) {
MOZ_ASSERT_IF(!mInProcess, mUserGestureStart.IsNull());
USER_ACTIVATION_LOG("Set user gesture activation %" PRIu8
" for %s browsing context 0x%08" PRIx64,
static_cast<uint8_t>(GetUserActivationState()),
XRE_IsParentProcess() ? "Parent" : "Child", Id());
if (mInProcess) {
USER_ACTIVATION_LOG(
"Set user gesture start time for %s browsing context 0x%08" PRIx64,
XRE_IsParentProcess() ? "Parent" : "Child", Id());
mUserGestureStart =
(GetUserActivationState() == UserActivation::State::FullActivated)
? TimeStamp::Now()
: TimeStamp();
}
}
void WindowContext::DidSet(FieldIndex<IDX_HasReportedShadowDOMUsage>,
bool aOldValue) {
if (!aOldValue && GetHasReportedShadowDOMUsage() && IsInProcess()) {
@ -282,6 +305,59 @@ void WindowContext::AddMixedContentSecurityState(uint32_t aStateFlags) {
}
}
void WindowContext::NotifyUserGestureActivation() {
Unused << SetUserActivationState(UserActivation::State::FullActivated);
}
void WindowContext::NotifyResetUserGestureActivation() {
Unused << SetUserActivationState(UserActivation::State::None);
}
bool WindowContext::HasBeenUserGestureActivated() {
return GetUserActivationState() != UserActivation::State::None;
}
bool WindowContext::HasValidTransientUserGestureActivation() {
MOZ_ASSERT(mInProcess);
if (GetUserActivationState() != UserActivation::State::FullActivated) {
MOZ_ASSERT(mUserGestureStart.IsNull(),
"mUserGestureStart should be null if the document hasn't ever "
"been activated by user gesture");
return false;
}
MOZ_ASSERT(!mUserGestureStart.IsNull(),
"mUserGestureStart shouldn't be null if the document has ever "
"been activated by user gesture");
TimeDuration timeout = TimeDuration::FromMilliseconds(
StaticPrefs::dom_user_activation_transient_timeout());
return timeout <= TimeDuration() ||
(TimeStamp::Now() - mUserGestureStart) <= timeout;
}
bool WindowContext::ConsumeTransientUserGestureActivation() {
MOZ_ASSERT(mInProcess);
MOZ_ASSERT(!IsCached());
if (!HasValidTransientUserGestureActivation()) {
return false;
}
BrowsingContext* top = mBrowsingContext->Top();
top->PreOrderWalk([&](BrowsingContext* aBrowsingContext) {
WindowContext* windowContext = aBrowsingContext->GetCurrentWindowContext();
if (windowContext && windowContext->GetUserActivationState() ==
UserActivation::State::FullActivated) {
Unused << windowContext->SetUserActivationState(
UserActivation::State::HasBeenActivated);
}
});
return true;
}
WindowContext::IPCInitializer WindowContext::GetIPCInitializer() {
IPCInitializer init;
init.mInnerWindowId = mInnerWindowId;

View File

@ -11,6 +11,7 @@
#include "mozilla/Span.h"
#include "mozilla/dom/MaybeDiscarded.h"
#include "mozilla/dom/SyncedContext.h"
#include "mozilla/dom/UserActivation.h"
#include "nsILoadInfo.h"
#include "nsWrapperCache.h"
@ -51,6 +52,9 @@ class BrowsingContextGroup;
/* Whether the user has overriden the mixed content blocker to allow \
* mixed content loads to happen */ \
FIELD(AllowMixedContent, bool) \
/* Controls whether the WindowContext is currently considered to be \
* activated by a gesture */ \
FIELD(UserActivationState, UserActivation::State) \
FIELD(EmbedderPolicy, nsILoadInfo::CrossOriginEmbedderPolicy) \
/* True if this document tree contained an HTMLMediaElement that \
* played audibly. This should only be set on top level context. */ \
@ -117,6 +121,28 @@ class WindowContext : public nsISupports, public nsWrapperCache {
// top window context.
void AddMixedContentSecurityState(uint32_t aStateFlags);
// This function would be called when its corresponding window is activated
// by user gesture.
void NotifyUserGestureActivation();
// This function would be called when we want to reset the user gesture
// activation flag.
void NotifyResetUserGestureActivation();
// Return true if its corresponding window has been activated by user
// gesture.
bool HasBeenUserGestureActivated();
// Return true if its corresponding window has transient user gesture
// activation and the transient user gesture activation haven't yet timed
// out.
bool HasValidTransientUserGestureActivation();
// Return true if the corresponding window has valid transient user gesture
// activation and the transient user gesture activation had been consumed
// successfully.
bool ConsumeTransientUserGestureActivation();
protected:
WindowContext(BrowsingContext* aBrowsingContext, uint64_t aInnerWindowId,
uint64_t aOuterWindowId, bool aInProcess,
@ -181,6 +207,11 @@ class WindowContext : public nsISupports, public nsWrapperCache {
bool CanSet(FieldIndex<IDX_DelegatedExactHostMatchPermissions>,
const PermissionDelegateHandler::DelegatedPermissionList& aValue,
ContentParent* aSource);
bool CanSet(FieldIndex<IDX_UserActivationState>,
const UserActivation::State& aUserActivationState,
ContentParent* aSource) {
return true;
}
bool CanSet(FieldIndex<IDX_HasReportedShadowDOMUsage>, const bool& aValue,
ContentParent* aSource) {
@ -195,6 +226,7 @@ class WindowContext : public nsISupports, public nsWrapperCache {
void DidSet(FieldIndex<I>) {}
template <size_t I, typename T>
void DidSet(FieldIndex<I>, T&& aOldValue) {}
void DidSet(FieldIndex<IDX_UserActivationState>);
uint64_t mInnerWindowId;
uint64_t mOuterWindowId;
@ -208,6 +240,10 @@ class WindowContext : public nsISupports, public nsWrapperCache {
bool mIsDiscarded = false;
bool mInProcess = false;
// The start time of user gesture, this is only available if the window
// context is in process.
TimeStamp mUserGestureStart;
};
using WindowContextTransaction = WindowContext::BaseTransaction;

View File

@ -3795,6 +3795,7 @@ nsresult nsDocShell::LoadErrorPage(nsIURI* aErrorURI, nsIURI* aFailedURI,
mLSHE->AbandonBFCacheEntry();
}
RefPtr<WindowContext> context = mBrowsingContext->GetCurrentWindowContext();
RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState(aErrorURI);
loadState->SetTriggeringPrincipal(nsContentUtils::GetSystemPrincipal());
if (mBrowsingContext) {
@ -3804,8 +3805,7 @@ nsresult nsDocShell::LoadErrorPage(nsIURI* aErrorURI, nsIURI* aFailedURI,
loadState->SetFirstParty(true);
loadState->SetSourceBrowsingContext(mBrowsingContext);
loadState->SetHasValidUserGestureActivation(
mBrowsingContext &&
mBrowsingContext->HasValidTransientUserGestureActivation());
context && context->HasValidTransientUserGestureActivation());
return InternalLoad(loadState);
}
@ -3939,6 +3939,7 @@ nsresult nsDocShell::ReloadDocument(nsDocShell* aDocShell, Document* aDocument,
Maybe<nsCOMPtr<nsIURI>> emplacedResultPrincipalURI;
emplacedResultPrincipalURI.emplace(std::move(resultPrincipalURI));
RefPtr<WindowContext> context = aBrowsingContext->GetCurrentWindowContext();
RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState(currentURI);
loadState->SetReferrerInfo(aReferrerInfo);
loadState->SetOriginalURI(originalURI);
@ -3956,8 +3957,7 @@ nsresult nsDocShell::ReloadDocument(nsDocShell* aDocShell, Document* aDocument,
loadState->SetSourceBrowsingContext(aBrowsingContext);
loadState->SetBaseURI(baseURI);
loadState->SetHasValidUserGestureActivation(
aBrowsingContext &&
aBrowsingContext->HasValidTransientUserGestureActivation());
context && context->HasValidTransientUserGestureActivation());
return aDocShell->InternalLoad(loadState);
}
@ -9688,11 +9688,12 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
Maybe<mozilla::dom::ClientInfo>(),
Maybe<mozilla::dom::ServiceWorkerDescriptor>(),
sandboxFlags);
RefPtr<WindowContext> context = mBrowsingContext->GetCurrentWindowContext();
// in case this docshell load was triggered by a valid transient user gesture,
// or also the load originates from external, then we pass that information on
// to the loadinfo, which allows e.g. setting Sec-Fetch-User request headers.
if (mBrowsingContext->HasValidTransientUserGestureActivation() ||
if ((context && context->HasValidTransientUserGestureActivation()) ||
aLoadState->HasValidUserGestureActivation() ||
aLoadState->HasLoadFlags(LOAD_FLAGS_FROM_EXTERNAL)) {
loadInfo->SetHasValidUserGestureActivation(true);
@ -12098,6 +12099,7 @@ nsresult nsDocShell::OnLinkClickSync(nsIContent* aContent,
nsCOMPtr<nsIReferrerInfo> referrerInfo =
isElementAnchorOrArea ? new ReferrerInfo(*aContent->AsElement())
: new ReferrerInfo(*referrerDoc);
RefPtr<WindowContext> context = mBrowsingContext->GetCurrentWindowContext();
aLoadState->SetTriggeringSandboxFlags(triggeringSandboxFlags);
aLoadState->SetReferrerInfo(referrerInfo);
@ -12106,8 +12108,7 @@ nsresult nsDocShell::OnLinkClickSync(nsIContent* aContent,
aLoadState->SetLoadType(loadType);
aLoadState->SetSourceBrowsingContext(mBrowsingContext);
aLoadState->SetHasValidUserGestureActivation(
mBrowsingContext &&
mBrowsingContext->HasValidTransientUserGestureActivation());
context && context->HasValidTransientUserGestureActivation());
nsresult rv = InternalLoad(aLoadState);

View File

@ -15268,8 +15268,13 @@ BrowsingContext* Document::GetBrowsingContext() const {
void Document::NotifyUserGestureActivation() {
if (RefPtr<BrowsingContext> bc = GetBrowsingContext()) {
bc->PreOrderWalk([&](BrowsingContext* aContext) {
nsIDocShell* docShell = aContext->GetDocShell();
bc->PreOrderWalk([&](BrowsingContext* aBC) {
WindowContext* windowContext = aBC->GetCurrentWindowContext();
if (!windowContext) {
return;
}
nsIDocShell* docShell = aBC->GetDocShell();
if (!docShell) {
return;
}
@ -15282,38 +15287,42 @@ void Document::NotifyUserGestureActivation() {
// XXXedgar we probably could just check `IsInProcess()` after fission
// enable.
if (NodePrincipal()->Equals(document->NodePrincipal())) {
aContext->NotifyUserGestureActivation();
windowContext->NotifyUserGestureActivation();
}
});
for (bc = bc->GetParent(); bc; bc = bc->GetParent()) {
bc->NotifyUserGestureActivation();
if (WindowContext* windowContext = bc->GetCurrentWindowContext()) {
windowContext->NotifyUserGestureActivation();
}
}
}
}
bool Document::HasBeenUserGestureActivated() {
RefPtr<BrowsingContext> bc = GetBrowsingContext();
return bc && bc->HasBeenUserGestureActivated();
RefPtr<WindowContext> wc = GetWindowContext();
return wc && wc->HasBeenUserGestureActivated();
}
void Document::ClearUserGestureActivation() {
if (RefPtr<BrowsingContext> bc = GetBrowsingContext()) {
bc = bc->Top();
bc->PreOrderWalk([&](BrowsingContext* aContext) {
aContext->NotifyResetUserGestureActivation();
bc->PreOrderWalk([&](BrowsingContext* aBC) {
if (WindowContext* windowContext = aBC->GetCurrentWindowContext()) {
windowContext->NotifyResetUserGestureActivation();
}
});
}
}
bool Document::HasValidTransientUserGestureActivation() {
RefPtr<BrowsingContext> bc = GetBrowsingContext();
return bc && bc->HasValidTransientUserGestureActivation();
RefPtr<WindowContext> wc = GetWindowContext();
return wc && wc->HasValidTransientUserGestureActivation();
}
bool Document::ConsumeTransientUserGestureActivation() {
RefPtr<BrowsingContext> bc = GetBrowsingContext();
return bc && bc->ConsumeTransientUserGestureActivation();
RefPtr<WindowContext> wc = GetWindowContext();
return wc && wc->ConsumeTransientUserGestureActivation();
}
void Document::SetDocTreeHadAudibleMedia() {

View File

@ -16,6 +16,7 @@
#include "nsGlobalWindow.h"
#include "mozilla/NullPrincipal.h"
#include "mozilla/dom/Document.h"
#include "mozilla/dom/WindowContext.h"
namespace mozilla {
namespace dom {
@ -133,10 +134,10 @@ void LocationBase::SetURI(nsIURI* aURI, nsIPrincipal& aSubjectPrincipal,
nsCOMPtr<nsPIDOMWindowInner> sourceWindow =
nsContentUtils::CallerInnerWindow();
if (sourceWindow) {
RefPtr<BrowsingContext> sourceBC = sourceWindow->GetBrowsingContext();
loadState->SetSourceBrowsingContext(sourceBC);
WindowContext* context = sourceWindow->GetWindowContext();
loadState->SetSourceBrowsingContext(sourceWindow->GetBrowsingContext());
loadState->SetHasValidUserGestureActivation(
sourceBC && sourceBC->HasValidTransientUserGestureActivation());
context && context->HasValidTransientUserGestureActivation());
}
loadState->SetLoadFlags(nsIWebNavigation::LOAD_FLAGS_NONE);

View File

@ -1612,6 +1612,9 @@ void nsGlobalWindowInner::InitDocumentDependentState(JSContext* aCx) {
if (!mWindowGlobalChild) {
mWindowGlobalChild = WindowGlobalChild::Create(this);
}
MOZ_ASSERT(!GetWindowContext()->HasBeenUserGestureActivated(),
"WindowContext should always not have user gesture activation at "
"this point.");
UpdateAutoplayPermission();
UpdateShortcutsPermission();
@ -1623,10 +1626,6 @@ void nsGlobalWindowInner::InitDocumentDependentState(JSContext* aCx) {
permDelegateHandler->PopulateAllDelegatedPermissions();
}
if (mWindowGlobalChild && GetBrowsingContext()) {
GetBrowsingContext()->NotifyResetUserGestureActivation();
}
#if defined(MOZ_WIDGET_ANDROID)
// When we insert the new document to the window in the top-level browsing
// context, we should reset the status of the request which is used for the

View File

@ -78,8 +78,9 @@ static bool IsWindowAllowedToPlay(nsPIDOMWindowInner* aWindow) {
return true;
}
RefPtr<BrowsingContext> topLevelBC = aWindow->GetBrowsingContext()->Top();
if (topLevelBC->HasBeenUserGestureActivated()) {
WindowContext* topContext =
aWindow->GetBrowsingContext()->GetTopWindowContext();
if (topContext && topContext->HasBeenUserGestureActivated()) {
AUTOPLAY_LOG(
"Allow autoplay as top-level context has been activated by user "
"gesture.");

View File

@ -103,8 +103,11 @@ DocumentChannelChild::AsyncOpen(nsIStreamListener* aListener) {
args.timing() = Some(mTiming);
}
RefPtr<WindowContext> loadingWindowContext =
loadingContext->GetCurrentWindowContext();
args.hasValidTransientUserAction() =
loadingContext->HasValidTransientUserGestureActivation();
loadingWindowContext &&
loadingWindowContext->HasValidTransientUserGestureActivation();
switch (mLoadInfo->GetExternalContentPolicyType()) {
case nsIContentPolicy::TYPE_DOCUMENT:

View File

@ -159,8 +159,10 @@ NS_IMETHODIMP ParentProcessDocumentChannel::AsyncOpen(
nsresult rv = NS_OK;
Maybe<dom::ClientInfo> initialClientInfo = mInitialClientInfo;
RefPtr<WindowContext> context =
GetDocShell()->GetBrowsingContext()->GetCurrentWindowContext();
const bool hasValidTransientUserGestureActivation =
docShell->GetBrowsingContext()->HasValidTransientUserGestureActivation();
context && context->HasValidTransientUserGestureActivation();
RefPtr<DocumentLoadListener::OpenPromise> promise;
if (isDocumentLoad) {

View File

@ -1138,17 +1138,22 @@ nsresult nsWindowWatcher::OpenWindowInternal(
newBC->UseRemoteSubframes() ==
!!(chromeFlags & nsIWebBrowserChrome::CHROME_FISSION_WINDOW));
nsCOMPtr<nsPIDOMWindowInner> pInnerWin =
parentWindow ? parentWindow->GetCurrentInnerWindow() : nullptr;
;
RefPtr<nsDocShellLoadState> loadState = aLoadState;
if (uriToLoad && loadState) {
// If a URI was passed to this function, open that, not what was passed in
// the original LoadState. See Bug 1515433.
loadState->SetURI(uriToLoad);
} else if (uriToLoad && aNavigate && !loadState) {
RefPtr<WindowContext> context =
pInnerWin ? pInnerWin->GetWindowContext() : nullptr;
loadState = new nsDocShellLoadState(uriToLoad);
loadState->SetSourceBrowsingContext(parentBC);
loadState->SetHasValidUserGestureActivation(
parentBC && parentBC->HasValidTransientUserGestureActivation());
context && context->HasValidTransientUserGestureActivation());
if (parentBC) {
loadState->SetTriggeringSandboxFlags(parentBC->GetSandboxFlags());
}
@ -1249,8 +1254,6 @@ nsresult nsWindowWatcher::OpenWindowInternal(
if (parentStorageManager && newStorageManager) {
RefPtr<Storage> storage;
nsCOMPtr<nsPIDOMWindowInner> pInnerWin =
parentWindow->GetCurrentInnerWindow();
parentStorageManager->GetStorage(
pInnerWin, subjectPrincipal, subjectPrincipal,
newBC->UsePrivateBrowsing(), getter_AddRefs(storage));