Bug 1271075 - Sites on the new tab page opened with middle click in e10s should have a 'referrerURI'. r=ursulasarracini, a=lizzard FIREFOX_48_0b6_BUILD1 FIREFOX_48_0b6_RELEASE
authorMarina Samuel <msamuel@mozilla.com>
Tue, 05 Jul 2016 11:36:18 -0400
changeset 335560 d142c49033c015f67272562b37dbe2912cfc7f14
parent 335559 466fc08f77161a1ea93b59cddbc5a79146df42a1
child 335561 14cd5a377ae1680dff145c4fbda93cf5bdaaab34
push id1146
push userCallek@gmail.com
push dateMon, 25 Jul 2016 16:35:44 +0000
treeherdermozilla-release@a55778f9cd5a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersursulasarracini, lizzard
bugs1271075
milestone48.0
Bug 1271075 - Sites on the new tab page opened with middle click in e10s should have a 'referrerURI'. r=ursulasarracini, a=lizzard
browser/base/content/browser.js
browser/base/content/test/newtab/browser.ini
browser/base/content/test/newtab/browser_newtab_bug1271075.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -2907,17 +2907,17 @@ var BrowserOnClick = {
     }
 
     let anchorTarget = event.originalTarget.parentNode;
 
     if (anchorTarget instanceof HTMLAnchorElement &&
         anchorTarget.classList.contains("newtab-link")) {
       event.preventDefault();
       let where = whereToOpenLink(event, false, false);
-      openLinkIn(anchorTarget.href, where, { charset: ownerDoc.characterSet });
+      openLinkIn(anchorTarget.href, where, { charset: ownerDoc.characterSet, referrerURI: ownerDoc.documentURIObject });
     }
   },
 
   ignoreWarningButton: function (reason) {
     // Allow users to override and continue through to the site,
     // but add a notify bar as a reminder, so that they don't lose
     // track after, e.g., tab switching.
     gBrowser.loadURIWithFlags(gBrowser.currentURI.spec,
--- a/browser/base/content/test/newtab/browser.ini
+++ b/browser/base/content/test/newtab/browser.ini
@@ -17,16 +17,17 @@ support-files =
 [browser_newtab_bug765628.js]
 [browser_newtab_bug876313.js]
 [browser_newtab_bug991111.js]
 [browser_newtab_bug991210.js]
 [browser_newtab_bug998387.js]
 [browser_newtab_bug1145428.js]
 [browser_newtab_bug1178586.js]
 [browser_newtab_bug1194895.js]
+[browser_newtab_bug1271075.js]
 [browser_newtab_disable.js]
 [browser_newtab_drag_drop.js]
 [browser_newtab_drag_drop_ext.js]
 [browser_newtab_drop_preview.js]
 [browser_newtab_enhanced.js]
 [browser_newtab_focus.js]
 [browser_newtab_perwindow_private_browsing.js]
 [browser_newtab_reportLinkAction.js]
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/newtab/browser_newtab_bug1271075.js
@@ -0,0 +1,32 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+add_task(function* () {
+  is(gBrowser.tabs.length, 1, "one tab is open initially");
+
+  // Add a few tabs.
+  let tabs = [];
+  function addTab(aURL, aReferrer) {
+    let tab = gBrowser.addTab(aURL, {referrerURI: aReferrer});
+    tabs.push(tab);
+    return BrowserTestUtils.browserLoaded(tab.linkedBrowser);
+  }
+
+  yield addTab("http://mochi.test:8888/#0");
+  yield addTab("http://mochi.test:8888/#1");
+  yield addTab("http://mochi.test:8888/#2");
+  yield addTab("http://mochi.test:8888/#3");
+
+  // Create a new tab page with a "www.example.com" tile and move it to the 2nd tab position.
+  yield setLinks("-1");
+  yield* addNewTabPageTab();
+  gBrowser.moveTabTo(gBrowser.selectedTab, 1);
+
+  // Send a middle-click and confirm that the clicked site opens immediately next to the new tab page.
+  yield BrowserTestUtils.synthesizeMouseAtCenter(".newtab-cell",
+                                                 {button: 1}, gBrowser.selectedBrowser);
+
+  yield BrowserTestUtils.browserLoaded(gBrowser.getBrowserAtIndex(2));
+  is(gBrowser.getBrowserAtIndex(2).currentURI.spec, "http://example.com/",
+     "Middle click opens site in a new tab immediately to the right.");
+});