diff --git a/browser/base/content/test/referrer/browser.ini b/browser/base/content/test/referrer/browser.ini index 13b712850fcd..23636a8c72cc 100644 --- a/browser/base/content/test/referrer/browser.ini +++ b/browser/base/content/test/referrer/browser.ini @@ -16,6 +16,7 @@ skip-if = os == 'linux' # Bug 1145199 [browser_referrer_open_link_in_window_in_container.js] skip-if = os == 'linux' # Bug 1145199 [browser_referrer_simple_click.js] +[browser_referrer_click_pinned_tab.js] [browser_referrer_open_link_in_container_tab.js] skip-if = os == 'linux' # Bug 1144816 [browser_referrer_open_link_in_container_tab2.js] diff --git a/browser/base/content/test/referrer/browser_referrer_click_pinned_tab.js b/browser/base/content/test/referrer/browser_referrer_click_pinned_tab.js new file mode 100644 index 000000000000..a4e7e2606055 --- /dev/null +++ b/browser/base/content/test/referrer/browser_referrer_click_pinned_tab.js @@ -0,0 +1,69 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// We will open a new tab if clicking on a cross domain link in pinned tab +// So, override the tests data in head.js, adding "cross: true". + +_referrerTests = [ + { + fromScheme: "http://", + toScheme: "http://", + cross: true, + result: "http://test1.example.com/browser" // full referrer + }, + { + fromScheme: "https://", + toScheme: "http://", + cross: true, + result: "" // no referrer when downgrade + }, + { + fromScheme: "https://", + toScheme: "http://", + policy: "origin", + cross: true, + result: "https://test1.example.com/" // origin, even on downgrade + }, + { + fromScheme: "https://", + toScheme: "http://", + policy: "origin", + rel: "noreferrer", + cross: true, + result: "" // rel=noreferrer trumps meta-referrer + }, + { + fromScheme: "https://", + toScheme: "https://", + policy: "no-referrer", + cross: true, + result: "" // same origin https://test1.example.com/browser + }, + { + fromScheme: "http://", + toScheme: "https://", + policy: "no-referrer", + cross: true, + result: "" // cross origin http://test1.example.com + }, +]; + +async function startClickPinnedTabTestCase(aTestNumber) { + info("browser_referrer_click_pinned_tab: " + + getReferrerTestDescription(aTestNumber)); + let browser = gTestWindow.gBrowser; + + browser.pinTab(browser.selectedTab); + someTabLoaded(gTestWindow).then(function(aNewTab) { + checkReferrerAndStartNextTest(aTestNumber, null, aNewTab, + startClickPinnedTabTestCase); + }); + + clickTheLink(gTestWindow, "testlink", {}); +} + +function test() { + requestLongerTimeout(10); // slowwww shutdown on e10s + startReferrerTest(startClickPinnedTabTestCase); +} diff --git a/browser/base/content/test/referrer/file_referrer_policyserver.sjs b/browser/base/content/test/referrer/file_referrer_policyserver.sjs index e079656759b5..963e0bb77a50 100644 --- a/browser/base/content/test/referrer/file_referrer_policyserver.sjs +++ b/browser/base/content/test/referrer/file_referrer_policyserver.sjs @@ -11,9 +11,11 @@ function handleRequest(request, response) let scheme = query.get("scheme"); let policy = query.get("policy"); let rel = query.get("rel"); + let cross = query.get("cross"); - let linkUrl = scheme + - "test1.example.com/browser/browser/base/content/test/referrer/" + + let host = cross ? "example.com" : "test1.example.com"; + let linkUrl = scheme + host + + "/browser/browser/base/content/test/referrer/" + "file_referrer_testserver.sjs"; let metaReferrerTag = policy ? `` : ""; diff --git a/browser/base/content/test/referrer/file_referrer_policyserver_attr.sjs b/browser/base/content/test/referrer/file_referrer_policyserver_attr.sjs index 25a58188a016..e5591f8fb3c2 100644 --- a/browser/base/content/test/referrer/file_referrer_policyserver_attr.sjs +++ b/browser/base/content/test/referrer/file_referrer_policyserver_attr.sjs @@ -11,10 +11,13 @@ function handleRequest(request, response) let scheme = query.get("scheme"); let policy = query.get("policy"); let rel = query.get("rel"); + let cross = query.get("cross"); - let linkUrl = scheme + - "test1.example.com/browser/browser/base/content/test/referrer/" + + let host = cross ? "example.com" : "test1.example.com"; + let linkUrl = scheme + host + + "/browser/browser/base/content/test/referrer/" + "file_referrer_testserver.sjs"; + let referrerPolicy = policy ? `referrerpolicy="${policy}"` : ""; diff --git a/browser/base/content/test/referrer/head.js b/browser/base/content/test/referrer/head.js index ab3afdb9ddee..fc1586eab54c 100644 --- a/browser/base/content/test/referrer/head.js +++ b/browser/base/content/test/referrer/head.js @@ -206,7 +206,8 @@ function referrerTestCaseLoaded(aTestNumber, aParams) { let url = test.fromScheme + server + "?scheme=" + escape(test.toScheme) + "&policy=" + escape(test.policy || "") + - "&rel=" + escape(test.rel || ""); + "&rel=" + escape(test.rel || "") + + "&cross=" + escape(test.cross || ""); let browser = gTestWindow.gBrowser; return BrowserTestUtils.openNewForegroundTab(browser, () => { browser.selectedTab = browser.addTab(url, aParams);