Bug 1697927 - Part 1: Only expose HadOriginalOpener on BrowsingContext, r=farre

Differential Revision: https://phabricator.services.mozilla.com/D108860
This commit is contained in:
Nika Layzell 2021-03-18 16:15:17 +00:00
parent b2e94b592b
commit 27ff2d45df
4 changed files with 6 additions and 15 deletions

View File

@ -4822,7 +4822,7 @@ bool nsGlobalWindowOuter::CanMoveResizeWindows(CallerType aCallerType) {
if (aCallerType != CallerType::System) {
// Don't allow scripts to move or resize windows that were not opened by a
// script.
if (!HadOriginalOpener()) {
if (!mBrowsingContext->HadOriginalOpener()) {
return false;
}
@ -6158,8 +6158,9 @@ void nsGlobalWindowOuter::CloseOuter(bool aTrustedCaller) {
nsresult rv = mDoc->GetURL(url);
NS_ENSURE_SUCCESS_VOID(rv);
if (!StringBeginsWith(url, u"about:neterror"_ns) && !HadOriginalOpener() &&
!aTrustedCaller && !IsOnlyTopLevelDocumentInSHistory()) {
if (!StringBeginsWith(url, u"about:neterror"_ns) &&
!mBrowsingContext->HadOriginalOpener() && !aTrustedCaller &&
!IsOnlyTopLevelDocumentInSHistory()) {
bool allowClose =
mAllowScriptsToClose ||
Preferences::GetBool("dom.allow_scripts_to_close_windows", true);
@ -7439,10 +7440,6 @@ int16_t nsGlobalWindowOuter::Orientation(CallerType aCallerType) const {
}
#endif
bool nsPIDOMWindowOuter::HadOriginalOpener() const {
return nsGlobalWindowOuter::Cast(this)->HadOriginalOpener();
}
#if defined(_WINDOWS_) && !defined(MOZ_WRAPPED_WINDOWS_H)
# pragma message( \
"wrapper failure reason: " MOZ_WINDOWS_WRAPPER_DISABLED_REASON)

View File

@ -458,10 +458,6 @@ class nsGlobalWindowOuter final : public mozilla::dom::EventTarget,
bool IsCleanedUp() const { return mCleanedUp; }
bool HadOriginalOpener() const {
return GetBrowsingContext()->HadOriginalOpener();
}
virtual void FirePopupBlockedEvent(
Document* aDoc, nsIURI* aPopupURI, const nsAString& aPopupWindowName,
const nsAString& aPopupWindowFeatures) override;

View File

@ -789,8 +789,6 @@ class nsPIDOMWindowOuter : public mozIDOMWindowProxy {
float GetDevicePixelRatio(mozilla::dom::CallerType aCallerType);
bool HadOriginalOpener() const;
virtual nsPIDOMWindowOuter* GetPrivateRoot() = 0;
/**

View File

@ -283,7 +283,7 @@ nsresult ClientSource::WindowExecutionReady(nsPIDOMWindowInner* aInnerWindow) {
FrameType frameType = FrameType::Top_level;
if (!outer->GetBrowsingContext()->IsTop()) {
frameType = FrameType::Nested;
} else if (outer->HadOriginalOpener()) {
} else if (outer->GetBrowsingContext()->HadOriginalOpener()) {
frameType = FrameType::Auxiliary;
}
@ -325,7 +325,7 @@ nsresult ClientSource::DocShellExecutionReady(nsIDocShell* aDocShell) {
FrameType frameType = FrameType::Top_level;
if (!outer->GetBrowsingContext()->IsTop()) {
frameType = FrameType::Nested;
} else if (outer->HadOriginalOpener()) {
} else if (outer->GetBrowsingContext()->HadOriginalOpener()) {
frameType = FrameType::Auxiliary;
}