Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | function test() { |
michael@0 | 6 | is(gBrowser.tabs.length, 1, "one tab is open initially"); |
michael@0 | 7 | |
michael@0 | 8 | // Add several new tabs in sequence, interrupted by selecting a |
michael@0 | 9 | // different tab, moving a tab around and closing a tab, |
michael@0 | 10 | // returning a list of opened tabs for verifying the expected order. |
michael@0 | 11 | // The new tab behaviour is documented in bug 465673 |
michael@0 | 12 | let tabs = []; |
michael@0 | 13 | function addTab(aURL, aReferrer) { |
michael@0 | 14 | tabs.push(gBrowser.addTab(aURL, {referrerURI: aReferrer})); |
michael@0 | 15 | } |
michael@0 | 16 | |
michael@0 | 17 | addTab("http://mochi.test:8888/#0"); |
michael@0 | 18 | gBrowser.selectedTab = tabs[0]; |
michael@0 | 19 | addTab("http://mochi.test:8888/#1"); |
michael@0 | 20 | addTab("http://mochi.test:8888/#2", gBrowser.currentURI); |
michael@0 | 21 | addTab("http://mochi.test:8888/#3", gBrowser.currentURI); |
michael@0 | 22 | gBrowser.selectedTab = tabs[tabs.length - 1]; |
michael@0 | 23 | gBrowser.selectedTab = tabs[0]; |
michael@0 | 24 | addTab("http://mochi.test:8888/#4", gBrowser.currentURI); |
michael@0 | 25 | gBrowser.selectedTab = tabs[3]; |
michael@0 | 26 | addTab("http://mochi.test:8888/#5", gBrowser.currentURI); |
michael@0 | 27 | gBrowser.removeTab(tabs.pop()); |
michael@0 | 28 | addTab("about:blank", gBrowser.currentURI); |
michael@0 | 29 | gBrowser.moveTabTo(gBrowser.selectedTab, 1); |
michael@0 | 30 | addTab("http://mochi.test:8888/#6", gBrowser.currentURI); |
michael@0 | 31 | addTab(); |
michael@0 | 32 | addTab("http://mochi.test:8888/#7"); |
michael@0 | 33 | |
michael@0 | 34 | function testPosition(tabNum, expectedPosition, msg) { |
michael@0 | 35 | is(Array.indexOf(gBrowser.tabs, tabs[tabNum]), expectedPosition, msg); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | testPosition(0, 3, "tab without referrer was opened to the far right"); |
michael@0 | 39 | testPosition(1, 7, "tab without referrer was opened to the far right"); |
michael@0 | 40 | testPosition(2, 5, "tab with referrer opened immediately to the right"); |
michael@0 | 41 | testPosition(3, 1, "next tab with referrer opened further to the right"); |
michael@0 | 42 | testPosition(4, 4, "tab selection changed, tab opens immediately to the right"); |
michael@0 | 43 | testPosition(5, 6, "blank tab with referrer opens to the right of 3rd original tab where removed tab was"); |
michael@0 | 44 | testPosition(6, 2, "tab has moved, new tab opens immediately to the right"); |
michael@0 | 45 | testPosition(7, 8, "blank tab without referrer opens at the end"); |
michael@0 | 46 | testPosition(8, 9, "tab without referrer opens at the end"); |
michael@0 | 47 | |
michael@0 | 48 | tabs.forEach(gBrowser.removeTab, gBrowser); |
michael@0 | 49 | } |