Bug 663395 - put tabs opened from pinned tabs at the end of the tab strip. r=gavin ui-r=faaborg
authorDão Gottwald <dao@mozilla.com>
Thu, 21 Jul 2011 04:36:02 +0200
changeset 73086 ef79a5b416978bd3d91e690acce722af9f4671b9
parent 73085 dd5648b2280220f97ff23fcb5c926ff3c8b44c99
child 73087 6df31af4cca62113ba9bf90877f71c59d3b5bd75
push idunknown
push userunknown
push dateunknown
reviewersgavin, faaborg
bugs663395
milestone8.0a1
Bug 663395 - put tabs opened from pinned tabs at the end of the tab strip. r=gavin ui-r=faaborg
browser/base/content/tabbrowser.xml
browser/base/content/test/browser_relatedTabs.js
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -1367,25 +1367,29 @@
             // activeness in the tab switcher.
             b.docShellIsActive = false;
 
             // Check if we're opening a tab related to the current tab and
             // move it to after the current tab.
             // aReferrerURI is null or undefined if the tab is opened from
             // an external application or bookmark, i.e. somewhere other
             // than the current tab.
-            if ((aRelatedToCurrent == null ? aReferrerURI : aRelatedToCurrent) &&
-                Services.prefs.getBoolPref("browser.tabs.insertRelatedAfterCurrent")) {
+            if (aRelatedToCurrent == null ? aReferrerURI : aRelatedToCurrent) {
               let newTabPos = (this._lastRelatedTab ||
                                this.selectedTab)._tPos + 1;
+
               if (this._lastRelatedTab)
                 this._lastRelatedTab.owner = null;
               else
                 t.owner = this.selectedTab;
-              this.moveTabTo(t, newTabPos);
+
+              if (!this.selectedTab.pinned &&
+                  Services.prefs.getBoolPref("browser.tabs.insertRelatedAfterCurrent"))
+                this.moveTabTo(t, newTabPos);
+
               this._lastRelatedTab = t;
             }
 
             return t;
           ]]>
         </body>
       </method>
 
--- a/browser/base/content/test/browser_relatedTabs.js
+++ b/browser/base/content/test/browser_relatedTabs.js
@@ -73,10 +73,19 @@ function test() {
   testPosition(2, 5, "tab with referrer opened immediately to the right");
   testPosition(3, 1, "next tab with referrer opened further to the right");
   testPosition(4, 4, "tab selection changed, tab opens immediately to the right");
   testPosition(5, 6, "blank tab with referrer opens to the right of 3rd original tab where removed tab was");
   testPosition(6, 2, "tab has moved, new tab opens immediately to the right");
   testPosition(7, 8, "blank tab without referrer opens at the end");
   testPosition(8, 9, "tab without referrer opens at the end");
 
+  gBrowser.selectedTab = tabs[0];
+  gBrowser.pinTab(gBrowser.selectedTab);
+  addTab("http://mochi.test:8888/#8", gBrowser.currentURI);
+  testPosition(9, 10, "tab with referrer should open at the end when the selected tab is pinned");
+  gBrowser.selectedTab = tabs[9];
+  gBrowser.removeTab(tabs.pop());
+  is(gBrowser.selectedTab, tabs[0],
+     "opening a tab from a pinned tab, selecting it and closing it should go back to the pinned tab");
+
   tabs.forEach(gBrowser.removeTab, gBrowser);
 }