Skip to content

Commit 51de2de

Browse files
committed
Backed out changeset 8b3fe0426ffc (bug 1442694)
UltraBlame original commit: c923e07cf0ff04559568f8ef795709b047343a2c
1 parent 9ea4530 commit 51de2de

File tree

2 files changed

+121
-71
lines changed

2 files changed

+121
-71
lines changed

browser/components/sessionstore/SessionStore.jsm

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3612,36 +3612,6 @@ var SessionStoreInternal = {
36123612

36133613

36143614

3615-
_updateRestoredSelectedTabPinnedState(aWindow, aWinData, aRestoreIndex) {
3616-
let tabbrowser = aWindow.gBrowser;
3617-
let tabData = aWinData.tabs[aRestoreIndex];
3618-
let tab = tabbrowser.selectedTab;
3619-
let needsUnpin = tab.pinned && !tabData.pinned;
3620-
let needsPin = !tab.pinned && tabData.pinned;
3621-
if (needsUnpin) {
3622-
tabbrowser.unpinTab(tab);
3623-
} else if (needsPin && tab == tabbrowser.tabs[aRestoreIndex]) {
3624-
tabbrowser.pinTab(tab);
3625-
} else if (needsPin) {
3626-
tabbrowser.removeTab(tabbrowser.tabs[aRestoreIndex]);
3627-
tabbrowser.pinTab(tab);
3628-
tabbrowser.moveTabTo(tab, aRestoreIndex);
3629-
}
3630-
return tab;
3631-
},
3632-
3633-
3634-
3635-
3636-
3637-
3638-
3639-
3640-
3641-
3642-
3643-
3644-
36453615
restoreWindow: function ssi_restoreWindow(aWindow, winData, aOptions = {}) {
36463616
let overwriteTabs = aOptions && aOptions.overwriteTabs;
36473617
let firstWindow = aOptions && aOptions.firstWindow;
@@ -3715,7 +3685,14 @@ var SessionStoreInternal = {
37153685

37163686
if (select &&
37173687
tabbrowser.selectedTab.userContextId == userContextId) {
3718-
tab = this._updateRestoredSelectedTabPinnedState(aWindow, winData, t);
3688+
tab = tabbrowser.selectedTab;
3689+
if (tab.pinned && !tabData.pinned) {
3690+
tabbrowser.unpinTab(tab);
3691+
} else if (!tab.pinned && tabData.pinned) {
3692+
tabbrowser.removeTab(tabbrowser.tabs[t]);
3693+
tabbrowser.pinTab(tab);
3694+
tabbrowser.moveTabTo(tab, t);
3695+
}
37193696

37203697
tabbrowser.moveTabToEnd();
37213698
if (aWindow.gMultiProcessBrowser && !tab.linkedBrowser.isRemoteBrowser) {

browser/components/sessionstore/test/browser_preopened_apptabs.js

Lines changed: 113 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -23,43 +23,116 @@ registerCleanupFunction(function() {
2323
Services.prefs.clearUserPref(PREF_NUM_PINNED_TABS);
2424
});
2525

26-
let testCases = [
27-
{numPinnedPref: 5, selected: 3, overrideTabs: false},
28-
{numPinnedPref: 5, selected: 3, overrideTabs: true},
29-
{numPinnedPref: 5, selected: 1, overrideTabs: false},
30-
{numPinnedPref: 5, selected: 1, overrideTabs: true},
31-
{numPinnedPref: 3, selected: 3, overrideTabs: false},
32-
{numPinnedPref: 3, selected: 3, overrideTabs: true},
33-
{numPinnedPref: 3, selected: 1, overrideTabs: false},
34-
{numPinnedPref: 3, selected: 1, overrideTabs: true},
35-
{numPinnedPref: 1, selected: 3, overrideTabs: false},
36-
{numPinnedPref: 1, selected: 3, overrideTabs: true},
37-
{numPinnedPref: 1, selected: 1, overrideTabs: false},
38-
{numPinnedPref: 1, selected: 1, overrideTabs: true},
39-
{numPinnedPref: 0, selected: 3, overrideTabs: false},
40-
{numPinnedPref: 0, selected: 3, overrideTabs: true},
41-
{numPinnedPref: 0, selected: 1, overrideTabs: false},
42-
{numPinnedPref: 0, selected: 1, overrideTabs: true},
43-
];
44-
45-
for (let {numPinnedPref, selected, overrideTabs} of testCases) {
46-
add_task(async function testPrefSynced() {
47-
Services.prefs.setIntPref(PREF_NUM_PINNED_TABS, numPinnedPref);
48-
49-
let state = { windows: [{ tabs: [
50-
{ entries: [{ url: "http://example.org/#1", triggeringPrincipal_base64 }], pinned: true, userContextId: 0 },
51-
{ entries: [{ url: "http://example.org/#2", triggeringPrincipal_base64 }], pinned: true, userContextId: 0 },
52-
{ entries: [{ url: "http://example.org/#3", triggeringPrincipal_base64 }], pinned: true, userContextId: 0 },
53-
], selected }] };
54-
55-
muffleMainWindowType();
56-
let win = await BrowserTestUtils.openNewBrowserWindow();
57-
Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, numPinnedPref);
58-
Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length, 1);
59-
await setWindowState(win, state, overrideTabs, true);
60-
Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, 3);
61-
Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length,
62-
overrideTabs ? 3 : 4);
63-
await BrowserTestUtils.closeWindow(win);
64-
});
65-
}
26+
add_task(async function testPrefSynced() {
27+
Services.prefs.setIntPref(PREF_NUM_PINNED_TABS, 3);
28+
29+
let state = { windows: [{ tabs: [
30+
{ entries: [{ url: "http://example.org/#1", triggeringPrincipal_base64 }], pinned: true },
31+
{ entries: [{ url: "http://example.org/#2", triggeringPrincipal_base64 }], pinned: true },
32+
{ entries: [{ url: "http://example.org/#3", triggeringPrincipal_base64 }], pinned: true },
33+
], selected: 3 }] };
34+
35+
muffleMainWindowType();
36+
let win = await BrowserTestUtils.openNewBrowserWindow();
37+
Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, 3);
38+
Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length, 1);
39+
await setWindowState(win, state, false, true);
40+
Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, 3);
41+
Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length, 4);
42+
await BrowserTestUtils.closeWindow(win);
43+
});
44+
45+
add_task(async function testPrefSyncedSelected() {
46+
Services.prefs.setIntPref(PREF_NUM_PINNED_TABS, 3);
47+
48+
let state = { windows: [{ tabs: [
49+
{ entries: [{ url: "http://example.org/#1", triggeringPrincipal_base64 }], pinned: true },
50+
{ entries: [{ url: "http://example.org/#2", triggeringPrincipal_base64 }], pinned: true },
51+
{ entries: [{ url: "http://example.org/#3", triggeringPrincipal_base64 }], pinned: true },
52+
], selected: 1 }] };
53+
54+
muffleMainWindowType();
55+
let win = await BrowserTestUtils.openNewBrowserWindow();
56+
Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, 3);
57+
Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length, 1);
58+
await setWindowState(win, state, false, true);
59+
Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, 3);
60+
Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length, 4);
61+
await BrowserTestUtils.closeWindow(win);
62+
});
63+
64+
add_task(async function testPrefTooHigh() {
65+
Services.prefs.setIntPref(PREF_NUM_PINNED_TABS, 5);
66+
67+
let state = { windows: [{ tabs: [
68+
{ entries: [{ url: "http://example.org/#1", triggeringPrincipal_base64 }], pinned: true },
69+
{ entries: [{ url: "http://example.org/#2", triggeringPrincipal_base64 }], pinned: true },
70+
{ entries: [{ url: "http://example.org/#3", triggeringPrincipal_base64 }], pinned: true },
71+
], selected: 3 }] };
72+
73+
muffleMainWindowType();
74+
let win = await BrowserTestUtils.openNewBrowserWindow();
75+
Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, 5);
76+
Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length, 1);
77+
await setWindowState(win, state, false, true);
78+
Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, 3);
79+
Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length, 4);
80+
await BrowserTestUtils.closeWindow(win);
81+
});
82+
83+
add_task(async function testPrefTooLow() {
84+
Services.prefs.setIntPref(PREF_NUM_PINNED_TABS, 1);
85+
86+
let state = { windows: [{ tabs: [
87+
{ entries: [{ url: "http://example.org/#1", triggeringPrincipal_base64 }], pinned: true },
88+
{ entries: [{ url: "http://example.org/#2", triggeringPrincipal_base64 }], pinned: true },
89+
{ entries: [{ url: "http://example.org/#3", triggeringPrincipal_base64 }], pinned: true },
90+
], selected: 3 }] };
91+
92+
muffleMainWindowType();
93+
let win = await BrowserTestUtils.openNewBrowserWindow();
94+
Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, 1);
95+
Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length, 1);
96+
await setWindowState(win, state, false, true);
97+
Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, 3);
98+
Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length, 4);
99+
await BrowserTestUtils.closeWindow(win);
100+
});
101+
102+
add_task(async function testPrefTooHighSelected() {
103+
Services.prefs.setIntPref(PREF_NUM_PINNED_TABS, 5);
104+
105+
let state = { windows: [{ tabs: [
106+
{ entries: [{ url: "http://example.org/#1", triggeringPrincipal_base64 }], pinned: true },
107+
{ entries: [{ url: "http://example.org/#2", triggeringPrincipal_base64 }], pinned: true },
108+
{ entries: [{ url: "http://example.org/#3", triggeringPrincipal_base64 }], pinned: true },
109+
], selected: 1 }] };
110+
111+
muffleMainWindowType();
112+
let win = await BrowserTestUtils.openNewBrowserWindow();
113+
Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, 5);
114+
Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length, 1);
115+
await setWindowState(win, state, false, true);
116+
Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, 3);
117+
Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length, 4);
118+
await BrowserTestUtils.closeWindow(win);
119+
});
120+
121+
add_task(async function testPrefTooLowSelected() {
122+
Services.prefs.setIntPref(PREF_NUM_PINNED_TABS, 1);
123+
124+
let state = { windows: [{ tabs: [
125+
{ entries: [{ url: "http://example.org/#1", triggeringPrincipal_base64 }], pinned: true },
126+
{ entries: [{ url: "http://example.org/#2", triggeringPrincipal_base64 }], pinned: true },
127+
{ entries: [{ url: "http://example.org/#3", triggeringPrincipal_base64 }], pinned: true },
128+
], selected: 1 }] };
129+
130+
muffleMainWindowType();
131+
let win = await BrowserTestUtils.openNewBrowserWindow();
132+
Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, 1);
133+
Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length, 1);
134+
await setWindowState(win, state, false, true);
135+
Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, 3);
136+
Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length, 4);
137+
await BrowserTestUtils.closeWindow(win);
138+
});

0 commit comments

Comments
 (0)