1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/base/content/test/general/browser_relatedTabs.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,49 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +function test() { 1.9 + is(gBrowser.tabs.length, 1, "one tab is open initially"); 1.10 + 1.11 + // Add several new tabs in sequence, interrupted by selecting a 1.12 + // different tab, moving a tab around and closing a tab, 1.13 + // returning a list of opened tabs for verifying the expected order. 1.14 + // The new tab behaviour is documented in bug 465673 1.15 + let tabs = []; 1.16 + function addTab(aURL, aReferrer) { 1.17 + tabs.push(gBrowser.addTab(aURL, {referrerURI: aReferrer})); 1.18 + } 1.19 + 1.20 + addTab("http://mochi.test:8888/#0"); 1.21 + gBrowser.selectedTab = tabs[0]; 1.22 + addTab("http://mochi.test:8888/#1"); 1.23 + addTab("http://mochi.test:8888/#2", gBrowser.currentURI); 1.24 + addTab("http://mochi.test:8888/#3", gBrowser.currentURI); 1.25 + gBrowser.selectedTab = tabs[tabs.length - 1]; 1.26 + gBrowser.selectedTab = tabs[0]; 1.27 + addTab("http://mochi.test:8888/#4", gBrowser.currentURI); 1.28 + gBrowser.selectedTab = tabs[3]; 1.29 + addTab("http://mochi.test:8888/#5", gBrowser.currentURI); 1.30 + gBrowser.removeTab(tabs.pop()); 1.31 + addTab("about:blank", gBrowser.currentURI); 1.32 + gBrowser.moveTabTo(gBrowser.selectedTab, 1); 1.33 + addTab("http://mochi.test:8888/#6", gBrowser.currentURI); 1.34 + addTab(); 1.35 + addTab("http://mochi.test:8888/#7"); 1.36 + 1.37 + function testPosition(tabNum, expectedPosition, msg) { 1.38 + is(Array.indexOf(gBrowser.tabs, tabs[tabNum]), expectedPosition, msg); 1.39 + } 1.40 + 1.41 + testPosition(0, 3, "tab without referrer was opened to the far right"); 1.42 + testPosition(1, 7, "tab without referrer was opened to the far right"); 1.43 + testPosition(2, 5, "tab with referrer opened immediately to the right"); 1.44 + testPosition(3, 1, "next tab with referrer opened further to the right"); 1.45 + testPosition(4, 4, "tab selection changed, tab opens immediately to the right"); 1.46 + testPosition(5, 6, "blank tab with referrer opens to the right of 3rd original tab where removed tab was"); 1.47 + testPosition(6, 2, "tab has moved, new tab opens immediately to the right"); 1.48 + testPosition(7, 8, "blank tab without referrer opens at the end"); 1.49 + testPosition(8, 9, "tab without referrer opens at the end"); 1.50 + 1.51 + tabs.forEach(gBrowser.removeTab, gBrowser); 1.52 +}