diff options
Diffstat (limited to 'application/palemoon/base/content')
-rw-r--r-- | application/palemoon/base/content/browser-fullScreen.js | 207 | ||||
-rw-r--r-- | application/palemoon/base/content/browser.css | 4 | ||||
-rw-r--r-- | application/palemoon/base/content/browser.js | 54 | ||||
-rw-r--r-- | application/palemoon/base/content/browser.xul | 2 | ||||
-rw-r--r-- | application/palemoon/base/content/nsContextMenu.js | 7 | ||||
-rw-r--r-- | application/palemoon/base/content/openLocation.js | 2 | ||||
-rw-r--r-- | application/palemoon/base/content/tabbrowser.xml | 18 | ||||
-rw-r--r-- | application/palemoon/base/content/urlbarBindings.xml | 4 | ||||
-rw-r--r-- | application/palemoon/base/content/utilityOverlay.js | 54 |
9 files changed, 186 insertions, 166 deletions
diff --git a/application/palemoon/base/content/browser-fullScreen.js b/application/palemoon/base/content/browser-fullScreen.js index 73b10ae85..ffe1da450 100644 --- a/application/palemoon/base/content/browser-fullScreen.js +++ b/application/palemoon/base/content/browser-fullScreen.js @@ -5,16 +5,9 @@ var FullScreen = { _XULNS: "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", - get _fullScrToggler() { - delete this._fullScrToggler; - return this._fullScrToggler = document.getElementById("fullscr-toggler"); - }, - toggle: function (event) { - var enterFS = window.fullScreen; - // We get the fullscreen event _before_ the window transitions into or out of FS mode. - if (event && event.type == "fullscreen") - enterFS = !enterFS; + toggle: function () { + var enterFS = window.fullScreen; // Toggle the View:FullScreen command, which controls elements like the // fullscreen menuitem, menubars, and the appmenu. @@ -31,6 +24,12 @@ var FullScreen = { document.getElementById("exitFullScreenItem").hidden = !enterFS; #endif + if (!this._fullScrToggler) { + this._fullScrToggler = document.getElementById("fullscr-toggler"); + this._fullScrToggler.addEventListener("mouseover", this._expandCallback, false); + this._fullScrToggler.addEventListener("dragenter", this._expandCallback, false); + } + // On OS X Lion we don't want to hide toolbars when entering fullscreen, unless // we're entering DOM fullscreen, in which case we should hide the toolbars. // If we're leaving fullscreen, then we'll go through the exit code below to @@ -50,36 +49,17 @@ var FullScreen = { this.showXULChrome("toolbar", !enterFS); if (enterFS) { - // Add a tiny toolbar to receive mouseover and dragenter events, and provide affordance. - // This will help simulate the "collapse" metaphor while also requiring less code and - // events than raw listening of mouse coords. We don't add the toolbar in DOM full-screen - // mode, only browser full-screen mode. - if (!document.mozFullScreen) { - this._fullScrToggler.addEventListener("mouseover", this._expandCallback, false); - this._fullScrToggler.addEventListener("dragenter", this._expandCallback, false); - } - if (gPrefService.getBoolPref("browser.fullscreen.autohide")) - gBrowser.mPanelContainer.addEventListener("mousemove", - this._collapseCallback, false); - document.addEventListener("keypress", this._keyToggleCallback, false); document.addEventListener("popupshown", this._setPopupOpen, false); document.addEventListener("popuphidden", this._setPopupOpen, false); + this._shouldAnimate = true; // We don't animate the toolbar collapse if in DOM full-screen mode, // as the size of the content area would still be changing after the // mozfullscreenchange event fired, which could confuse content script. - this._shouldAnimate = !document.mozFullScreen; - this.mouseoverToggle(false); - - // Autohide prefs - gPrefService.addObserver("browser.fullscreen", this, false); + this.hideNavToolbox(document.mozFullScreen); } else { - // The user may quit fullscreen during an animation - this._cancelAnimation(); - gNavToolbox.style.marginTop = ""; - if (this._isChromeCollapsed) - this.mouseoverToggle(true); + this.showNavToolbox(false); // This is needed if they use the context menu to quit fullscreen this._isPopupOpen = false; @@ -152,26 +132,16 @@ var FullScreen = { // Cancel any "hide the toolbar" animation which is in progress, and make // the toolbar hide immediately. - this._cancelAnimation(); - this.mouseoverToggle(false); - - // Remove listeners on the full-screen toggler, so that mouseover - // the top of the screen will not cause the toolbar to re-appear. - this._fullScrToggler.removeEventListener("mouseover", this._expandCallback, false); - this._fullScrToggler.removeEventListener("dragenter", this._expandCallback, false); + this.hideNavToolbox(true); }, cleanup: function () { - if (window.fullScreen) { - gBrowser.mPanelContainer.removeEventListener("mousemove", - this._collapseCallback, false); + if (!window.fullScreen) { + MousePosTracker.removeListener(this); document.removeEventListener("keypress", this._keyToggleCallback, false); document.removeEventListener("popupshown", this._setPopupOpen, false); document.removeEventListener("popuphidden", this._setPopupOpen, false); - gPrefService.removeObserver("browser.fullscreen", this); - this._fullScrToggler.removeEventListener("mouseover", this._expandCallback, false); - this._fullScrToggler.removeEventListener("dragenter", this._expandCallback, false); this.cancelWarning(); gBrowser.tabContainer.removeEventListener("TabOpen", this.exitDomFullScreen); gBrowser.tabContainer.removeEventListener("TabClose", this.exitDomFullScreen); @@ -182,40 +152,30 @@ var FullScreen = { } }, - observe: function(aSubject, aTopic, aData) + getMouseTargetRect: function() { - if (aData == "browser.fullscreen.autohide") { - if (gPrefService.getBoolPref("browser.fullscreen.autohide")) { - gBrowser.mPanelContainer.addEventListener("mousemove", - this._collapseCallback, false); - } - else { - gBrowser.mPanelContainer.removeEventListener("mousemove", - this._collapseCallback, false); - } - } + return this._mouseTargetRect; }, // Event callbacks _expandCallback: function() { - FullScreen.mouseoverToggle(true); + FullScreen.showNavToolbox(); }, - _collapseCallback: function() + onMouseEnter: function() { - FullScreen.mouseoverToggle(false); + FullScreen.hideNavToolbox(); }, _keyToggleCallback: function(aEvent) { // if we can use the keyboard (eg Ctrl+L or Ctrl+E) to open the toolbars, we // should provide a way to collapse them too. if (aEvent.keyCode == aEvent.DOM_VK_ESCAPE) { - FullScreen._shouldAnimate = false; - FullScreen.mouseoverToggle(false, true); + FullScreen.hideNavToolbox(true); } // F6 is another shortcut to the address bar, but its not covered in OpenLocation() else if (aEvent.keyCode == aEvent.DOM_VK_F6) - FullScreen.mouseoverToggle(true); + FullScreen.showNavToolbox(); }, // Checks whether we are allowed to collapse the chrome @@ -269,47 +229,6 @@ var FullScreen = { // Animate the toolbars disappearing _shouldAnimate: true, - _isAnimating: false, - _animationTimeout: 0, - _animationHandle: 0, - _animateUp: function() { - // check again, the user may have done something before the animation was due to start - if (!window.fullScreen || !this._safeToCollapse(false)) { - this._isAnimating = false; - this._shouldAnimate = true; - return; - } - - this._animateStartTime = window.mozAnimationStartTime; - if (!this._animationHandle) - this._animationHandle = window.mozRequestAnimationFrame(this); - }, - - sample: function (timeStamp) { - const duration = 1500; - const timePassed = timeStamp - this._animateStartTime; - const pos = timePassed >= duration ? 1 : - 1 - Math.pow(1 - timePassed / duration, 4); - - if (pos >= 1) { - // We've animated enough - this._cancelAnimation(); - gNavToolbox.style.marginTop = ""; - this.mouseoverToggle(false); - return; - } - - gNavToolbox.style.marginTop = (gNavToolbox.boxObject.height * pos * -1) + "px"; - this._animationHandle = window.mozRequestAnimationFrame(this); - }, - - _cancelAnimation: function() { - window.cancelAnimationFrame(this._animationHandle); - this._animationHandle = 0; - clearTimeout(this._animationTimeout); - this._isAnimating = false; - this._shouldAnimate = false; - }, cancelWarning: function(event) { if (!this.warningBox) @@ -463,49 +382,69 @@ var FullScreen = { 3000); }, - mouseoverToggle: function(aShow, forceHide) - { - // Don't do anything if: - // a) we're already in the state we want, - // b) we're animating and will become collapsed soon, or - // c) we can't collapse because it would be undesirable right now - if (aShow != this._isChromeCollapsed || (!aShow && this._isAnimating) || - (!aShow && !this._safeToCollapse(forceHide))) + showNavToolbox: function(trackMouse = true) { + this._fullScrToggler.hidden = true; + gNavToolbox.removeAttribute("fullscreenShouldAnimate"); + gNavToolbox.style.marginTop = ""; + + if (!this._isChromeCollapsed) { + return; + } + + // Track whether mouse is near the toolbox + this._isChromeCollapsed = false; + if (trackMouse) { + let rect = gBrowser.mPanelContainer.getBoundingClientRect(); + this._mouseTargetRect = { + top: rect.top + 50, + bottom: rect.bottom, + left: rect.left, + right: rect.right + }; + MousePosTracker.addListener(this); + } + }, + + hideNavToolbox: function(forceHide = false) { + this._fullScrToggler.hidden = document.mozFullScreen; + if (this._isChromeCollapsed) { + if (forceHide) { + gNavToolbox.removeAttribute("fullscreenShouldAnimate"); + } + return; + } + if (!this._safeToCollapse(forceHide)) { + this._fullScrToggler.hidden = true; return; + } // browser.fullscreen.animateUp // 0 - never animate up // 1 - animate only for first collapse after entering fullscreen (default for perf's sake) // 2 - animate every time it collapses - if (gPrefService.getIntPref("browser.fullscreen.animateUp") == 0) - this._shouldAnimate = false; - - if (!aShow && this._shouldAnimate) { - this._isAnimating = true; + let animateUp = gPrefService.getIntPref("browser.fullscreen.animateUp"); + if (animateUp == 0) { this._shouldAnimate = false; - this._animationTimeout = setTimeout(this._animateUp.bind(this), 800); - return; - } - - // The chrome is collapsed so don't spam needless mousemove events - if (aShow) { - gBrowser.mPanelContainer.addEventListener("mousemove", - this._collapseCallback, false); + } else if (animateUp == 2) { + this._shouldAnimate = true; } - else { - gBrowser.mPanelContainer.removeEventListener("mousemove", - this._collapseCallback, false); + if (this._shouldAnimate && !forceHide) { + gNavToolbox.setAttribute("fullscreenShouldAnimate", true); + this._shouldAnimate = false; + // Hide the fullscreen toggler until the transition ends. + let listener = () => { + gNavToolbox.removeEventListener("transitionend", listener, true); + if (this._isChromeCollapsed) + this._fullScrToggler.hidden = false; + }; + gNavToolbox.addEventListener("transitionend", listener, true); + this._fullScrToggler.hidden = true; } - // Hiding/collapsing the toolbox interferes with the tab bar's scrollbox, - // so we just move it off-screen instead. See bug 430687. gNavToolbox.style.marginTop = - aShow ? "" : -gNavToolbox.getBoundingClientRect().height + "px"; - - this._fullScrToggler.collapsed = aShow; - this._isChromeCollapsed = !aShow; - if (gPrefService.getIntPref("browser.fullscreen.animateUp") == 2) - this._shouldAnimate = true; + -gNavToolbox.getBoundingClientRect().height + "px"; + this._isChromeCollapsed = true; + MousePosTracker.removeListener(this); }, showXULChrome: function(aTag, aShow) diff --git a/application/palemoon/base/content/browser.css b/application/palemoon/base/content/browser.css index 658655970..05dd00997 100644 --- a/application/palemoon/base/content/browser.css +++ b/application/palemoon/base/content/browser.css @@ -760,3 +760,7 @@ toolbarbutton[pmkit-button="true"] > .toolbarbutton-badge-stack > .toolbarbutton #main-window[inFullscreen] #high-priority-global-notificationbox { visibility: collapse; } + +#navigator-toolbox[fullscreenShouldAnimate] { + transition: 1.5s margin-top ease-out; +} diff --git a/application/palemoon/base/content/browser.js b/application/palemoon/base/content/browser.js index 6dbd9677e..72d51ce4a 100644 --- a/application/palemoon/base/content/browser.js +++ b/application/palemoon/base/content/browser.js @@ -122,7 +122,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils", XPCOMUtils.defineLazyModuleGetter(this, "FormValidationHandler", "resource:///modules/FormValidationHandler.jsm"); -let gInitialPages = [ +var gInitialPages = [ "about:blank", "about:newtab", "about:home", @@ -990,12 +990,23 @@ var gBrowserInit = { gBrowser.swapBrowsersAndCloseOther(gBrowser.selectedTab, uriToLoad); } - // window.arguments[2]: referrer (nsIURI) + // window.arguments[2]: referrer (nsIURI | string) // [3]: postData (nsIInputStream) // [4]: allowThirdPartyFixup (bool) + // [5]: referrerPolicy (int) else if (window.arguments.length >= 3) { - loadURI(uriToLoad, window.arguments[2], window.arguments[3] || null, - window.arguments[4] || false); + let referrerURI = window.arguments[2]; + if (typeof(referrerURI) == "string") { + try { + referrerURI = makeURI(referrerURI); + } catch (e) { + referrerURI = null; + } + } + let referrerPolicy = (window.arguments[5] != undefined ? + window.arguments[5] : Ci.nsIHttpChannel.REFERRER_POLICY_DEFAULT); + loadURI(uriToLoad, referrerURI, window.arguments[3] || null, + window.arguments[4] || false, referrerPolicy); window.focus(); } // Note: loadOneOrMoreURIs *must not* be called if window.arguments.length >= 3. @@ -1730,7 +1741,7 @@ function loadOneOrMoreURIs(aURIString) function focusAndSelectUrlBar() { if (gURLBar) { if (window.fullScreen) - FullScreen.mouseoverToggle(true); + FullScreen.showNavToolbox(); gURLBar.select(); if (document.activeElement == gURLBar.inputField) @@ -1883,7 +1894,7 @@ function BrowserTryToCloseWindow() window.close(); // WindowIsClosing does all the necessary checks } -function loadURI(uri, referrer, postData, allowThirdPartyFixup) { +function loadURI(uri, referrer, postData, allowThirdPartyFixup, referrerPolicy) { if (postData === undefined) postData = null; @@ -1894,7 +1905,12 @@ function loadURI(uri, referrer, postData, allowThirdPartyFixup) { } try { - gBrowser.loadURIWithFlags(uri, flags, referrer, null, postData); + gBrowser.loadURIWithFlags(uri, { + flags: flags, + referrerURI: referrer, + referrerPolicy: referrerPolicy, + postData: postData, + }); } catch (e) {} } @@ -2517,8 +2533,8 @@ function BrowserFullScreen() window.fullScreen = !window.fullScreen; } -function onFullScreen(event) { - FullScreen.toggle(event); +function onFullScreen() { + FullScreen.toggle(); } function onMozEnteredDomFullscreen(event) { @@ -2999,7 +3015,7 @@ const BrowserSearch = { #endif var searchBar = this.searchBar; if (searchBar && window.fullScreen) - FullScreen.mouseoverToggle(true); + FullScreen.showNavToolbox(); if (searchBar) searchBar.select(); if (!searchBar || document.activeElement != searchBar.textbox.inputField) @@ -4288,6 +4304,13 @@ nsBrowserAccess.prototype = { else aWhere = gPrefService.getIntPref("browser.link.open_newwindow"); } + + let referrer = aOpener ? makeURI(aOpener.location.href) : null; + let referrerPolicy = Ci.nsIHttpChannel.REFERRER_POLICY_DEFAULT; + if (aOpener && aOpener.document) { + referrerPolicy = aOpener.document.referrerPolicy; + } + switch (aWhere) { case Ci.nsIBrowserDOMWindow.OPEN_NEWWINDOW : // FIXME: Bug 408379. So how come this doesn't send the @@ -4326,6 +4349,7 @@ nsBrowserAccess.prototype = { let tab = win.gBrowser.loadOneTab(aURI ? aURI.spec : "about:blank", { referrerURI: referrer, + referrerPolicy: referrerPolicy, fromExternal: isExternal, inBackground: loadInBackground}); let browser = win.gBrowser.getBrowserForTab(tab); @@ -4341,11 +4365,14 @@ nsBrowserAccess.prototype = { default : // OPEN_CURRENTWINDOW or an illegal value newWindow = content; if (aURI) { - let referrer = aOpener ? makeURI(aOpener.location.href) : null; let loadflags = isExternal ? Ci.nsIWebNavigation.LOAD_FLAGS_FROM_EXTERNAL : Ci.nsIWebNavigation.LOAD_FLAGS_NONE; - gBrowser.loadURIWithFlags(aURI.spec, loadflags, referrer, null, null); + gBrowser.loadURIWithFlags(aURI.spec, { + flags: loadflags, + referrerURI: referrer, + referrerPolicy: referrerPolicy, + }); } if (!gPrefService.getBoolPref("browser.tabs.loadDivertedInBackground")) window.focus(); @@ -5075,7 +5102,8 @@ function handleLinkClick(event, href, linkNode) { urlSecurityCheck(href, doc.nodePrincipal); openLinkIn(href, where, { referrerURI: doc.documentURIObject, - charset: doc.characterSet }); + charset: doc.characterSet, + referrerPolicy: doc.referrerPolicy }); event.preventDefault(); return true; } diff --git a/application/palemoon/base/content/browser.xul b/application/palemoon/base/content/browser.xul index c2553f295..9b37f7b6f 100644 --- a/application/palemoon/base/content/browser.xul +++ b/application/palemoon/base/content/browser.xul @@ -941,7 +941,7 @@ </toolbarpalette> </toolbox> - <hbox id="fullscr-toggler" collapsed="true"/> + <hbox id="fullscr-toggler" hidden="true"/> <hbox flex="1" id="browser"> <vbox id="browser-border-start" hidden="true" layer="true"/> diff --git a/application/palemoon/base/content/nsContextMenu.js b/application/palemoon/base/content/nsContextMenu.js index 830c20998..f389491d3 100644 --- a/application/palemoon/base/content/nsContextMenu.js +++ b/application/palemoon/base/content/nsContextMenu.js @@ -753,7 +753,8 @@ nsContextMenu.prototype = { urlSecurityCheck(this.linkURL, doc.nodePrincipal); openLinkIn(this.linkURL, "window", { charset: doc.characterSet, - referrerURI: doc.documentURIObject }); + referrerURI: doc.documentURIObject, + referrerPolicy: doc.referrerPolicy }); }, // Open linked-to URL in a new private window. @@ -763,6 +764,7 @@ nsContextMenu.prototype = { openLinkIn(this.linkURL, "window", { charset: doc.characterSet, referrerURI: doc.documentURIObject, + referrerPolicy: doc.referrerPolicy, private: true }); }, @@ -772,7 +774,8 @@ nsContextMenu.prototype = { urlSecurityCheck(this.linkURL, doc.nodePrincipal); openLinkIn(this.linkURL, "tab", { charset: doc.characterSet, - referrerURI: doc.documentURIObject }); + referrerURI: doc.documentURIObject, + referrerPolicy: doc.referrerPolicy }); }, // open URL in current tab diff --git a/application/palemoon/base/content/openLocation.js b/application/palemoon/base/content/openLocation.js index 1a10334c7..f39e34666 100644 --- a/application/palemoon/base/content/openLocation.js +++ b/application/palemoon/base/content/openLocation.js @@ -83,7 +83,7 @@ function open() var flags = webNav.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP | webNav.LOAD_FLAGS_FIXUP_SCHEME_TYPOS; if (!mayInheritPrincipal) - flags |= webNav.LOAD_FLAGS_DISALLOW_INHERIT_OWNER; + flags |= webNav.LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL; browser.gBrowser.loadURIWithFlags(url, flags, null, null, postData); break; case "1": diff --git a/application/palemoon/base/content/tabbrowser.xml b/application/palemoon/base/content/tabbrowser.xml index c06b49af0..1b8099785 100644 --- a/application/palemoon/base/content/tabbrowser.xml +++ b/application/palemoon/base/content/tabbrowser.xml @@ -1264,6 +1264,7 @@ <parameter name="aAllowThirdPartyFixup"/> <body> <![CDATA[ + var aReferrerPolicy; var aFromExternal; var aRelatedToCurrent; if (arguments.length == 2 && @@ -1271,6 +1272,7 @@ !(arguments[1] instanceof Ci.nsIURI)) { let params = arguments[1]; aReferrerURI = params.referrerURI; + aReferrerPolicy = params.referrerPolicy; aCharset = params.charset; aPostData = params.postData; aLoadInBackground = params.inBackground; @@ -1284,6 +1286,7 @@ var owner = bgLoad ? null : this.selectedTab; var tab = this.addTab(aURI, { referrerURI: aReferrerURI, + referrerPolicy: aReferrerPolicy, charset: aCharset, postData: aPostData, ownerTab: owner, @@ -1409,6 +1412,7 @@ <body> <![CDATA[ const NS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; + var aReferrerPolicy; var aFromExternal; var aRelatedToCurrent; var aSkipAnimation; @@ -1417,6 +1421,7 @@ !(arguments[1] instanceof Ci.nsIURI)) { let params = arguments[1]; aReferrerURI = params.referrerURI; + aReferrerPolicy = params.referrerPolicy; aCharset = params.charset; aPostData = params.postData; aOwner = params.ownerTab; @@ -1588,7 +1593,13 @@ if (aFromExternal) flags |= Ci.nsIWebNavigation.LOAD_FLAGS_FROM_EXTERNAL; try { - b.loadURIWithFlags(aURI, flags, aReferrerURI, aCharset, aPostData); + b.loadURIWithFlags(aURI, { + flags: flags, + referrerURI: aReferrerURI, + referrerPolicy: aReferrerPolicy, + charset: aCharset, + postData: aPostData, + }); } catch (ex) { Cu.reportError(ex); } @@ -2700,6 +2711,11 @@ <parameter name="aPostData"/> <body> <![CDATA[ + // Note - the callee understands both: + // (a) loadURIWithFlags(aURI, aFlags, ...) + // (b) loadURIWithFlags(aURI, { flags: aFlags, ... }) + // Forwarding it as (a) here actually supports both (a) and (b), + // so you can call us either way too. return this.mCurrentBrowser.loadURIWithFlags(aURI, aFlags, aReferrerURI, aCharset, aPostData); ]]> </body> diff --git a/application/palemoon/base/content/urlbarBindings.xml b/application/palemoon/base/content/urlbarBindings.xml index 985769ec2..d188e6658 100644 --- a/application/palemoon/base/content/urlbarBindings.xml +++ b/application/palemoon/base/content/urlbarBindings.xml @@ -305,12 +305,12 @@ function loadCurrent() { let flags = Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP; - // Pass LOAD_FLAGS_DISALLOW_INHERIT_OWNER to prevent any loads from + // Pass LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL to prevent any loads from // inheriting the currently loaded document's principal, unless this // URL is marked as safe to inherit (e.g. came from a bookmark // keyword). if (!mayInheritPrincipal) - flags |= Ci.nsIWebNavigation.LOAD_FLAGS_DISALLOW_INHERIT_OWNER; + flags |= Ci.nsIWebNavigation.LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL; // If the value wasn't typed, we know that we decoded the value as // UTF-8 (see losslessDecodeURI) if (!this.valueIsTyped) diff --git a/application/palemoon/base/content/utilityOverlay.js b/application/palemoon/base/content/utilityOverlay.js index 86cc5cea5..633cb8853 100644 --- a/application/palemoon/base/content/utilityOverlay.js +++ b/application/palemoon/base/content/utilityOverlay.js @@ -104,7 +104,8 @@ function openUILink(url, event, aIgnoreButton, aIgnoreAlt, aAllowThirdPartyFixup allowThirdPartyFixup: aAllowThirdPartyFixup, postData: aPostData, referrerURI: aReferrerURI, - initiatingDoc: event ? event.target.ownerDocument : null + referrerPolicy: Components.interfaces.nsIHttpChannel.REFERRER_POLICY_DEFAULT, + initiatingDoc: event ? event.target.ownerDocument : null, }; } @@ -196,7 +197,8 @@ function openUILinkIn(url, where, aAllowThirdPartyFixup, aPostData, aReferrerURI params = { allowThirdPartyFixup: aAllowThirdPartyFixup, postData: aPostData, - referrerURI: aReferrerURI + referrerURI: aReferrerURI, + referrerPolicy: Components.interfaces.nsIHttpChannel.REFERRER_POLICY_DEFAULT, }; } @@ -209,12 +211,16 @@ function openUILinkIn(url, where, aAllowThirdPartyFixup, aPostData, aReferrerURI function openLinkIn(url, where, params) { if (!where || !url) return; + const Cc = Components.classes; + const Ci = Components.interfaces; var aFromChrome = params.fromChrome; var aAllowThirdPartyFixup = params.allowThirdPartyFixup; var aPostData = params.postData; var aCharset = params.charset; var aReferrerURI = params.referrerURI; + var aReferrerPolicy = ('referrerPolicy' in params ? + params.referrerPolicy : Ci.nsIHttpChannel.REFERRER_POLICY_DEFAULT); var aRelatedToCurrent = params.relatedToCurrent; var aForceAllowDataURI = params.forceAllowDataURI; var aInBackground = params.inBackground; @@ -229,11 +235,10 @@ function openLinkIn(url, where, params) { "where == 'save' but without initiatingDoc. See bug 814264."); return; } + // TODO(1073187): propagate referrerPolicy. saveURL(url, null, null, true, null, aReferrerURI, aInitiatingDoc); return; } - const Cc = Components.classes; - const Ci = Components.interfaces; var w = getTopWin(); if ((where == "tab" || where == "tabshifted") && @@ -243,6 +248,7 @@ function openLinkIn(url, where, params) { } if (!w || where == "window") { + // This propagates to window.arguments. // Strip referrer data when opening a new private window, to prevent // regular browsing data from leaking into it. if (aIsPrivate) { @@ -267,12 +273,23 @@ function openLinkIn(url, where, params) { createInstance(Ci.nsISupportsPRBool); allowThirdPartyFixupSupports.data = aAllowThirdPartyFixup; + var referrerURISupports = null; + if (aReferrerURI && sendReferrerURI) { + referrerURISupports = Cc["@mozilla.org/supports-string;1"]. + createInstance(Ci.nsISupportsString); + referrerURISupports.data = aReferrerURI.spec; + } + + var referrerPolicySupports = Cc["@mozilla.org/supports-PRUint32;1"]. + createInstance(Ci.nsISupportsPRUint32); + referrerPolicySupports.data = aReferrerPolicy; + sa.AppendElement(wuri); sa.AppendElement(charset); - if (sendReferrerURI) - sa.AppendElement(aReferrerURI); + sa.AppendElement(referrerURISupports); sa.AppendElement(aPostData); sa.AppendElement(allowThirdPartyFixupSupports); + sa.AppendElement(referrerPolicySupports); let features = "chrome,dialog=no,all"; if (aIsPrivate) { @@ -316,11 +333,16 @@ function openLinkIn(url, where, params) { flags |= Ci.nsIWebNavigation.LOAD_FLAGS_FIXUP_SCHEME_TYPOS; } if (aDisallowInheritPrincipal) - flags |= Ci.nsIWebNavigation.LOAD_FLAGS_DISALLOW_INHERIT_OWNER; + flags |= Ci.nsIWebNavigation.LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL; if (aForceAllowDataURI) { flags |= Ci.nsIWebNavigation.LOAD_FLAGS_FORCE_ALLOW_DATA_URI; } - w.gBrowser.loadURIWithFlags(url, flags, aReferrerURI, null, aPostData); + w.gBrowser.loadURIWithFlags(url, { + flags: flags, + referrerURI: aReferrerURI, + referrerPolicy: aReferrerPolicy, + postData: aPostData, + }); break; case "tabshifted": loadInBackground = !loadInBackground; @@ -329,6 +351,7 @@ function openLinkIn(url, where, params) { let browser = w.gBrowser; browser.loadOneTab(url, { referrerURI: aReferrerURI, + referrerPolicy: aReferrerPolicy, charset: aCharset, postData: aPostData, inBackground: loadInBackground, @@ -577,9 +600,11 @@ function makeURLAbsolute(aBase, aUrl) * @param [optional] aReferrer * If aDocument is null, then this will be used as the referrer. * There will be no security check. + * @param [optional] aReferrerPolicy + * Referrer policy - Ci.nsIHttpChannel.REFERRER_POLICY_*. */ function openNewTabWith(aURL, aDocument, aPostData, aEvent, - aAllowThirdPartyFixup, aReferrer) { + aAllowThirdPartyFixup, aReferrer, aReferrerPolicy) { if (aDocument) urlSecurityCheck(aURL, aDocument.nodePrincipal); @@ -594,10 +619,13 @@ function openNewTabWith(aURL, aDocument, aPostData, aEvent, { charset: originCharset, postData: aPostData, allowThirdPartyFixup: aAllowThirdPartyFixup, - referrerURI: aDocument ? aDocument.documentURIObject : aReferrer }); + referrerURI: aDocument ? aDocument.documentURIObject : aReferrer, + referrerPolicy: aReferrerPolicy, + }); } -function openNewWindowWith(aURL, aDocument, aPostData, aAllowThirdPartyFixup, aReferrer) { +function openNewWindowWith(aURL, aDocument, aPostData, aAllowThirdPartyFixup, + aReferrer, aReferrerPolicy) { if (aDocument) urlSecurityCheck(aURL, aDocument.nodePrincipal); @@ -614,7 +642,9 @@ function openNewWindowWith(aURL, aDocument, aPostData, aAllowThirdPartyFixup, aR { charset: originCharset, postData: aPostData, allowThirdPartyFixup: aAllowThirdPartyFixup, - referrerURI: aDocument ? aDocument.documentURIObject : aReferrer }); + referrerURI: aDocument ? aDocument.documentURIObject : aReferrer, + referrerPolicy: aReferrerPolicy, + }); } /** |