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