Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Backed out changeset ce050fe2bd45 (bug 1527287) for causing merge con…
Browse files Browse the repository at this point in the history
…flicts. CLOSED TREE
  • Loading branch information
cristianbrindusan committed Apr 24, 2019
1 parent 8aa7083 commit 51f9bbd
Show file tree
Hide file tree
Showing 23 changed files with 71 additions and 132 deletions.
9 changes: 2 additions & 7 deletions browser/base/content/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5749,13 +5749,8 @@ nsBrowserAccess.prototype = {
aWhere = Services.prefs.getIntPref("browser.link.open_newwindow");
}

let referrerInfo;
if (aFlags & Ci.nsIBrowserDOMWindow.OPEN_NO_REFERRER) {
referrerInfo = new ReferrerInfo(Ci.nsIHttpChannel.REFERRER_POLICY_UNSET, false, null);
} else {
referrerInfo = new ReferrerInfo(Ci.nsIHttpChannel.REFERRER_POLICY_UNSET, true,
aOpener ? makeURI(aOpener.location.href) : null);
}
let referrerInfo = new ReferrerInfo(Ci.nsIHttpChannel.REFERRER_POLICY_UNSET, true,
aOpener ? makeURI(aOpener.location.href) : null);
if (aOpener && aOpener.document) {
referrerInfo.referrerPolicy = aOpener.document.referrerPolicy;
}
Expand Down
7 changes: 2 additions & 5 deletions devtools/client/responsive.html/browser/tunnel.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,16 +263,13 @@ function tunnelToInnerBrowser(outer, inner) {
const { detail } = event;
event.preventDefault();
const uri = Services.io.newURI(detail.url);
let flags = Ci.nsIBrowserDOMWindow.OPEN_NEWTAB;
if (detail.forceNoReferrer) {
flags |= Ci.nsIBrowserDOMWindow.OPEN_NO_REFERRER;
}
// This API is used mainly because it's near the path used for <a target/> with
// regular browser tabs (which calls `openURIInFrame`). The more elaborate APIs
// that support openers, window features, etc. didn't seem callable from JS and / or
// this event doesn't give enough info to use them.
browserWindow.browserDOMWindow
.openURI(uri, null, flags, Ci.nsIBrowserDOMWindow.OPEN_NEW,
.openURI(uri, null, Ci.nsIBrowserDOMWindow.OPEN_NEWTAB,
Ci.nsIBrowserDOMWindow.OPEN_NEW,
outer.contentPrincipal);
},

Expand Down
12 changes: 2 additions & 10 deletions dom/base/nsGlobalWindowOuter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7070,7 +7070,6 @@ nsresult nsGlobalWindowOuter::OpenInternal(

nsAutoCString options;
bool forceNoOpener = aForceNoOpener;
bool forceNoReferrer = false;
// Unlike other window flags, "noopener" comes from splitting on commas with
// HTML whitespace trimming...
nsCharSeparatedTokenizerTemplate<nsContentUtils::IsHTMLWhitespace> tok(
Expand All @@ -7081,13 +7080,6 @@ nsresult nsGlobalWindowOuter::OpenInternal(
forceNoOpener = true;
continue;
}
if (StaticPrefs::dom_window_open_noreferrer_enabled() &&
nextTok.LowerCaseEqualsLiteral("noreferrer")) {
forceNoReferrer = true;
// noreferrer implies noopener
forceNoOpener = true;
continue;
}
// Want to create a copy of the options without 'noopener' because having
// 'noopener' in the options affects other window features.
if (!options.IsEmpty()) {
Expand Down Expand Up @@ -7193,7 +7185,7 @@ nsresult nsGlobalWindowOuter::OpenInternal(
rv = pwwatch->OpenWindow2(
this, url.IsVoid() ? nullptr : url.get(), name_ptr, options_ptr,
/* aCalledFromScript = */ true, aDialog, aNavigate, argv,
isPopupSpamWindow, forceNoOpener, forceNoReferrer, aLoadState,
isPopupSpamWindow, forceNoOpener, aLoadState,
getter_AddRefs(domReturn));
} else {
// Force a system caller here so that the window watcher won't screw us
Expand All @@ -7213,7 +7205,7 @@ nsresult nsGlobalWindowOuter::OpenInternal(
rv = pwwatch->OpenWindow2(
this, url.IsVoid() ? nullptr : url.get(), name_ptr, options_ptr,
/* aCalledFromScript = */ false, aDialog, aNavigate, aExtraArgument,
isPopupSpamWindow, forceNoOpener, forceNoReferrer, aLoadState,
isPopupSpamWindow, forceNoOpener, aLoadState,
getter_AddRefs(domReturn));
}
}
Expand Down
12 changes: 4 additions & 8 deletions dom/browser-element/BrowserElementParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ BrowserElementParent::DispatchOpenWindowEvent(Element* aOpenerFrameElement,
Element* aPopupFrameElement,
const nsAString& aURL,
const nsAString& aName,
bool aForceNoReferrer,
const nsAString& aFeatures) {
// Dispatch a CustomEvent at aOpenerFrameElement with a detail object
// (OpenWindowEventDetail) containing aPopupFrameElement, aURL, aName, and
Expand All @@ -131,7 +130,6 @@ BrowserElementParent::DispatchOpenWindowEvent(Element* aOpenerFrameElement,
detail.mName = aName;
detail.mFeatures = aFeatures;
detail.mFrameElement = aPopupFrameElement;
detail.mForceNoReferrer = aForceNoReferrer;

nsIGlobalObject* sgo = aPopupFrameElement->OwnerDoc()->GetScopeObject();
if (!sgo) {
Expand Down Expand Up @@ -175,8 +173,7 @@ BrowserElementParent::DispatchOpenWindowEvent(Element* aOpenerFrameElement,
/*static*/
BrowserElementParent::OpenWindowResult BrowserElementParent::OpenWindowOOP(
TabParent* aOpenerTabParent, TabParent* aPopupTabParent,
const nsAString& aURL, const nsAString& aName, bool aForceNoReferrer,
const nsAString& aFeatures) {
const nsAString& aURL, const nsAString& aName, const nsAString& aFeatures) {
// Create an iframe owned by the same document which owns openerFrameElement.
nsCOMPtr<Element> openerFrameElement = aOpenerTabParent->GetOwnerElement();
NS_ENSURE_TRUE(openerFrameElement, BrowserElementParent::OPEN_WINDOW_IGNORED);
Expand All @@ -195,9 +192,8 @@ BrowserElementParent::OpenWindowResult BrowserElementParent::OpenWindowOOP(
// allowed.
popupFrameElement->DisallowCreateFrameLoader();

OpenWindowResult opened =
DispatchOpenWindowEvent(openerFrameElement, popupFrameElement, aURL,
aName, aForceNoReferrer, aFeatures);
OpenWindowResult opened = DispatchOpenWindowEvent(
openerFrameElement, popupFrameElement, aURL, aName, aFeatures);

if (opened != BrowserElementParent::OPEN_WINDOW_ADDED) {
return opened;
Expand Down Expand Up @@ -253,7 +249,7 @@ BrowserElementParent::OpenWindowInProcess(BrowsingContext* aOpenerWindow,

OpenWindowResult opened = DispatchOpenWindowEvent(
openerFrameElement, popupFrameElement, NS_ConvertUTF8toUTF16(spec), aName,
false, NS_ConvertUTF8toUTF16(aFeatures));
NS_ConvertUTF8toUTF16(aFeatures));

if (opened != BrowserElementParent::OPEN_WINDOW_ADDED) {
return opened;
Expand Down
3 changes: 1 addition & 2 deletions dom/browser-element/BrowserElementParent.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ class BrowserElementParent {
dom::TabParent* aPopupTabParent,
const nsAString& aURL,
const nsAString& aName,
bool aForceNoReferrer,
const nsAString& aFeatures);

/**
Expand All @@ -112,7 +111,7 @@ class BrowserElementParent {
private:
static OpenWindowResult DispatchOpenWindowEvent(
dom::Element* aOpenerFrameElement, dom::Element* aPopupFrameElement,
const nsAString& aURL, const nsAString& aName, bool aForceNoReferrer,
const nsAString& aURL, const nsAString& aName,
const nsAString& aFeatures);
};

Expand Down
1 change: 0 additions & 1 deletion dom/clients/manager/ClientOpenWindowUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ nsresult OpenWindow(const ClientOpenWindowArgs& aArgs,
// opener anyway, and we _do_ want the returned
// window.
/* aForceNoOpener = */ false,
/* aForceNoReferrer = */ false,
/* aLoadInfp = */ nullptr, getter_AddRefs(newWindow));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
Expand Down
6 changes: 0 additions & 6 deletions dom/interfaces/base/nsIBrowserDOMWindow.idl
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,6 @@ interface nsIBrowserDOMWindow : nsISupports
*/
const long OPEN_NO_OPENER = 0x4;

/**
* Don't set the referrer on the navigation inside the window which is
* being opened.
*/
const long OPEN_NO_REFERRER = 0x8;

/**
* Create the content window for the given URI.

Expand Down
40 changes: 17 additions & 23 deletions dom/ipc/ContentChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,18 +754,18 @@ ContentChild::ProvideWindow(mozIDOMWindowProxy* aParent, uint32_t aChromeFlags,
bool aCalledFromJS, bool aPositionSpecified,
bool aSizeSpecified, nsIURI* aURI,
const nsAString& aName, const nsACString& aFeatures,
bool aForceNoOpener, bool aForceNoReferrer,
bool aForceNoOpener,
nsDocShellLoadState* aLoadState, bool* aWindowIsNew,
mozIDOMWindowProxy** aReturn) {
return ProvideWindowCommon(
nullptr, aParent, false, aChromeFlags, aCalledFromJS, aPositionSpecified,
aSizeSpecified, aURI, aName, aFeatures, aForceNoOpener, aForceNoReferrer,
aLoadState, aWindowIsNew, aReturn);
return ProvideWindowCommon(nullptr, aParent, false, aChromeFlags,
aCalledFromJS, aPositionSpecified, aSizeSpecified,
aURI, aName, aFeatures, aForceNoOpener, aLoadState,
aWindowIsNew, aReturn);
}

static nsresult GetCreateWindowParams(mozIDOMWindowProxy* aParent,
nsDocShellLoadState* aLoadState,
bool aForceNoReferrer, float* aFullZoom,
float* aFullZoom,
nsIReferrerInfo** aReferrerInfo,
nsIPrincipal** aTriggeringPrincipal,
nsIContentSecurityPolicy** aCsp) {
Expand All @@ -781,11 +781,7 @@ static nsresult GetCreateWindowParams(mozIDOMWindowProxy* aParent,
}

nsCOMPtr<nsIReferrerInfo> referrerInfo;
if (aForceNoReferrer) {
referrerInfo = new ReferrerInfo(
nullptr, mozilla::net::ReferrerPolicy::RP_Unset, false);
}
if (aLoadState && !referrerInfo) {
if (aLoadState) {
referrerInfo = aLoadState->GetReferrerInfo();
}

Expand Down Expand Up @@ -846,7 +842,7 @@ nsresult ContentChild::ProvideWindowCommon(
TabChild* aTabOpener, mozIDOMWindowProxy* aParent, bool aIframeMoz,
uint32_t aChromeFlags, bool aCalledFromJS, bool aPositionSpecified,
bool aSizeSpecified, nsIURI* aURI, const nsAString& aName,
const nsACString& aFeatures, bool aForceNoOpener, bool aForceNoReferrer,
const nsACString& aFeatures, bool aForceNoOpener,
nsDocShellLoadState* aLoadState, bool* aWindowIsNew,
mozIDOMWindowProxy** aReturn) {
*aReturn = nullptr;
Expand Down Expand Up @@ -892,10 +888,9 @@ nsresult ContentChild::ProvideWindowCommon(
nsCOMPtr<nsIPrincipal> triggeringPrincipal;
nsCOMPtr<nsIContentSecurityPolicy> csp;
nsCOMPtr<nsIReferrerInfo> referrerInfo;
rv = GetCreateWindowParams(aParent, aLoadState, aForceNoReferrer, &fullZoom,
getter_AddRefs(referrerInfo),
getter_AddRefs(triggeringPrincipal),
getter_AddRefs(csp));
rv = GetCreateWindowParams(
aParent, aLoadState, &fullZoom, getter_AddRefs(referrerInfo),
getter_AddRefs(triggeringPrincipal), getter_AddRefs(csp));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
Expand Down Expand Up @@ -1111,18 +1106,17 @@ nsresult ContentChild::ProvideWindowCommon(

// NOTE: BrowserFrameOpenWindowPromise is the same type as
// CreateWindowPromise, and this code depends on that fact.
newChild->SendBrowserFrameOpenWindow(
aTabOpener, NS_ConvertUTF8toUTF16(url), name, aForceNoReferrer,
NS_ConvertUTF8toUTF16(features), std::move(resolve), std::move(reject));
newChild->SendBrowserFrameOpenWindow(aTabOpener, NS_ConvertUTF8toUTF16(url),
name, NS_ConvertUTF8toUTF16(features),
std::move(resolve), std::move(reject));
} else {
float fullZoom;
nsCOMPtr<nsIPrincipal> triggeringPrincipal;
nsCOMPtr<nsIContentSecurityPolicy> csp;
nsCOMPtr<nsIReferrerInfo> referrerInfo;
rv = GetCreateWindowParams(aParent, aLoadState, aForceNoReferrer, &fullZoom,
getter_AddRefs(referrerInfo),
getter_AddRefs(triggeringPrincipal),
getter_AddRefs(csp));
rv = GetCreateWindowParams(
aParent, aLoadState, &fullZoom, getter_AddRefs(referrerInfo),
getter_AddRefs(triggeringPrincipal), getter_AddRefs(csp));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
Expand Down
16 changes: 9 additions & 7 deletions dom/ipc/ContentChild.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,15 @@ class ContentChild final : public PContentChild,
nsCString sourceURL;
};

nsresult ProvideWindowCommon(
TabChild* aTabOpener, mozIDOMWindowProxy* aParent, bool aIframeMoz,
uint32_t aChromeFlags, bool aCalledFromJS, bool aPositionSpecified,
bool aSizeSpecified, nsIURI* aURI, const nsAString& aName,
const nsACString& aFeatures, bool aForceNoOpener, bool aForceNoReferrer,
nsDocShellLoadState* aLoadState, bool* aWindowIsNew,
mozIDOMWindowProxy** aReturn);
nsresult ProvideWindowCommon(TabChild* aTabOpener,
mozIDOMWindowProxy* aOpener, bool aIframeMoz,
uint32_t aChromeFlags, bool aCalledFromJS,
bool aPositionSpecified, bool aSizeSpecified,
nsIURI* aURI, const nsAString& aName,
const nsACString& aFeatures, bool aForceNoOpener,
nsDocShellLoadState* aLoadState,
bool* aWindowIsNew,
mozIDOMWindowProxy** aReturn);

bool Init(MessageLoop* aIOLoop, base::ProcessId aParentPid,
const char* aParentBuildID, IPC::Channel* aChannel,
Expand Down
3 changes: 1 addition & 2 deletions dom/ipc/PBrowser.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,7 @@ parent:
* @param opener the PBrowser whose content called window.open.
*/
async BrowserFrameOpenWindow(PBrowser opener,
nsString aURL, nsString aName,
bool aForceNoReferrer, nsString aFeatures)
nsString aURL, nsString aName, nsString aFeatures)
returns (CreatedWindowInfo window);

/**
Expand Down
9 changes: 4 additions & 5 deletions dom/ipc/TabChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,9 +901,8 @@ TabChild::ProvideWindow(mozIDOMWindowProxy* aParent, uint32_t aChromeFlags,
bool aCalledFromJS, bool aPositionSpecified,
bool aSizeSpecified, nsIURI* aURI,
const nsAString& aName, const nsACString& aFeatures,
bool aForceNoOpener, bool aForceNoReferrer,
nsDocShellLoadState* aLoadState, bool* aWindowIsNew,
mozIDOMWindowProxy** aReturn) {
bool aForceNoOpener, nsDocShellLoadState* aLoadState,
bool* aWindowIsNew, mozIDOMWindowProxy** aReturn) {
*aReturn = nullptr;

// If aParent is inside an <iframe mozbrowser> and this isn't a request to
Expand Down Expand Up @@ -936,8 +935,8 @@ TabChild::ProvideWindow(mozIDOMWindowProxy* aParent, uint32_t aChromeFlags,
ContentChild* cc = ContentChild::GetSingleton();
return cc->ProvideWindowCommon(
this, aParent, iframeMoz, aChromeFlags, aCalledFromJS, aPositionSpecified,
aSizeSpecified, aURI, aName, aFeatures, aForceNoOpener, aForceNoReferrer,
aLoadState, aWindowIsNew, aReturn);
aSizeSpecified, aURI, aName, aFeatures, aForceNoOpener, aLoadState,
aWindowIsNew, aReturn);
}

void TabChild::DestroyWindow() {
Expand Down
6 changes: 2 additions & 4 deletions dom/ipc/TabParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2875,16 +2875,14 @@ void TabParent::ApzAwareEventRoutingToChild(ScrollableLayerGuid* aOutTargetGuid,

mozilla::ipc::IPCResult TabParent::RecvBrowserFrameOpenWindow(
PBrowserParent* aOpener, const nsString& aURL, const nsString& aName,
bool aForceNoReferrer, const nsString& aFeatures,
BrowserFrameOpenWindowResolver&& aResolve) {
const nsString& aFeatures, BrowserFrameOpenWindowResolver&& aResolve) {
CreatedWindowInfo cwi;
cwi.rv() = NS_OK;
cwi.maxTouchPoints() = 0;

BrowserElementParent::OpenWindowResult opened =
BrowserElementParent::OpenWindowOOP(TabParent::GetFrom(aOpener), this,
aURL, aName, aForceNoReferrer,
aFeatures);
aURL, aName, aFeatures);
cwi.windowOpened() = (opened == BrowserElementParent::OPEN_WINDOW_ADDED);
nsCOMPtr<nsIWidget> widget = GetWidget();
if (widget) {
Expand Down
3 changes: 1 addition & 2 deletions dom/ipc/TabParent.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ class TabParent final : public PBrowserParent,

mozilla::ipc::IPCResult RecvBrowserFrameOpenWindow(
PBrowserParent* aOpener, const nsString& aURL, const nsString& aName,
bool aForceNoReferrer, const nsString& aFeatures,
BrowserFrameOpenWindowResolver&& aResolve);
const nsString& aFeatures, BrowserFrameOpenWindowResolver&& aResolve);

mozilla::ipc::IPCResult RecvSyncMessage(
const nsString& aMessage, const ClonedMessageData& aData,
Expand Down
8 changes: 2 additions & 6 deletions dom/tests/browser/browser_noopener.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ const TESTS = [

{id: "#test7", name: "", opener: true, newWindow: false},
{id: "#test8", name: "", opener: false, newWindow: false},
{id: "#test9", name: "", opener: false, newWindow: false},
{id: "#test9", name: "", opener: true, newWindow: true},

{id: "#test10", name: "uniquename1", opener: true, newWindow: false},
{id: "#test11", name: "uniquename2", opener: false, newWindow: false},
{id: "#test12", name: "uniquename3", opener: false, newWindow: false},
{id: "#test12", name: "uniquename3", opener: true, newWindow: true},
];

const TEST_URL = "http://mochi.test:8888/browser/dom/tests/browser/test_noopener_source.html";
Expand Down Expand Up @@ -99,10 +99,6 @@ async function doAllTests() {
// constant starting and stopping processes, and opens a new window ~144 times.
requestLongerTimeout(25);

add_task(async function prepare() {
await SpecialPowers.pushPrefEnv({set: [["dom.window.open.noreferrer.enabled", true]]});
});

add_task(async function newtab_sameproc() {
await SpecialPowers.pushPrefEnv({set: [[OPEN_NEWWINDOW_PREF, OPEN_NEWTAB],
[NOOPENER_NEWPROC_PREF, false]]});
Expand Down
1 change: 0 additions & 1 deletion dom/webidl/BrowserElementDictionaries.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ dictionary OpenWindowEventDetail {
DOMString name = "";
DOMString features = "";
Node? frameElement = null;
boolean forceNoReferrer = false;
};

dictionary DOMWindowResizeEventDetail {
Expand Down
3 changes: 1 addition & 2 deletions mobile/android/chrome/content/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3412,11 +3412,10 @@ nsBrowserAccess.prototype = {
Services.io.offline = false;

let referrer;
let forceNoReferrer = !!(aFlags & Ci.nsIBrowserDOMWindow.OPEN_NO_REFERRER);
if (aOpener) {
try {
let location = aOpener.location;
referrer = forceNoReferrer ? null : Services.io.newURI(location);
referrer = Services.io.newURI(location);
} catch(e) { }
}

Expand Down
8 changes: 0 additions & 8 deletions modules/libpref/init/StaticPrefList.h
Original file line number Diff line number Diff line change
Expand Up @@ -590,14 +590,6 @@ VARCACHE_PREF(
bool, true
)

// Enable the "noreferrer" feature argument for window.open()
VARCACHE_PREF(
"dom.window.open.noreferrer.enabled",
dom_window_open_noreferrer_enabled,
bool, true
)


//---------------------------------------------------------------------------
// Extension prefs
//---------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[window-open-noreferrer.html]
[window.open() with "noreferrer" tests]
expected: FAIL

Loading

0 comments on commit 51f9bbd

Please sign in to comment.