Skip to content

Commit 2fb5214

Browse files
committed
fix: Don't allow private windows to sync new tabs, b=closes #11949, c=no-component
1 parent d72c69a commit 2fb5214

4 files changed

Lines changed: 37 additions & 64 deletions

File tree

prefs/zen/session-store.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,3 @@
1010

1111
- name: zen.session-store.restore-unsynced-windows
1212
value: true
13-
14-
- name: zen.session-store.reduce-sessionstore-write-size
15-
value: true
16-
17-
- name: zen.session-store.allow-restoring-closed-synced-windows
18-
value: false
Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/browser/components/sessionstore/SessionSaver.sys.mjs b/browser/components/sessionstore/SessionSaver.sys.mjs
2-
index 9141793550f7c7ff6aa63d4c85bf571b4499e2d0..a4ce5de45f13eaa22803083eccb4e48a054fee39 100644
2+
index 9141793550f7c7ff6aa63d4c85bf571b4499e2d0..6906fd9be7ae6ca4316133e0d6552b797c54a7ec 100644
33
--- a/browser/components/sessionstore/SessionSaver.sys.mjs
44
+++ b/browser/components/sessionstore/SessionSaver.sys.mjs
55
@@ -20,6 +20,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
@@ -27,24 +27,3 @@ index 9141793550f7c7ff6aa63d4c85bf571b4499e2d0..a4ce5de45f13eaa22803083eccb4e48a
2727
return this._writeState(state);
2828
},
2929

30-
@@ -372,7 +374,19 @@ var SessionSaverInternal = {
31-
// Write (atomically) to a session file, using a tmp file. Once the session
32-
// file is successfully updated, save the time stamp of the last save and
33-
// notify the observers.
34-
- return lazy.SessionFile.write(state).then(
35-
+ let stateToWrite = Cu.cloneInto(state, {});
36-
+ if (Services.prefs.getBoolPref("zen.session-store.reduce-sessionstore-write-size", true)) {
37-
+ for (let i = 0; i < stateToWrite.windows.length; i++) {
38-
+ let win = stateToWrite.windows[i];
39-
+ if (win.isPopup || win.isTaskbarTab || win.isZenUnsynced) {
40-
+ continue;
41-
+ }
42-
+ win.tabs = [];
43-
+ win.folders = [];
44-
+ win.groups = [];
45-
+ }
46-
+ }
47-
+ return lazy.SessionFile.write(stateToWrite).then(
48-
() => {
49-
this.updateLastSaveTime();
50-
if (!lazy.RunState.isRunning) {

src/browser/components/sessionstore/SessionStore-sys-mjs.patch

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/browser/components/sessionstore/SessionStore.sys.mjs b/browser/components/sessionstore/SessionStore.sys.mjs
2-
index 2a055f0c5f34f0a2667f659185120c07d38f4e41..ccdc2f2c9c8384d696e0bb32ddbbe254fd98c027 100644
2+
index 2a055f0c5f34f0a2667f659185120c07d38f4e41..1562a49c47f934b3f4372ce8ca74d5c0559b8ae7 100644
33
--- a/browser/components/sessionstore/SessionStore.sys.mjs
44
+++ b/browser/components/sessionstore/SessionStore.sys.mjs
55
@@ -127,6 +127,9 @@ const TAB_EVENTS = [
@@ -95,34 +95,34 @@ index 2a055f0c5f34f0a2667f659185120c07d38f4e41..ccdc2f2c9c8384d696e0bb32ddbbe254
9595

9696
TAB_EVENTS.forEach(function (aEvent) {
9797
tabbrowser.tabContainer.removeEventListener(aEvent, this, true);
98-
@@ -2477,7 +2495,10 @@ var SessionStoreInternal = {
99-
100-
// This window has the potential to be saved in the _closedWindows
101-
// array (maybeSaveClosedWindows gets the final call on that).
102-
+ if (!Services.prefs.getBoolPref("zen.session-store.allow-restoring-closed-synced-windows", false)
103-
+ && (winData.isTaskbarTab || winData.isPrivate || winData.isZenUnsynced)) {
104-
this._saveableClosedWindowData.add(winData);
105-
+ }
98+
@@ -2491,7 +2509,7 @@ var SessionStoreInternal = {
99+
// 2) Flush the window.
100+
// 3) When the flush is complete, revisit our decision to store the window
101+
// in _closedWindows, and add/remove as necessary.
102+
- if (!winData.isPrivate && !winData.isTaskbarTab) {
103+
+ if (!winData.isPrivate && !winData.isTaskbarTab && !winData.isZenUnsynced) {
104+
this.maybeSaveClosedWindow(winData, isLastWindow);
105+
}
106106

107-
// Now we have to figure out if this window is worth saving in the _closedWindows
108-
// Object.
109-
@@ -2512,6 +2533,7 @@ var SessionStoreInternal = {
107+
@@ -2512,7 +2530,8 @@ var SessionStoreInternal = {
110108

111109
// Save non-private windows if they have at
112110
// least one saveable tab or are the last window.
111+
- if (!winData.isPrivate && !winData.isTaskbarTab) {
113112
+ lazy.ZenWindowSync.on_WindowCloseAndBrowserFlushed(browsers);
114-
if (!winData.isPrivate && !winData.isTaskbarTab) {
113+
+ if (!winData.isPrivate && !winData.isTaskbarTab && !winData.isZenUnsynced) {
115114
this.maybeSaveClosedWindow(winData, isLastWindow);
116115

117-
@@ -2590,6 +2612,7 @@ var SessionStoreInternal = {
118-
* a window flush).
119-
*/
120-
maybeSaveClosedWindow(winData, isLastWindow) {
121-
+ lazy.ZenSessionStore.maybeSaveClosedWindow(winData, isLastWindow);
122-
// Make sure SessionStore is still running, and make sure that we
123-
// haven't chosen to forget this window.
124-
if (
125-
@@ -3408,7 +3431,7 @@ var SessionStoreInternal = {
116+
if (!isLastWindow && winData.closedId > -1) {
117+
@@ -2608,6 +2627,7 @@ var SessionStoreInternal = {
118+
let alreadyStored = winIndex != -1;
119+
// If sidebar command is truthy, i.e. sidebar is open, store sidebar settings
120+
let shouldStore = hasSaveableTabs || isLastWindow;
121+
+ lazy.ZenSessionStore.maybeSaveClosedWindow(winData, isLastWindow);
122+
123+
if (shouldStore && !alreadyStored) {
124+
let index = this._closedWindows.findIndex(win => {
125+
@@ -3408,7 +3428,7 @@ var SessionStoreInternal = {
126126
if (!isPrivateWindow && tabState.isPrivate) {
127127
return;
128128
}
@@ -131,7 +131,7 @@ index 2a055f0c5f34f0a2667f659185120c07d38f4e41..ccdc2f2c9c8384d696e0bb32ddbbe254
131131
return;
132132
}
133133

134-
@@ -4129,6 +4152,12 @@ var SessionStoreInternal = {
134+
@@ -4129,6 +4149,12 @@ var SessionStoreInternal = {
135135
Math.min(tabState.index, tabState.entries.length)
136136
);
137137
tabState.pinned = false;
@@ -144,7 +144,7 @@ index 2a055f0c5f34f0a2667f659185120c07d38f4e41..ccdc2f2c9c8384d696e0bb32ddbbe254
144144

145145
if (inBackground === false) {
146146
aWindow.gBrowser.selectedTab = newTab;
147-
@@ -4565,6 +4594,8 @@ var SessionStoreInternal = {
147+
@@ -4565,6 +4591,8 @@ var SessionStoreInternal = {
148148
// Append the tab if we're opening into a different window,
149149
tabIndex: aSource == aTargetWindow ? pos : Infinity,
150150
pinned: state.pinned,
@@ -153,7 +153,7 @@ index 2a055f0c5f34f0a2667f659185120c07d38f4e41..ccdc2f2c9c8384d696e0bb32ddbbe254
153153
userContextId: state.userContextId,
154154
skipLoad: true,
155155
preferredRemoteType,
156-
@@ -5414,7 +5445,7 @@ var SessionStoreInternal = {
156+
@@ -5414,7 +5442,7 @@ var SessionStoreInternal = {
157157

158158
for (let i = tabbrowser.pinnedTabCount; i < tabbrowser.tabs.length; i++) {
159159
let tab = tabbrowser.tabs[i];
@@ -162,7 +162,7 @@ index 2a055f0c5f34f0a2667f659185120c07d38f4e41..ccdc2f2c9c8384d696e0bb32ddbbe254
162162
removableTabs.push(tab);
163163
}
164164
}
165-
@@ -5525,7 +5556,7 @@ var SessionStoreInternal = {
165+
@@ -5525,7 +5553,7 @@ var SessionStoreInternal = {
166166

167167
// collect the data for all windows
168168
for (ix in this._windows) {
@@ -171,7 +171,7 @@ index 2a055f0c5f34f0a2667f659185120c07d38f4e41..ccdc2f2c9c8384d696e0bb32ddbbe254
171171
// window data is still in _statesToRestore
172172
continue;
173173
}
174-
@@ -5668,11 +5699,12 @@ var SessionStoreInternal = {
174+
@@ -5668,11 +5696,12 @@ var SessionStoreInternal = {
175175
}
176176

177177
let tabbrowser = aWindow.gBrowser;
@@ -185,7 +185,7 @@ index 2a055f0c5f34f0a2667f659185120c07d38f4e41..ccdc2f2c9c8384d696e0bb32ddbbe254
185185
// update the internal state data for this window
186186
for (let tab of tabs) {
187187
if (tab == aWindow.FirefoxViewHandler.tab) {
188-
@@ -5683,6 +5715,9 @@ var SessionStoreInternal = {
188+
@@ -5683,6 +5712,9 @@ var SessionStoreInternal = {
189189
tabsData.push(tabData);
190190
}
191191

@@ -195,7 +195,7 @@ index 2a055f0c5f34f0a2667f659185120c07d38f4e41..ccdc2f2c9c8384d696e0bb32ddbbe254
195195
// update tab group state for this window
196196
winData.groups = [];
197197
for (let tabGroup of aWindow.gBrowser.tabGroups) {
198-
@@ -5695,7 +5730,7 @@ var SessionStoreInternal = {
198+
@@ -5695,7 +5727,7 @@ var SessionStoreInternal = {
199199
// a window is closed, point to the first item in the tab strip instead (it will never be the Firefox View tab,
200200
// since it's only inserted into the tab strip after it's selected).
201201
if (aWindow.FirefoxViewHandler.tab?.selected) {
@@ -204,7 +204,7 @@ index 2a055f0c5f34f0a2667f659185120c07d38f4e41..ccdc2f2c9c8384d696e0bb32ddbbe254
204204
winData.title = tabbrowser.tabs[0].label;
205205
}
206206
winData.selected = selectedIndex;
207-
@@ -5810,8 +5845,8 @@ var SessionStoreInternal = {
207+
@@ -5810,8 +5842,8 @@ var SessionStoreInternal = {
208208
// selectTab represents.
209209
let selectTab = 0;
210210
if (overwriteTabs) {
@@ -215,15 +215,15 @@ index 2a055f0c5f34f0a2667f659185120c07d38f4e41..ccdc2f2c9c8384d696e0bb32ddbbe254
215215
selectTab = Math.min(selectTab, winData.tabs.length);
216216
}
217217

218-
@@ -5833,6 +5868,7 @@ var SessionStoreInternal = {
218+
@@ -5833,6 +5865,7 @@ var SessionStoreInternal = {
219219
if (overwriteTabs) {
220220
for (let i = tabbrowser.browsers.length - 1; i >= 0; i--) {
221221
if (!tabbrowser.tabs[i].selected) {
222222
+ aWindow.gZenWorkspaces._shouldOverrideTabs = true;
223223
tabbrowser.removeTab(tabbrowser.tabs[i]);
224224
}
225225
}
226-
@@ -5866,6 +5902,12 @@ var SessionStoreInternal = {
226+
@@ -5866,6 +5899,12 @@ var SessionStoreInternal = {
227227
savedTabGroup => !openTabGroupIdsInWindow.has(savedTabGroup.id)
228228
);
229229
}
@@ -236,7 +236,7 @@ index 2a055f0c5f34f0a2667f659185120c07d38f4e41..ccdc2f2c9c8384d696e0bb32ddbbe254
236236

237237
// Move the originally open tabs to the end.
238238
if (initialTabs) {
239-
@@ -6419,6 +6461,25 @@ var SessionStoreInternal = {
239+
@@ -6419,6 +6458,25 @@ var SessionStoreInternal = {
240240

241241
// Most of tabData has been restored, now continue with restoring
242242
// attributes that may trigger external events.
@@ -262,7 +262,7 @@ index 2a055f0c5f34f0a2667f659185120c07d38f4e41..ccdc2f2c9c8384d696e0bb32ddbbe254
262262

263263
if (tabData.pinned) {
264264
tabbrowser.pinTab(tab);
265-
@@ -7343,7 +7404,7 @@ var SessionStoreInternal = {
265+
@@ -7343,7 +7401,7 @@ var SessionStoreInternal = {
266266

267267
let groupsToSave = new Map();
268268
for (let tIndex = 0; tIndex < window.tabs.length; ) {
@@ -271,7 +271,7 @@ index 2a055f0c5f34f0a2667f659185120c07d38f4e41..ccdc2f2c9c8384d696e0bb32ddbbe254
271271
// Adjust window.selected
272272
if (tIndex + 1 < window.selected) {
273273
window.selected -= 1;
274-
@@ -7358,7 +7419,7 @@ var SessionStoreInternal = {
274+
@@ -7358,7 +7416,7 @@ var SessionStoreInternal = {
275275
);
276276
// We don't want to increment tIndex here.
277277
continue;

src/zen/sessionstore/ZenWindowSync.sys.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ class nsZenWindowSync {
10121012
on_TabOpen(aEvent) {
10131013
const tab = aEvent.target;
10141014
const window = tab.ownerGlobal;
1015-
const isUnsyncedWindow = window.document.documentElement.hasAttribute("zen-unsynced-window");
1015+
const isUnsyncedWindow = window.gZenWorkspaces.privateWindowOrDisabled;
10161016

10171017
if (tab.id) {
10181018
// This tab was opened as part of a sync operation.

0 commit comments

Comments
 (0)