Backed out 4 changesets (bug 1737832, bug 1701001) for causing geckoview failures on noopener-noreferrer-BarProp.window.html. CLOSED TREE
Backed out changeset ff439d9c0391 (bug 1701001) Backed out changeset b0e47b1f4d39 (bug 1701001) Backed out changeset 0e2ca3cc650e (bug 1701001) Backed out changeset 712b897cbc76 (bug 1737832)
This commit is contained in:
@@ -294,7 +294,7 @@ bool BrowsingContext::SameOriginWithTop() {
|
||||
already_AddRefed<BrowsingContext> BrowsingContext::CreateDetached(
|
||||
nsGlobalWindowInner* aParent, BrowsingContext* aOpener,
|
||||
BrowsingContextGroup* aSpecificGroup, const nsAString& aName, Type aType,
|
||||
bool aIsPopupRequested, bool aCreatedDynamically) {
|
||||
bool aCreatedDynamically) {
|
||||
if (aParent) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(aParent->GetWindowContext());
|
||||
MOZ_DIAGNOSTIC_ASSERT(aParent->GetBrowsingContext()->mType == aType);
|
||||
@@ -410,8 +410,6 @@ 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();
|
||||
@@ -456,7 +454,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, false));
|
||||
CreateDetached(nullptr, nullptr, nullptr, u""_ns, aType));
|
||||
bc->mWindowless = bc->IsContent();
|
||||
bc->mEmbeddedByThisProcess = true;
|
||||
bc->EnsureAttached();
|
||||
|
||||
@@ -156,14 +156,6 @@ enum class ExplicitActiveStatus : uint8_t {
|
||||
FIELD(ForceEnableTrackingProtection, bool) \
|
||||
FIELD(UseGlobalHistory, bool) \
|
||||
FIELD(FullscreenAllowedByOwner, bool) \
|
||||
/* \
|
||||
* "is popup" in the spec. \
|
||||
* Set only on top browsing contexts. \
|
||||
* This doesn't indicate whether this is actually a popup or not, \
|
||||
* but whether this browsing context is created by requesting popup or not. \
|
||||
* See also: nsWindowWatcher::ShouldOpenPopup. \
|
||||
*/ \
|
||||
FIELD(IsPopupRequested, bool) \
|
||||
/* These field are used to store the states of autoplay media request on \
|
||||
* GeckoView only, and it would only be modified on the top level browsing \
|
||||
* context. */ \
|
||||
@@ -291,7 +283,7 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
|
||||
static already_AddRefed<BrowsingContext> CreateDetached(
|
||||
nsGlobalWindowInner* aParent, BrowsingContext* aOpener,
|
||||
BrowsingContextGroup* aSpecificGroup, const nsAString& aName, Type aType,
|
||||
bool aIsPopupRequested, bool aCreatedDynamically = false);
|
||||
bool aCreatedDynamically = false);
|
||||
|
||||
void EnsureAttached();
|
||||
|
||||
|
||||
@@ -35,27 +35,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(BarProp)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
bool BarProp::GetVisibleByIsPopup() {
|
||||
// For web content, return the value defined by the spec, instead of
|
||||
// the actual visibility of each bar.
|
||||
//
|
||||
// If this browsing context is created by requesting a popup, all
|
||||
// `BarProp.visible` should return false.
|
||||
RefPtr<BrowsingContext> bc = GetBrowsingContext();
|
||||
if (!bc || bc->IsDiscarded()) {
|
||||
return true;
|
||||
}
|
||||
bc = bc->Top();
|
||||
bool isPopup = bc->GetIsPopupRequested();
|
||||
return !isPopup;
|
||||
}
|
||||
|
||||
bool BarProp::GetVisibleByFlag(uint32_t aChromeFlag, CallerType aCallerType,
|
||||
ErrorResult& aRv) {
|
||||
if (aCallerType != CallerType::System) {
|
||||
return GetVisibleByIsPopup();
|
||||
}
|
||||
|
||||
bool BarProp::GetVisibleByFlag(uint32_t aChromeFlag, ErrorResult& aRv) {
|
||||
nsCOMPtr<nsIWebBrowserChrome> browserChrome = GetBrowserChrome();
|
||||
NS_ENSURE_TRUE(browserChrome, false);
|
||||
|
||||
@@ -103,14 +83,6 @@ already_AddRefed<nsIWebBrowserChrome> BarProp::GetBrowserChrome() {
|
||||
return mDOMWindow->GetWebBrowserChrome();
|
||||
}
|
||||
|
||||
BrowsingContext* BarProp::GetBrowsingContext() {
|
||||
if (!mDOMWindow) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return mDOMWindow->GetBrowsingContext();
|
||||
}
|
||||
|
||||
//
|
||||
// MenubarProp class implementation
|
||||
//
|
||||
@@ -120,8 +92,7 @@ MenubarProp::MenubarProp(nsGlobalWindowInner* aWindow) : BarProp(aWindow) {}
|
||||
MenubarProp::~MenubarProp() = default;
|
||||
|
||||
bool MenubarProp::GetVisible(CallerType aCallerType, ErrorResult& aRv) {
|
||||
return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_MENUBAR,
|
||||
aCallerType, aRv);
|
||||
return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_MENUBAR, aRv);
|
||||
}
|
||||
|
||||
void MenubarProp::SetVisible(bool aVisible, CallerType aCallerType,
|
||||
@@ -139,8 +110,7 @@ ToolbarProp::ToolbarProp(nsGlobalWindowInner* aWindow) : BarProp(aWindow) {}
|
||||
ToolbarProp::~ToolbarProp() = default;
|
||||
|
||||
bool ToolbarProp::GetVisible(CallerType aCallerType, ErrorResult& aRv) {
|
||||
return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_TOOLBAR,
|
||||
aCallerType, aRv);
|
||||
return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_TOOLBAR, aRv);
|
||||
}
|
||||
|
||||
void ToolbarProp::SetVisible(bool aVisible, CallerType aCallerType,
|
||||
@@ -160,7 +130,7 @@ LocationbarProp::~LocationbarProp() = default;
|
||||
|
||||
bool LocationbarProp::GetVisible(CallerType aCallerType, ErrorResult& aRv) {
|
||||
return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_LOCATIONBAR,
|
||||
aCallerType, aRv);
|
||||
aRv);
|
||||
}
|
||||
|
||||
void LocationbarProp::SetVisible(bool aVisible, CallerType aCallerType,
|
||||
@@ -180,7 +150,7 @@ PersonalbarProp::~PersonalbarProp() = default;
|
||||
|
||||
bool PersonalbarProp::GetVisible(CallerType aCallerType, ErrorResult& aRv) {
|
||||
return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR,
|
||||
aCallerType, aRv);
|
||||
aRv);
|
||||
}
|
||||
|
||||
void PersonalbarProp::SetVisible(bool aVisible, CallerType aCallerType,
|
||||
@@ -198,8 +168,7 @@ StatusbarProp::StatusbarProp(nsGlobalWindowInner* aWindow) : BarProp(aWindow) {}
|
||||
StatusbarProp::~StatusbarProp() = default;
|
||||
|
||||
bool StatusbarProp::GetVisible(CallerType aCallerType, ErrorResult& aRv) {
|
||||
return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_STATUSBAR,
|
||||
aCallerType, aRv);
|
||||
return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_STATUSBAR, aRv);
|
||||
}
|
||||
|
||||
void StatusbarProp::SetVisible(bool aVisible, CallerType aCallerType,
|
||||
@@ -218,10 +187,6 @@ ScrollbarsProp::ScrollbarsProp(nsGlobalWindowInner* aWindow)
|
||||
ScrollbarsProp::~ScrollbarsProp() = default;
|
||||
|
||||
bool ScrollbarsProp::GetVisible(CallerType aCallerType, ErrorResult& aRv) {
|
||||
if (aCallerType != CallerType::System) {
|
||||
return BarProp::GetVisibleByIsPopup();
|
||||
}
|
||||
|
||||
if (!mDOMWindow) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include "nsWrapperCache.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/dom/BrowsingContext.h"
|
||||
|
||||
class nsGlobalWindowInner;
|
||||
class nsIWebBrowserChrome;
|
||||
@@ -48,16 +47,12 @@ class BarProp : public nsISupports, public nsWrapperCache {
|
||||
protected:
|
||||
virtual ~BarProp();
|
||||
|
||||
bool GetVisibleByIsPopup();
|
||||
bool GetVisibleByFlag(uint32_t aChromeFlag, CallerType aCallerType,
|
||||
ErrorResult& aRv);
|
||||
bool GetVisibleByFlag(uint32_t aChromeFlag, ErrorResult& aRv);
|
||||
void SetVisibleByFlag(bool aVisible, uint32_t aChromeFlag,
|
||||
CallerType aCallerType, ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<nsIWebBrowserChrome> GetBrowserChrome();
|
||||
|
||||
BrowsingContext* GetBrowsingContext();
|
||||
|
||||
RefPtr<nsGlobalWindowInner> mDOMWindow;
|
||||
};
|
||||
|
||||
|
||||
@@ -345,9 +345,9 @@ static already_AddRefed<BrowsingContext> CreateBrowsingContext(
|
||||
// for the BrowsingContext, and cause no end of trouble.
|
||||
if (IsTopContent(parentBC, aOwner)) {
|
||||
// Create toplevel context without a parent & as Type::Content.
|
||||
return BrowsingContext::CreateDetached(
|
||||
nullptr, opener, aSpecificGroup, frameName,
|
||||
BrowsingContext::Type::Content, false);
|
||||
return BrowsingContext::CreateDetached(nullptr, opener, aSpecificGroup,
|
||||
frameName,
|
||||
BrowsingContext::Type::Content);
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!aOpenWindowInfo,
|
||||
@@ -356,7 +356,7 @@ static already_AddRefed<BrowsingContext> CreateBrowsingContext(
|
||||
MOZ_ASSERT(!aSpecificGroup,
|
||||
"Can't force BrowsingContextGroup for non-toplevel context");
|
||||
return BrowsingContext::CreateDetached(parentInner, nullptr, nullptr,
|
||||
frameName, parentBC->GetType(), false,
|
||||
frameName, parentBC->GetType(),
|
||||
!aNetworkCreated);
|
||||
}
|
||||
|
||||
|
||||
@@ -816,9 +816,9 @@ BrowserChild::GetInterface(const nsIID& aIID, void** aSink) {
|
||||
NS_IMETHODIMP
|
||||
BrowserChild::ProvideWindow(nsIOpenWindowInfo* aOpenWindowInfo,
|
||||
uint32_t aChromeFlags, bool aCalledFromJS,
|
||||
nsIURI* aURI, const nsAString& aName,
|
||||
const nsACString& aFeatures, bool aForceNoOpener,
|
||||
bool aForceNoReferrer, bool aIsPopupRequested,
|
||||
bool aWidthSpecified, nsIURI* aURI,
|
||||
const nsAString& aName, const nsACString& aFeatures,
|
||||
bool aForceNoOpener, bool aForceNoReferrer,
|
||||
nsDocShellLoadState* aLoadState, bool* aWindowIsNew,
|
||||
BrowsingContext** aReturn) {
|
||||
*aReturn = nullptr;
|
||||
@@ -826,7 +826,7 @@ BrowserChild::ProvideWindow(nsIOpenWindowInfo* aOpenWindowInfo,
|
||||
RefPtr<BrowsingContext> parent = aOpenWindowInfo->GetParent();
|
||||
|
||||
int32_t openLocation = nsWindowWatcher::GetWindowOpenLocation(
|
||||
parent->GetDOMWindow(), aChromeFlags, aCalledFromJS,
|
||||
parent->GetDOMWindow(), aChromeFlags, aCalledFromJS, aWidthSpecified,
|
||||
aOpenWindowInfo->GetIsForPrinting());
|
||||
|
||||
// If it turns out we're opening in the current browser, just hand over the
|
||||
@@ -848,9 +848,9 @@ BrowserChild::ProvideWindow(nsIOpenWindowInfo* aOpenWindowInfo,
|
||||
// open window call was canceled. It's important that we pass this error
|
||||
// code back to our caller.
|
||||
ContentChild* cc = ContentChild::GetSingleton();
|
||||
return cc->ProvideWindowCommon(
|
||||
this, aOpenWindowInfo, aChromeFlags, aCalledFromJS, aURI, aName,
|
||||
aFeatures, aForceNoOpener, aForceNoReferrer, aIsPopupRequested,
|
||||
return cc->ProvideWindowCommon(this, aOpenWindowInfo, aChromeFlags,
|
||||
aCalledFromJS, aWidthSpecified, aURI, aName,
|
||||
aFeatures, aForceNoOpener, aForceNoReferrer,
|
||||
aLoadState, aWindowIsNew, aReturn);
|
||||
}
|
||||
|
||||
|
||||
@@ -966,11 +966,10 @@ static nsresult GetCreateWindowParams(nsIOpenWindowInfo* aOpenWindowInfo,
|
||||
|
||||
nsresult ContentChild::ProvideWindowCommon(
|
||||
BrowserChild* aTabOpener, nsIOpenWindowInfo* aOpenWindowInfo,
|
||||
uint32_t aChromeFlags, bool aCalledFromJS, nsIURI* aURI,
|
||||
const nsAString& aName, const nsACString& aFeatures, bool aForceNoOpener,
|
||||
bool aForceNoReferrer, bool aIsPopupRequested,
|
||||
nsDocShellLoadState* aLoadState, bool* aWindowIsNew,
|
||||
BrowsingContext** aReturn) {
|
||||
uint32_t aChromeFlags, bool aCalledFromJS, bool aWidthSpecified,
|
||||
nsIURI* aURI, const nsAString& aName, const nsACString& aFeatures,
|
||||
bool aForceNoOpener, bool aForceNoReferrer, nsDocShellLoadState* aLoadState,
|
||||
bool* aWindowIsNew, BrowsingContext** aReturn) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(aTabOpener, "We must have a tab opener");
|
||||
|
||||
*aReturn = nullptr;
|
||||
@@ -1038,9 +1037,9 @@ nsresult ContentChild::ProvideWindowCommon(
|
||||
MOZ_DIAGNOSTIC_ASSERT(!nsContentUtils::IsSpecialName(name));
|
||||
|
||||
Unused << SendCreateWindowInDifferentProcess(
|
||||
aTabOpener, parent, aChromeFlags, aCalledFromJS, aURI, features,
|
||||
fullZoom, name, triggeringPrincipal, csp, referrerInfo,
|
||||
aOpenWindowInfo->GetOriginAttributes());
|
||||
aTabOpener, parent, aChromeFlags, aCalledFromJS, aWidthSpecified,
|
||||
aURI, features, fullZoom, name, triggeringPrincipal, csp,
|
||||
referrerInfo, aOpenWindowInfo->GetOriginAttributes());
|
||||
|
||||
// We return NS_ERROR_ABORT, so that the caller knows that we've abandoned
|
||||
// the window open as far as it is concerned.
|
||||
@@ -1059,8 +1058,7 @@ nsresult ContentChild::ProvideWindowCommon(
|
||||
}
|
||||
|
||||
RefPtr<BrowsingContext> browsingContext = BrowsingContext::CreateDetached(
|
||||
nullptr, openerBC, nullptr, aName, BrowsingContext::Type::Content,
|
||||
aIsPopupRequested);
|
||||
nullptr, openerBC, nullptr, aName, BrowsingContext::Type::Content);
|
||||
MOZ_ALWAYS_SUCCEEDS(browsingContext->SetRemoteTabs(true));
|
||||
MOZ_ALWAYS_SUCCEEDS(browsingContext->SetRemoteSubframes(useRemoteSubframes));
|
||||
MOZ_ALWAYS_SUCCEEDS(browsingContext->SetOriginAttributes(
|
||||
@@ -1241,7 +1239,7 @@ nsresult ContentChild::ProvideWindowCommon(
|
||||
}
|
||||
|
||||
SendCreateWindow(aTabOpener, parent, newChild, aChromeFlags, aCalledFromJS,
|
||||
aOpenWindowInfo->GetIsForPrinting(),
|
||||
aWidthSpecified, aOpenWindowInfo->GetIsForPrinting(),
|
||||
aOpenWindowInfo->GetIsForWindowDotPrint(), aURI, features,
|
||||
fullZoom, Principal(triggeringPrincipal), csp, referrerInfo,
|
||||
aOpenWindowInfo->GetOriginAttributes(), std::move(resolve),
|
||||
|
||||
@@ -113,9 +113,9 @@ class ContentChild final : public PContentChild,
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult ProvideWindowCommon(
|
||||
BrowserChild* aTabOpener, nsIOpenWindowInfo* aOpenWindowInfo,
|
||||
uint32_t aChromeFlags, bool aCalledFromJS, nsIURI* aURI,
|
||||
const nsAString& aName, const nsACString& aFeatures, bool aForceNoOpener,
|
||||
bool aForceNoReferrer, bool aIsPopupRequested,
|
||||
uint32_t aChromeFlags, bool aCalledFromJS, bool aWidthSpecified,
|
||||
nsIURI* aURI, const nsAString& aName, const nsACString& aFeatures,
|
||||
bool aForceNoOpener, bool aForceNoReferrer,
|
||||
nsDocShellLoadState* aLoadState, bool* aWindowIsNew,
|
||||
BrowsingContext** aReturn);
|
||||
|
||||
|
||||
@@ -5129,8 +5129,9 @@ bool ContentParent::DeallocPWebBrowserPersistDocumentParent(
|
||||
mozilla::ipc::IPCResult ContentParent::CommonCreateWindow(
|
||||
PBrowserParent* aThisTab, BrowsingContext* aParent, bool aSetOpener,
|
||||
const uint32_t& aChromeFlags, const bool& aCalledFromJS,
|
||||
const bool& aForPrinting, const bool& aForWindowDotPrint,
|
||||
nsIURI* aURIToLoad, const nsCString& aFeatures, const float& aFullZoom,
|
||||
const bool& aWidthSpecified, const bool& aForPrinting,
|
||||
const bool& aForWindowDotPrint, nsIURI* aURIToLoad,
|
||||
const nsCString& aFeatures, const float& aFullZoom,
|
||||
BrowserParent* aNextRemoteBrowser, const nsString& aName, nsresult& aResult,
|
||||
nsCOMPtr<nsIRemoteTab>& aNewRemoteTab, bool* aWindowIsNew,
|
||||
int32_t& aOpenLocation, nsIPrincipal* aTriggeringPrincipal,
|
||||
@@ -5218,7 +5219,7 @@ mozilla::ipc::IPCResult ContentParent::CommonCreateWindow(
|
||||
}
|
||||
|
||||
aOpenLocation = nsWindowWatcher::GetWindowOpenLocation(
|
||||
outerWin, aChromeFlags, aCalledFromJS, aForPrinting);
|
||||
outerWin, aChromeFlags, aCalledFromJS, aWidthSpecified, aForPrinting);
|
||||
|
||||
MOZ_ASSERT(aOpenLocation == nsIBrowserDOMWindow::OPEN_NEWTAB ||
|
||||
aOpenLocation == nsIBrowserDOMWindow::OPEN_NEWWINDOW ||
|
||||
@@ -5346,8 +5347,8 @@ mozilla::ipc::IPCResult ContentParent::CommonCreateWindow(
|
||||
mozilla::ipc::IPCResult ContentParent::RecvCreateWindow(
|
||||
PBrowserParent* aThisTab, const MaybeDiscarded<BrowsingContext>& aParent,
|
||||
PBrowserParent* aNewTab, const uint32_t& aChromeFlags,
|
||||
const bool& aCalledFromJS, const bool& aForPrinting,
|
||||
const bool& aForPrintPreview, nsIURI* aURIToLoad,
|
||||
const bool& aCalledFromJS, const bool& aWidthSpecified,
|
||||
const bool& aForPrinting, const bool& aForPrintPreview, nsIURI* aURIToLoad,
|
||||
const nsCString& aFeatures, const float& aFullZoom,
|
||||
const IPC::Principal& aTriggeringPrincipal, nsIContentSecurityPolicy* aCsp,
|
||||
nsIReferrerInfo* aReferrerInfo, const OriginAttributes& aOriginAttributes,
|
||||
@@ -5431,10 +5432,10 @@ mozilla::ipc::IPCResult ContentParent::RecvCreateWindow(
|
||||
int32_t openLocation = nsIBrowserDOMWindow::OPEN_NEWWINDOW;
|
||||
mozilla::ipc::IPCResult ipcResult = CommonCreateWindow(
|
||||
aThisTab, parent, newBCOpenerId != 0, aChromeFlags, aCalledFromJS,
|
||||
aForPrinting, aForPrintPreview, aURIToLoad, aFeatures, aFullZoom, newTab,
|
||||
VoidString(), rv, newRemoteTab, &cwi.windowOpened(), openLocation,
|
||||
aTriggeringPrincipal, aReferrerInfo, /* aLoadUri = */ false, aCsp,
|
||||
aOriginAttributes);
|
||||
aWidthSpecified, aForPrinting, aForPrintPreview, aURIToLoad, aFeatures,
|
||||
aFullZoom, newTab, VoidString(), rv, newRemoteTab, &cwi.windowOpened(),
|
||||
openLocation, aTriggeringPrincipal, aReferrerInfo, /* aLoadUri = */ false,
|
||||
aCsp, aOriginAttributes);
|
||||
if (!ipcResult) {
|
||||
return ipcResult;
|
||||
}
|
||||
@@ -5462,8 +5463,9 @@ mozilla::ipc::IPCResult ContentParent::RecvCreateWindow(
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvCreateWindowInDifferentProcess(
|
||||
PBrowserParent* aThisTab, const MaybeDiscarded<BrowsingContext>& aParent,
|
||||
const uint32_t& aChromeFlags, const bool& aCalledFromJS, nsIURI* aURIToLoad,
|
||||
const nsCString& aFeatures, const float& aFullZoom, const nsString& aName,
|
||||
const uint32_t& aChromeFlags, const bool& aCalledFromJS,
|
||||
const bool& aWidthSpecified, nsIURI* aURIToLoad, const nsCString& aFeatures,
|
||||
const float& aFullZoom, const nsString& aName,
|
||||
nsIPrincipal* aTriggeringPrincipal, nsIContentSecurityPolicy* aCsp,
|
||||
nsIReferrerInfo* aReferrerInfo, const OriginAttributes& aOriginAttributes) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(!nsContentUtils::IsSpecialName(aName));
|
||||
@@ -5506,7 +5508,7 @@ mozilla::ipc::IPCResult ContentParent::RecvCreateWindowInDifferentProcess(
|
||||
nsresult rv;
|
||||
mozilla::ipc::IPCResult ipcResult = CommonCreateWindow(
|
||||
aThisTab, parent, /* aSetOpener = */ false, aChromeFlags, aCalledFromJS,
|
||||
/* aForPrinting = */ false,
|
||||
aWidthSpecified, /* aForPrinting = */ false,
|
||||
/* aForPrintPreview = */ false, aURIToLoad, aFeatures, aFullZoom,
|
||||
/* aNextRemoteBrowser = */ nullptr, aName, rv, newRemoteTab, &windowIsNew,
|
||||
openLocation, aTriggeringPrincipal, aReferrerInfo,
|
||||
|
||||
@@ -518,8 +518,9 @@ class ContentParent final
|
||||
PBrowserParent* aThisBrowserParent,
|
||||
const MaybeDiscarded<BrowsingContext>& aParent, PBrowserParent* aNewTab,
|
||||
const uint32_t& aChromeFlags, const bool& aCalledFromJS,
|
||||
const bool& aForPrinting, const bool& aForWindowDotPrint,
|
||||
nsIURI* aURIToLoad, const nsCString& aFeatures, const float& aFullZoom,
|
||||
const bool& aWidthSpecified, const bool& aForPrinting,
|
||||
const bool& aForWindowDotPrint, nsIURI* aURIToLoad,
|
||||
const nsCString& aFeatures, const float& aFullZoom,
|
||||
const IPC::Principal& aTriggeringPrincipal,
|
||||
nsIContentSecurityPolicy* aCsp, nsIReferrerInfo* aReferrerInfo,
|
||||
const OriginAttributes& aOriginAttributes,
|
||||
@@ -528,9 +529,10 @@ class ContentParent final
|
||||
mozilla::ipc::IPCResult RecvCreateWindowInDifferentProcess(
|
||||
PBrowserParent* aThisTab, const MaybeDiscarded<BrowsingContext>& aParent,
|
||||
const uint32_t& aChromeFlags, const bool& aCalledFromJS,
|
||||
nsIURI* aURIToLoad, const nsCString& aFeatures, const float& aFullZoom,
|
||||
const nsString& aName, nsIPrincipal* aTriggeringPrincipal,
|
||||
nsIContentSecurityPolicy* aCsp, nsIReferrerInfo* aReferrerInfo,
|
||||
const bool& aWidthSpecified, nsIURI* aURIToLoad,
|
||||
const nsCString& aFeatures, const float& aFullZoom, const nsString& aName,
|
||||
nsIPrincipal* aTriggeringPrincipal, nsIContentSecurityPolicy* aCsp,
|
||||
nsIReferrerInfo* aReferrerInfo,
|
||||
const OriginAttributes& aOriginAttributes);
|
||||
|
||||
static void BroadcastBlobURLRegistration(
|
||||
@@ -762,8 +764,9 @@ class ContentParent final
|
||||
mozilla::ipc::IPCResult CommonCreateWindow(
|
||||
PBrowserParent* aThisTab, BrowsingContext* aParent, bool aSetOpener,
|
||||
const uint32_t& aChromeFlags, const bool& aCalledFromJS,
|
||||
const bool& aForPrinting, const bool& aForWindowDotPrint,
|
||||
nsIURI* aURIToLoad, const nsCString& aFeatures, const float& aFullZoom,
|
||||
const bool& aWidthSpecified, const bool& aForPrinting,
|
||||
const bool& aForWindowDotPrint, nsIURI* aURIToLoad,
|
||||
const nsCString& aFeatures, const float& aFullZoom,
|
||||
BrowserParent* aNextRemoteBrowser, const nsString& aName,
|
||||
nsresult& aResult, nsCOMPtr<nsIRemoteTab>& aNewRemoteTab,
|
||||
bool* aWindowIsNew, int32_t& aOpenLocation,
|
||||
|
||||
@@ -1476,6 +1476,7 @@ parent:
|
||||
PBrowser aNewTab,
|
||||
uint32_t aChromeFlags,
|
||||
bool aCalledFromJS,
|
||||
bool aWidthSpecified,
|
||||
bool aForPrinting,
|
||||
bool aForWindowDotPrint,
|
||||
nsIURI aURIToLoad,
|
||||
@@ -1492,6 +1493,7 @@ parent:
|
||||
MaybeDiscardedBrowsingContext aParent,
|
||||
uint32_t aChromeFlags,
|
||||
bool aCalledFromJS,
|
||||
bool aWidthSpecified,
|
||||
nsIURI aURIToLoad,
|
||||
nsCString aFeatures,
|
||||
float aFullZoom,
|
||||
|
||||
@@ -18,51 +18,13 @@ const TARGET_PAGE = ROOT + "dummy.html";
|
||||
*/
|
||||
function getToolbarsFromBrowserContent(aBrowser) {
|
||||
return SpecialPowers.spawn(aBrowser, [], async function() {
|
||||
// This is still chrome context.
|
||||
// Inject a script that runs on content context, and gather the result.
|
||||
|
||||
let script = content.document.createElement("script");
|
||||
script.textContent = `
|
||||
let bars = [
|
||||
"toolbar",
|
||||
"menubar",
|
||||
"personalbar",
|
||||
"statusbar",
|
||||
"scrollbars",
|
||||
"locationbar",
|
||||
];
|
||||
|
||||
for (let bar of bars) {
|
||||
let node = document.createElement("span");
|
||||
node.id = bar;
|
||||
node.textContent = window[bar].visible;
|
||||
document.body.appendChild(node);
|
||||
}
|
||||
`;
|
||||
content.document.body.appendChild(script);
|
||||
|
||||
let result = {};
|
||||
|
||||
let bars = [
|
||||
"toolbar",
|
||||
"menubar",
|
||||
"personalbar",
|
||||
"statusbar",
|
||||
"scrollbars",
|
||||
"locationbar",
|
||||
];
|
||||
|
||||
for (let bar of bars) {
|
||||
let node = content.document.getElementById(bar);
|
||||
let value = node.textContent;
|
||||
if (value !== "true" && value !== "false") {
|
||||
throw new Error("bar visibility isn't set");
|
||||
}
|
||||
result[bar] = value === "true";
|
||||
node.remove();
|
||||
}
|
||||
|
||||
return result;
|
||||
return {
|
||||
toolbar: content.toolbar.visible,
|
||||
menubar: content.menubar.visible,
|
||||
personalbar: content.personalbar.visible,
|
||||
statusbar: content.statusbar.visible,
|
||||
locationbar: content.locationbar.visible,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -81,7 +43,6 @@ function getToolbarsFromWindowChrome(win) {
|
||||
menubar: win.menubar.visible,
|
||||
personalbar: win.personalbar.visible,
|
||||
statusbar: win.statusbar.visible,
|
||||
scrollbars: win.scrollbars.visible,
|
||||
locationbar: win.locationbar.visible,
|
||||
};
|
||||
}
|
||||
@@ -106,42 +67,19 @@ function testDefaultToolbars(toolbars) {
|
||||
toolbars.statusbar,
|
||||
"statusbar should be visible on default window.open()"
|
||||
);
|
||||
ok(
|
||||
toolbars.scrollbars,
|
||||
"scrollbars should be visible on default window.open()"
|
||||
);
|
||||
ok(toolbars.toolbar, "toolbar should be visible on default window.open()");
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests toolbar visibility when opening a popup window on the content context,
|
||||
* and reading the value from context context.
|
||||
* Tests toolbar visibility when opening a window with non default parameters
|
||||
* on the content context.
|
||||
*
|
||||
* Ensure that locationbar can't be hidden in the content context, see bug#337344.
|
||||
*
|
||||
* @param toolbars
|
||||
* the visibility state of the toolbar elements
|
||||
*/
|
||||
function testNonDefaultContentToolbarsFromContent(toolbars) {
|
||||
// Accessing BarProp.visible from content context should return false for
|
||||
// popup, regardless of the each feature value in window.open parameter.
|
||||
ok(!toolbars.locationbar, "locationbar.visible should be false for popup");
|
||||
ok(!toolbars.menubar, "menubar.visible should be false for popup");
|
||||
ok(!toolbars.personalbar, "personalbar.visible should be false for popup");
|
||||
ok(!toolbars.statusbar, "statusbar.visible should be false for popup");
|
||||
ok(!toolbars.scrollbars, "scrollbars.visible should be false for popup");
|
||||
ok(!toolbars.toolbar, "toolbar.visible should be false for popup");
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests toolbar visibility when opening a popup window on the content context,
|
||||
* and reading the value from chrome context.
|
||||
*
|
||||
* @param toolbars
|
||||
* the visibility state of the toolbar elements
|
||||
*/
|
||||
function testNonDefaultContentToolbarsFromChrome(toolbars) {
|
||||
// Accessing BarProp.visible from chrome context should return the
|
||||
// actual visibility.
|
||||
|
||||
function testNonDefaultContentToolbars(toolbars) {
|
||||
// Locationbar should always be visible on content context
|
||||
ok(
|
||||
toolbars.locationbar,
|
||||
@@ -154,10 +92,6 @@ function testNonDefaultContentToolbarsFromChrome(toolbars) {
|
||||
);
|
||||
// statusbar will report visible=true even when it's hidden because of bug#55820
|
||||
todo(!toolbars.statusbar, "statusbar shouldn't be visible when status=no");
|
||||
ok(
|
||||
toolbars.scrollbars,
|
||||
"scrollbars should be visible even with scrollbars=no"
|
||||
);
|
||||
ok(!toolbars.toolbar, "toolbar shouldn't be visible when toolbar=no");
|
||||
}
|
||||
|
||||
@@ -180,10 +114,6 @@ function testNonDefaultChromeToolbars(toolbars) {
|
||||
"personalbar should not be visible with personalbar=no"
|
||||
);
|
||||
ok(!toolbars.statusbar, "statusbar should not be visible with status=no");
|
||||
ok(
|
||||
toolbars.scrollbars,
|
||||
"scrollbars should be visible even with scrollbars=no"
|
||||
);
|
||||
ok(!toolbars.toolbar, "toolbar should not be visible with toolbar=no");
|
||||
}
|
||||
|
||||
@@ -232,13 +162,13 @@ add_task(async function() {
|
||||
|
||||
let popupBrowser = popupWindow.gBrowser.selectedBrowser;
|
||||
|
||||
// Test toolbars visibility value from content.
|
||||
// Test toolbars visibility
|
||||
let popupToolbars = await getToolbarsFromBrowserContent(popupBrowser);
|
||||
testNonDefaultContentToolbarsFromContent(popupToolbars);
|
||||
testNonDefaultContentToolbars(popupToolbars);
|
||||
|
||||
// Test toolbars visibility value from chrome.
|
||||
// Ensure that chrome toolbars agree with content
|
||||
let chromeToolbars = getToolbarsFromWindowChrome(popupWindow);
|
||||
testNonDefaultContentToolbarsFromChrome(chromeToolbars);
|
||||
testNonDefaultContentToolbars(chromeToolbars);
|
||||
|
||||
// Close the new window
|
||||
await BrowserTestUtils.closeWindow(popupWindow);
|
||||
@@ -272,10 +202,11 @@ add_task(async function() {
|
||||
// No need to wait for this window to load, since it's loading about:blank
|
||||
let popupBrowser = popupWindow.gBrowser.selectedBrowser;
|
||||
let popupToolbars = await getToolbarsFromBrowserContent(popupBrowser);
|
||||
testNonDefaultContentToolbarsFromContent(popupToolbars);
|
||||
testNonDefaultContentToolbars(popupToolbars);
|
||||
|
||||
// Ensure that chrome toolbars agree with content
|
||||
let chromeToolbars = getToolbarsFromWindowChrome(popupWindow);
|
||||
testNonDefaultContentToolbarsFromChrome(chromeToolbars);
|
||||
testNonDefaultContentToolbars(chromeToolbars);
|
||||
|
||||
// Close the new window
|
||||
await BrowserTestUtils.closeWindow(popupWindow);
|
||||
|
||||
@@ -34,6 +34,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=642338
|
||||
// * resizable is false
|
||||
// * scrollbars is false
|
||||
// * status is false
|
||||
// * width is specified
|
||||
var featuresList = [
|
||||
{
|
||||
type: 'non-popup',
|
||||
@@ -77,18 +78,11 @@ var featuresList = [
|
||||
+ ',resizable=no',
|
||||
},
|
||||
{
|
||||
type: 'non-popup',
|
||||
type: 'popup',
|
||||
target: 'width-sized',
|
||||
features: 'toolbar=yes,menubar=yes,status=yes,scrollbars=yes'
|
||||
+ ',width=500',
|
||||
},
|
||||
{
|
||||
// if features isnt empty, toolbar and location defaults to false,
|
||||
// and that results in popup.
|
||||
type: 'popup',
|
||||
target: 'only-width-sized',
|
||||
features: 'width=500',
|
||||
},
|
||||
{
|
||||
type: 'non-popup',
|
||||
target: 'height-sized',
|
||||
@@ -96,16 +90,11 @@ var featuresList = [
|
||||
+ ',height=500',
|
||||
},
|
||||
{
|
||||
type: 'non-popup',
|
||||
type: 'popup',
|
||||
target: 'sized',
|
||||
features: 'toolbar=yes,menubar=yes,status=yes,scrollbars=yes'
|
||||
+ ',width=500,height=500',
|
||||
},
|
||||
{
|
||||
type: 'popup',
|
||||
target: 'only-sized',
|
||||
features: 'width=500,height=500',
|
||||
},
|
||||
];
|
||||
|
||||
var numWindows = 0;
|
||||
@@ -121,13 +110,19 @@ function testWindow(w)
|
||||
}
|
||||
}
|
||||
|
||||
// If popup is opened, all BarProp.visible become false.
|
||||
// If popup is opened, the following properties become false:
|
||||
// * menubar.visible
|
||||
// * toolbar.visible
|
||||
// * personalbar.visible
|
||||
// * status.visible
|
||||
checkFeature('menubar');
|
||||
checkFeature('toolbar');
|
||||
checkFeature('personalbar');
|
||||
checkFeature('scrollbars');
|
||||
checkFeature('statusbar');
|
||||
checkFeature('locationbar');
|
||||
|
||||
// The following aren't affected by feature.
|
||||
is(w.scrollbars.visible, true, `scrollbars should always be visible (${w.name}).`);
|
||||
is(w.statusbar.visible, true, `statusbar should always be visible (${w.name}).`);
|
||||
is(w.locationbar.visible, true, `locationbar should always be visible (${w.name}).`);
|
||||
|
||||
w.close();
|
||||
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
[open-features-is-popup-condition.html?combination]
|
||||
["resizable,scrollbars,status" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["location=no,menubar=no,resizable,scrollbars,status" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["location,toolbar,resizable,scrollbars,status" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["location,toolbar,menubar,resizable=no,scrollbars,status" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["location,toolbar,menubar,resizable,status" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["location,toolbar,menubar,resizable,scrollbars" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["popup=1,location,toolbar,menubar,resizable,scrollbars,status" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["popup=0,location,toolbar,menubar,resizable,scrollbars" should set BarProp visibility to true]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[open-features-is-popup-condition.html?single-1]
|
||||
["popup" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["popup=1" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["popup=0" should set BarProp visibility to true]
|
||||
expected: FAIL
|
||||
|
||||
["location" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["location=yes" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["location=no" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["toolbar" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["toolbar=yes" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["toolbar=no" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["menubar" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["menubar=yes" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["menubar=no" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["resizable" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["resizable=yes" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["resizable=no" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[open-features-is-popup-condition.html?position]
|
||||
["left=500" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["screenX=500" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["top=500" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["screenY=500" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["width=500" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["innerWidth=500" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["outerWidth=500" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["height=500" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["innerHeight=500" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["outerHeight=500" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[open-features-is-popup-condition.html?single-2]
|
||||
["scrollbars" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["scrollbars=yes" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["scrollbars=no" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["status" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["status=yes" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["status=no" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["titlebar" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["titlebar=yes" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["titlebar=no" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["close" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["close=yes" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["close=no" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["minimizable" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["minimizable=yes" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["minimizable=no" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["personalbar" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["personalbar=yes" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
|
||||
["personalbar=no" should set BarProp visibility to false]
|
||||
expected: FAIL
|
||||
@@ -91,11 +91,6 @@ interface nsIWebBrowserChrome : nsISupports
|
||||
|
||||
const unsigned long CHROME_ALL = 0x00000ffe;
|
||||
|
||||
const unsigned long CHROME_MINIMAL_POPUP =
|
||||
CHROME_WINDOW_BORDERS | CHROME_WINDOW_CLOSE | CHROME_WINDOW_RESIZE |
|
||||
CHROME_LOCATIONBAR | CHROME_STATUSBAR | CHROME_SCROLLBARS |
|
||||
CHROME_TITLEBAR | CHROME_WINDOW_MIN;
|
||||
|
||||
/**
|
||||
* The chrome flags for this browser chrome. The implementation should
|
||||
* reflect the value of this attribute by hiding or showing its chrome
|
||||
|
||||
@@ -47,6 +47,9 @@ interface nsIWindowProvider : nsISupports
|
||||
* window if this provider returns null. See nsIWebBrowserChrome for
|
||||
* the possible values of this field.
|
||||
*
|
||||
* @param aWidthSpecified Whether the attempt to create a window is trying
|
||||
* to specify the width for the new window.
|
||||
*
|
||||
* @param aURI The URI to be loaded in the new window (may be NULL). The
|
||||
* nsIWindowProvider implementation must not load this URI into the
|
||||
* window it returns. This URI is provided solely to help the
|
||||
@@ -69,10 +72,6 @@ interface nsIWindowProvider : nsISupports
|
||||
* the feature string to the window it returns in any way it sees fit.
|
||||
* See the nsIWindowWatcher interface for details on feature strings.
|
||||
*
|
||||
* @param aIsPopupRequested True if this window is opened by window.open
|
||||
* with requesting a popup window. This doesn't necessarily mean
|
||||
* whether the actual window is shown as minimal popup or not.
|
||||
*
|
||||
* @param aLoadState Specify setup information of the load in the new window
|
||||
*
|
||||
* @param aWindowIsNew [out] Whether the window being returned was just
|
||||
@@ -98,12 +97,12 @@ interface nsIWindowProvider : nsISupports
|
||||
BrowsingContext provideWindow(in nsIOpenWindowInfo aOpenWindowInfo,
|
||||
in unsigned long aChromeFlags,
|
||||
in boolean aCalledFromJS,
|
||||
in boolean aWidthSpecified,
|
||||
in nsIURI aURI,
|
||||
in AString aName,
|
||||
in AUTF8String aFeatures,
|
||||
in boolean aForceNoOpener,
|
||||
in boolean aForceNoReferrer,
|
||||
in boolean aIsPopupRequested,
|
||||
in nsDocShellLoadStatePtr aLoadState,
|
||||
out boolean aWindowIsNew);
|
||||
};
|
||||
|
||||
@@ -520,11 +520,7 @@ nsWindowWatcher::OpenWindowWithRemoteTab(nsIRemoteTab* aRemoteTab,
|
||||
SizeSpec sizeSpec;
|
||||
CalcSizeSpec(features, false, sizeSpec);
|
||||
|
||||
// This is not initiated by window.open call in content context, and we
|
||||
// don't need to propagate isPopupRequested out-parameter to the resulting
|
||||
// browsing context.
|
||||
bool unused = false;
|
||||
uint32_t chromeFlags = CalculateChromeFlagsForContent(features, &unused);
|
||||
uint32_t chromeFlags = CalculateChromeFlagsForContent(features, sizeSpec);
|
||||
|
||||
if (isPrivateBrowsingWindow) {
|
||||
chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW;
|
||||
@@ -701,19 +697,17 @@ nsresult nsWindowWatcher::OpenWindowInternal(
|
||||
SizeSpec sizeSpec;
|
||||
CalcSizeSpec(features, hasChromeParent, sizeSpec);
|
||||
|
||||
bool isPopupRequested = false;
|
||||
|
||||
// Make sure we calculate the chromeFlags *before* we push the
|
||||
// callee context onto the context stack so that
|
||||
// the calculation sees the actual caller when doing its
|
||||
// security checks.
|
||||
if (hasChromeParent && isCallerChrome && XRE_IsParentProcess()) {
|
||||
chromeFlags =
|
||||
CalculateChromeFlagsForSystem(features, aDialog, uriToLoadIsChrome);
|
||||
if (isCallerChrome && XRE_IsParentProcess()) {
|
||||
chromeFlags = CalculateChromeFlagsForSystem(
|
||||
features, sizeSpec, aDialog, uriToLoadIsChrome, hasChromeParent);
|
||||
} else {
|
||||
MOZ_DIAGNOSTIC_ASSERT(parentBC && parentBC->IsContent(),
|
||||
"content caller must provide content parent");
|
||||
chromeFlags = CalculateChromeFlagsForContent(features, &isPopupRequested);
|
||||
chromeFlags = CalculateChromeFlagsForContent(features, sizeSpec);
|
||||
|
||||
if (aDialog) {
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
@@ -845,10 +839,11 @@ nsresult nsWindowWatcher::OpenWindowInternal(
|
||||
|
||||
nsCOMPtr<nsIWindowProvider> provider = do_GetInterface(parentTreeOwner);
|
||||
if (provider) {
|
||||
rv = provider->ProvideWindow(
|
||||
openWindowInfo, chromeFlags, aCalledFromJS, uriToLoad, name,
|
||||
featuresStr, aForceNoOpener, aForceNoReferrer, isPopupRequested,
|
||||
aLoadState, &windowIsNew, getter_AddRefs(newBC));
|
||||
rv = provider->ProvideWindow(openWindowInfo, chromeFlags, aCalledFromJS,
|
||||
sizeSpec.WidthSpecified(), uriToLoad, name,
|
||||
featuresStr, aForceNoOpener,
|
||||
aForceNoReferrer, aLoadState, &windowIsNew,
|
||||
getter_AddRefs(newBC));
|
||||
|
||||
if (NS_SUCCEEDED(rv) && newBC) {
|
||||
nsCOMPtr<nsIDocShell> newDocShell = newBC->GetDocShell();
|
||||
@@ -1689,7 +1684,7 @@ nsresult nsWindowWatcher::URIfromURL(const nsACString& aURL,
|
||||
// static
|
||||
uint32_t nsWindowWatcher::CalculateChromeFlagsHelper(
|
||||
uint32_t aInitialFlags, const WindowFeatures& aFeatures,
|
||||
bool* presenceFlag) {
|
||||
const SizeSpec& aSizeSpec, bool* presenceFlag, bool aHasChromeParent) {
|
||||
uint32_t chromeFlags = aInitialFlags;
|
||||
|
||||
if (aFeatures.GetBoolWithDefault("titlebar", false, presenceFlag)) {
|
||||
@@ -1724,21 +1719,68 @@ uint32_t nsWindowWatcher::CalculateChromeFlagsHelper(
|
||||
chromeFlags |= nsIWebBrowserChrome::CHROME_SCROLLBARS;
|
||||
}
|
||||
|
||||
if (aHasChromeParent) {
|
||||
return chromeFlags;
|
||||
}
|
||||
|
||||
// Web content isn't allowed to control UI visibility separately, but only
|
||||
// whether to open a popup or not.
|
||||
//
|
||||
// The above code is still necessary to calculate `presenceFlag`.
|
||||
// (`ShouldOpenPopup` early returns and doesn't check all feature)
|
||||
|
||||
if (ShouldOpenPopup(aFeatures, aSizeSpec)) {
|
||||
// Flags for opening a popup, that doesn't have the following:
|
||||
// * nsIWebBrowserChrome::CHROME_TOOLBAR
|
||||
// * nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR
|
||||
// * nsIWebBrowserChrome::CHROME_MENUBAR
|
||||
return aInitialFlags | nsIWebBrowserChrome::CHROME_TITLEBAR |
|
||||
nsIWebBrowserChrome::CHROME_WINDOW_CLOSE |
|
||||
nsIWebBrowserChrome::CHROME_LOCATIONBAR |
|
||||
nsIWebBrowserChrome::CHROME_STATUSBAR |
|
||||
nsIWebBrowserChrome::CHROME_WINDOW_RESIZE |
|
||||
nsIWebBrowserChrome::CHROME_WINDOW_MIN |
|
||||
nsIWebBrowserChrome::CHROME_SCROLLBARS;
|
||||
}
|
||||
|
||||
// Otherwise open the current/new tab in the current/new window
|
||||
// (depends on browser.link.open_newwindow).
|
||||
return aInitialFlags | nsIWebBrowserChrome::CHROME_ALL;
|
||||
}
|
||||
|
||||
// static
|
||||
bool nsWindowWatcher::ShouldOpenPopup(const WindowFeatures& aFeatures) {
|
||||
uint32_t nsWindowWatcher::EnsureFlagsSafeForContent(uint32_t aChromeFlags,
|
||||
bool aChromeURL) {
|
||||
aChromeFlags |= nsIWebBrowserChrome::CHROME_TITLEBAR;
|
||||
aChromeFlags |= nsIWebBrowserChrome::CHROME_WINDOW_CLOSE;
|
||||
aChromeFlags &= ~nsIWebBrowserChrome::CHROME_WINDOW_LOWERED;
|
||||
aChromeFlags &= ~nsIWebBrowserChrome::CHROME_WINDOW_RAISED;
|
||||
aChromeFlags &= ~nsIWebBrowserChrome::CHROME_WINDOW_POPUP;
|
||||
/* Untrusted script is allowed to pose modal windows with a chrome
|
||||
scheme. This check could stand to be better. But it effectively
|
||||
prevents untrusted script from opening modal windows in general
|
||||
while still allowing alerts and the like. */
|
||||
if (!aChromeURL) {
|
||||
aChromeFlags &= ~(nsIWebBrowserChrome::CHROME_MODAL |
|
||||
nsIWebBrowserChrome::CHROME_OPENAS_CHROME);
|
||||
}
|
||||
|
||||
if (!(aChromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME)) {
|
||||
aChromeFlags &= ~nsIWebBrowserChrome::CHROME_DEPENDENT;
|
||||
}
|
||||
|
||||
return aChromeFlags;
|
||||
}
|
||||
|
||||
// static
|
||||
bool nsWindowWatcher::ShouldOpenPopup(const WindowFeatures& aFeatures,
|
||||
const SizeSpec& aSizeSpec) {
|
||||
if (aFeatures.IsEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// NOTE: This is different than chrome-only "popup" feature that is handled
|
||||
// in nsWindowWatcher::CalculateChromeFlagsForSystem.
|
||||
if (aFeatures.Exists("popup")) {
|
||||
return aFeatures.GetBool("popup");
|
||||
}
|
||||
|
||||
// Follow Google Chrome's behavior that opens a popup depending on
|
||||
// the following features.
|
||||
if (!aFeatures.GetBoolWithDefault("location", false) &&
|
||||
!aFeatures.GetBoolWithDefault("toolbar", false)) {
|
||||
return true;
|
||||
@@ -1760,6 +1802,11 @@ bool nsWindowWatcher::ShouldOpenPopup(const WindowFeatures& aFeatures) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Follow Safari's behavior that opens a popup when width is specified.
|
||||
if (aSizeSpec.WidthSpecified()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1768,22 +1815,20 @@ bool nsWindowWatcher::ShouldOpenPopup(const WindowFeatures& aFeatures) {
|
||||
* from a child process. The feature string can only control whether to open a
|
||||
* new tab or a new popup.
|
||||
* @param aFeatures a string containing a list of named features
|
||||
* @param aIsPopupRequested an out parameter that indicates whether a popup
|
||||
* is requested by aFeatures
|
||||
* @param aSizeSpec the result of CalcSizeSpec
|
||||
* @return the chrome bitmask
|
||||
*/
|
||||
// static
|
||||
uint32_t nsWindowWatcher::CalculateChromeFlagsForContent(
|
||||
const WindowFeatures& aFeatures, bool* aIsPopupRequested) {
|
||||
if (aFeatures.IsEmpty() || !ShouldOpenPopup(aFeatures)) {
|
||||
// Open the current/new tab in the current/new window
|
||||
// (depends on browser.link.open_newwindow).
|
||||
const WindowFeatures& aFeatures, const SizeSpec& aSizeSpec) {
|
||||
if (aFeatures.IsEmpty()) {
|
||||
return nsIWebBrowserChrome::CHROME_ALL;
|
||||
}
|
||||
|
||||
// Open a minimal popup.
|
||||
*aIsPopupRequested = true;
|
||||
return nsIWebBrowserChrome::CHROME_MINIMAL_POPUP;
|
||||
uint32_t chromeFlags = CalculateChromeFlagsHelper(
|
||||
nsIWebBrowserChrome::CHROME_WINDOW_BORDERS, aFeatures, aSizeSpec);
|
||||
|
||||
return EnsureFlagsSafeForContent(chromeFlags);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1792,11 +1837,13 @@ uint32_t nsWindowWatcher::CalculateChromeFlagsForContent(
|
||||
* @param aFeatures a string containing a list of named chrome features
|
||||
* @param aDialog affects the assumptions made about unnamed features
|
||||
* @param aChromeURL true if the window is being sent to a chrome:// URL
|
||||
* @param aHasChromeParent true if the parent window is privileged
|
||||
* @return the chrome bitmask
|
||||
*/
|
||||
// static
|
||||
uint32_t nsWindowWatcher::CalculateChromeFlagsForSystem(
|
||||
const WindowFeatures& aFeatures, bool aDialog, bool aChromeURL) {
|
||||
const WindowFeatures& aFeatures, const SizeSpec& aSizeSpec, bool aDialog,
|
||||
bool aChromeURL, bool aHasChromeParent) {
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
MOZ_ASSERT(nsContentUtils::LegacyIsCallerChromeOrNativeCode());
|
||||
|
||||
@@ -1828,8 +1875,8 @@ uint32_t nsWindowWatcher::CalculateChromeFlagsForSystem(
|
||||
}
|
||||
|
||||
/* Next, allow explicitly named options to override the initial settings */
|
||||
chromeFlags =
|
||||
CalculateChromeFlagsHelper(chromeFlags, aFeatures, &presenceFlag);
|
||||
chromeFlags = CalculateChromeFlagsHelper(chromeFlags, aFeatures, aSizeSpec,
|
||||
&presenceFlag, aHasChromeParent);
|
||||
|
||||
// Determine whether the window is a private browsing window
|
||||
if (aFeatures.GetBoolWithDefault("private", false, &presenceFlag)) {
|
||||
@@ -1955,6 +2002,11 @@ uint32_t nsWindowWatcher::CalculateChromeFlagsForSystem(
|
||||
chromeFlags->copy_history
|
||||
*/
|
||||
|
||||
// Check security state for use in determing window dimensions
|
||||
if (!aHasChromeParent) {
|
||||
chromeFlags = EnsureFlagsSafeForContent(chromeFlags, aChromeURL);
|
||||
}
|
||||
|
||||
return chromeFlags;
|
||||
}
|
||||
|
||||
@@ -2409,6 +2461,7 @@ void nsWindowWatcher::SizeOpenedWindow(nsIDocShellTreeOwner* aTreeOwner,
|
||||
int32_t nsWindowWatcher::GetWindowOpenLocation(nsPIDOMWindowOuter* aParent,
|
||||
uint32_t aChromeFlags,
|
||||
bool aCalledFromJS,
|
||||
bool aWidthSpecified,
|
||||
bool aIsForPrinting) {
|
||||
// These windows are not actually visible to the user, so we return the thing
|
||||
// that we can always handle.
|
||||
@@ -2464,16 +2517,16 @@ int32_t nsWindowWatcher::GetWindowOpenLocation(nsPIDOMWindowOuter* aParent,
|
||||
}
|
||||
|
||||
if (restrictionPref == 2) {
|
||||
// Only continue if there is no special chrome flags - with the exception
|
||||
// of the remoteness and private flags, which might have been
|
||||
// automatically flipped by Gecko.
|
||||
// Only continue if there are no width feature and no special
|
||||
// chrome flags - with the exception of the remoteness and private flags,
|
||||
// which might have been automatically flipped by Gecko.
|
||||
int32_t uiChromeFlags = aChromeFlags;
|
||||
uiChromeFlags &= ~(nsIWebBrowserChrome::CHROME_REMOTE_WINDOW |
|
||||
nsIWebBrowserChrome::CHROME_FISSION_WINDOW |
|
||||
nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW |
|
||||
nsIWebBrowserChrome::CHROME_NON_PRIVATE_WINDOW |
|
||||
nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME);
|
||||
if (uiChromeFlags != nsIWebBrowserChrome::CHROME_ALL) {
|
||||
if (uiChromeFlags != nsIWebBrowserChrome::CHROME_ALL || aWidthSpecified) {
|
||||
return nsIBrowserDOMWindow::OPEN_NEWWINDOW;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,8 @@ class nsWindowWatcher : public nsIWindowWatcher,
|
||||
|
||||
static int32_t GetWindowOpenLocation(nsPIDOMWindowOuter* aParent,
|
||||
uint32_t aChromeFlags,
|
||||
bool aCalledFromJS, bool aIsForPrinting);
|
||||
bool aCalledFromJS, bool aWidthSpecified,
|
||||
bool aIsForPrinting);
|
||||
|
||||
// Will first look for a caller on the JS stack, and then fall back on
|
||||
// aCurrentContext if it can't find one.
|
||||
@@ -87,14 +88,15 @@ class nsWindowWatcher : public nsIWindowWatcher,
|
||||
static nsresult URIfromURL(const nsACString& aURL,
|
||||
mozIDOMWindowProxy* aParent, nsIURI** aURI);
|
||||
|
||||
static bool ShouldOpenPopup(const mozilla::dom::WindowFeatures& aFeatures);
|
||||
static bool ShouldOpenPopup(const mozilla::dom::WindowFeatures& aFeatures,
|
||||
const SizeSpec& aSizeSpec);
|
||||
|
||||
static uint32_t CalculateChromeFlagsForContent(
|
||||
const mozilla::dom::WindowFeatures& aFeatures, bool* aIsPopupRequested);
|
||||
const mozilla::dom::WindowFeatures& aFeatures, const SizeSpec& aSizeSpec);
|
||||
|
||||
static uint32_t CalculateChromeFlagsForSystem(
|
||||
const mozilla::dom::WindowFeatures& aFeatures, bool aDialog,
|
||||
bool aChromeURL);
|
||||
const mozilla::dom::WindowFeatures& aFeatures, const SizeSpec& aSizeSpec,
|
||||
bool aDialog, bool aChromeURL, bool aHasChromeParent);
|
||||
|
||||
/* Compute the right SizeSpec based on aFeatures */
|
||||
static void CalcSizeSpec(const mozilla::dom::WindowFeatures& aFeatures,
|
||||
@@ -115,7 +117,10 @@ class nsWindowWatcher : public nsIWindowWatcher,
|
||||
|
||||
static uint32_t CalculateChromeFlagsHelper(
|
||||
uint32_t aInitialFlags, const mozilla::dom::WindowFeatures& aFeatures,
|
||||
bool* presenceFlag = nullptr);
|
||||
const SizeSpec& aSizeSpec, bool* presenceFlag = nullptr,
|
||||
bool aHasChromeParent = false);
|
||||
static uint32_t EnsureFlagsSafeForContent(uint32_t aChromeFlags,
|
||||
bool aChromeURL = false);
|
||||
|
||||
protected:
|
||||
nsTArray<nsWatcherWindowEnumerator*> mEnumeratorList;
|
||||
|
||||
@@ -15,6 +15,11 @@ add_task(async function test_popup_conditions() {
|
||||
// * resizable (defaults to true)
|
||||
// * scrollbars (defaults to false)
|
||||
// * status (defaults to false)
|
||||
// and also the following shouldn't be specified:
|
||||
// * left or screenX
|
||||
// * top or screenY
|
||||
// * width or innerWidth
|
||||
// * height or innerHeight
|
||||
{ features: "location,menubar,resizable,scrollbars,status", popup: false },
|
||||
{ features: "toolbar,menubar,resizable,scrollbars,status", popup: false },
|
||||
{
|
||||
@@ -71,11 +76,11 @@ add_task(async function test_popup_conditions() {
|
||||
{ features: "location,menubar,resizable,scrollbars", popup: true },
|
||||
{ features: "location,menubar,resizable,scrollbars,status=0", popup: true },
|
||||
|
||||
// width and innerWidth have no effect.
|
||||
{ features: "location,menubar,scrollbars,status,width=100", popup: false },
|
||||
// If either width or innerWidth is specified, popup.
|
||||
{ features: "location,menubar,scrollbars,status,width=100", popup: true },
|
||||
{
|
||||
features: "location,menubar,scrollbars,status,innerWidth=100",
|
||||
popup: false,
|
||||
popup: true,
|
||||
},
|
||||
|
||||
// outerWidth has no effect.
|
||||
|
||||
@@ -521,9 +521,9 @@ NS_IMETHODIMP nsContentTreeOwner::SetTitle(const nsAString& aTitle) {
|
||||
NS_IMETHODIMP
|
||||
nsContentTreeOwner::ProvideWindow(
|
||||
nsIOpenWindowInfo* aOpenWindowInfo, uint32_t aChromeFlags,
|
||||
bool aCalledFromJS, nsIURI* aURI, const nsAString& aName,
|
||||
const nsACString& aFeatures, bool aForceNoOpener, bool aForceNoReferrer,
|
||||
bool aIsPopupRequested, nsDocShellLoadState* aLoadState, bool* aWindowIsNew,
|
||||
bool aCalledFromJS, bool aWidthSpecified, nsIURI* aURI,
|
||||
const nsAString& aName, const nsACString& aFeatures, bool aForceNoOpener,
|
||||
bool aForceNoReferrer, nsDocShellLoadState* aLoadState, bool* aWindowIsNew,
|
||||
dom::BrowsingContext** aReturn) {
|
||||
NS_ENSURE_ARG_POINTER(aOpenWindowInfo);
|
||||
|
||||
@@ -545,7 +545,7 @@ nsContentTreeOwner::ProvideWindow(
|
||||
#endif
|
||||
|
||||
int32_t openLocation = nsWindowWatcher::GetWindowOpenLocation(
|
||||
parent->GetDOMWindow(), aChromeFlags, aCalledFromJS,
|
||||
parent->GetDOMWindow(), aChromeFlags, aCalledFromJS, aWidthSpecified,
|
||||
aOpenWindowInfo->GetIsForPrinting());
|
||||
|
||||
if (openLocation != nsIBrowserDOMWindow::OPEN_NEWTAB &&
|
||||
|
||||
Reference in New Issue
Block a user