gh-15279: Wait for all windows to be restored before syncing (gh-15294)

This commit is contained in:
mr. m
2026-09-08 18:13:33 +02:00
committed by GitHub
parent 412731f37e
commit 243a8791a0
11 changed files with 159 additions and 13 deletions

View File

@@ -24,6 +24,11 @@ zen-welcome-default-search-description = Choose your default search engine. You
zen-welcome-essentials-title = Choose the apps you use most.
zen-welcome-essentials-description = Select your favorite apps to keep them handy in your sidebar.
zen-welcome-block-ads-title = Block ads and trackers?
zen-welcome-block-ads-description = { -brand-short-name } can install uBlock Origin for you, so pages load cleaner and faster. You can remove it any time.
zen-welcome-block-ads-yes = <strong>YES</strong>, block ads for me.
zen-welcome-block-ads-no = <strong>NO</strong>, show me everything.
zen-welcome-workspace-colors-title = Your space, your colors.
zen-welcome-workspace-colors-description = Personalize your browser by giving each space its own unique color identity.

View File

@@ -1,8 +1,8 @@
diff --git a/browser/components/preferences/main.js b/browser/components/preferences/main.js
index 88675d1bcbf000b10d85a9c0980bc6069d88052c..ed3a1e809eb0fcccc5a957be7affb77be8978e32 100644
index 5a56d348146c1c37c088ced60327fffebcf8fac0..abd65594d365fbc0a74af3953c71f410301898ad 100644
--- a/browser/components/preferences/main.js
+++ b/browser/components/preferences/main.js
@@ -528,6 +528,11 @@ function createStartupConfig(hidden = false) {
@@ -529,6 +529,11 @@ function createStartupConfig(hidden = false) {
},
],
},
@@ -14,7 +14,7 @@ index 88675d1bcbf000b10d85a9c0980bc6069d88052c..ed3a1e809eb0fcccc5a957be7affb77b
{
id: "windowsLaunchOnLogin",
l10nId: "windows-launch-on-login",
@@ -575,7 +580,7 @@ function createStartupConfig(hidden = false) {
@@ -576,7 +581,7 @@ function createStartupConfig(hidden = false) {
SettingGroupManager.registerGroups({
defaultBrowser: createDefaultBrowserConfig(),
startup: createStartupConfig(
@@ -23,7 +23,7 @@ index 88675d1bcbf000b10d85a9c0980bc6069d88052c..ed3a1e809eb0fcccc5a957be7affb77b
),
});
@@ -628,7 +633,7 @@ function getBundleForLocales(newLocales) {
@@ -636,7 +641,7 @@ function getBundleForLocales(newLocales) {
])
);
return new Localization(

View File

@@ -0,0 +1,13 @@
diff --git a/browser/extensions/newtab/lib/AboutPreferences.sys.mjs b/browser/extensions/newtab/lib/AboutPreferences.sys.mjs
index 4562efc05b76d5dddd35bda79bd7d5d98a51ffc9..ad9b6f55f5e77065ce74535daf6457a5c4b44058 100644
--- a/browser/extensions/newtab/lib/AboutPreferences.sys.mjs
+++ b/browser/extensions/newtab/lib/AboutPreferences.sys.mjs
@@ -355,7 +355,7 @@ export class AboutPreferences {
// Firefox 155+ registers `homepage` and `customHomepage` in
// components/preferences. They can't be registered twice, so skip them
// on 155+. Drop this condition once 155 reaches Release.
- if (Services.vc.compare(AppConstants.MOZ_APP_VERSION, "155.0a1") < 0) {
+ if (false) {
groups.homepage = this._setupHomepageGroup(window);
groups.customHomepage = this._setupCustomHomepageGroup(window);
}

View File

@@ -414,7 +414,10 @@ class nsZenShareManager extends nsZenDOMOperatedFeature {
return tab;
});
gZenViewSplitter.splitTabs(tabs, "grid", 0);
gBrowser.removeTab(shareTab, { closeWindowWithLastTab: false });
gBrowser.removeTab(shareTab, {
closeWindowWithLastTab: false,
skipSessionStore: true,
});
// Shake the new split group in the sidebar.
const group = tabs[0]?.group;
if (group?.hasAttribute("split-view-group")) {
@@ -422,8 +425,8 @@ class nsZenShareManager extends nsZenDOMOperatedFeature {
gZenUIManager.motion
.animate(
group,
{ x: [-14, 0] },
{ type: "spring", bounce: 0.8, duration: 1.2 }
{ x: [-28, 0] },
{ type: "spring", bounce: 0.9, duration: 1.4 }
)
.then(() => {
group.style.removeProperty("transform");
@@ -543,7 +546,10 @@ class nsZenShareManager extends nsZenDOMOperatedFeature {
gZenUIManager.showToast("zen-share-imported-toast");
const tab = gBrowser.getTabForBrowser(browser);
if (tab) {
gBrowser.removeTab(tab, { closeWindowWithLastTab: false });
gBrowser.removeTab(tab, {
closeWindowWithLastTab: false,
skipSessionStore: true,
});
}
} catch (e) {
console.error("ZenShare: could not import share:", e);

View File

@@ -403,7 +403,8 @@ zen-workspace {
}
:root:not(:is([animating-background], [swipe-gesture])) #navigator-toolbox:not([movingtab]) &:not([active]) {
display: none;
-moz-subtree-hidden-only-visually: 1;
content-visibility: hidden;
}
}

View File

@@ -24,6 +24,7 @@ XPCOMUtils.defineLazyPreferenceGetter(
ChromeUtils.defineESModuleGetters(lazy, {
SessionSaver: "resource:///modules/sessionstore/SessionSaver.sys.mjs",
SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs",
E10SUtils: "resource://gre/modules/E10SUtils.sys.mjs",
TabStateCache: "resource:///modules/sessionstore/TabStateCache.sys.mjs",
ZenWindowSync: "resource:///modules/zen/ZenWindowSync.sys.mjs",
@@ -155,6 +156,7 @@ class nsZenSpacesSyncApplier {
fail(entry.record, noWindow);
}
} else {
await lazy.SessionStore.promiseAllWindowsRestored;
await win.gZenWorkspaces.promiseInitialized;
this.#maybePlayFirstSyncAnimation(win);
// A sync apply is a materialization just like session restore,

View File

@@ -95,6 +95,12 @@ add_task(async function test_Welcome_Steps() {
await goNextWelcomePage("zen-generic-next");
ok(true, "Welcome Search Step Test Finished");
await TestUtils.waitForCondition(
() => currentPageContent()?.getAttribute("page") === "essentials",
"the ad blocking page to be skipped when uBlock is unavailable"
);
ok(true, "Welcome Block Ads Step Test Finished");
const essentials = currentPageContent().querySelectorAll(
"#zen-welcome-essentials .zen-welcome-essential"
);

View File

@@ -1,2 +1,2 @@
// Ignore license in this file
https://cdn.jsdelivr.net/npm/motion@latest/dist/motion.js: v12.23.11
https://cdn.jsdelivr.net/npm/motion@latest/dist/motion.js: v13.2.0

File diff suppressed because one or more lines are too long

View File

@@ -6,6 +6,10 @@
let lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
AddonManager: "resource://gre/modules/AddonManager.sys.mjs",
CustomizableUI:
"moz-src:///browser/components/customizableui/CustomizableUI.sys.mjs",
AddonRepository: "resource://gre/modules/addons/AddonRepository.sys.mjs",
SearchService: "moz-src:///toolkit/components/search/SearchService.sys.mjs",
});
@@ -26,11 +30,33 @@
{ url: "https://figma.com", icon: "figma", color: "#f24e1e" },
];
const kAdBlockerId = "uBlock0@raymondhill.net";
const gChoices = {
setDefaultBrowser: false,
essentials: new Set(),
blockAds: true,
};
let _adBlocker;
async function fetchAdBlocker() {
if (_adBlocker !== undefined) {
return _adBlocker;
}
try {
const [found, installed] = await Promise.all([
lazy.AddonRepository.getAddonsByIDs([kAdBlockerId]),
lazy.AddonManager.getAddonsByIDs([kAdBlockerId]),
]);
_adBlocker = installed[0] || !found[0]?.sourceURI ? null : found[0];
} catch (ex) {
console.error(ex);
_adBlocker = null;
}
return _adBlocker;
}
function clearBrowserElements() {
for (const element of document.getElementById("browser").children) {
if (kZenElementsToIgnore.includes(element.id)) {
@@ -131,6 +157,44 @@
return label;
}
const _startedInstalls = new Set();
function unpinInstalledAddon(addon) {
const widgetId =
addon.id.toLowerCase().replace(/[^a-z0-9_-]/g, "_") + "-browser-action";
try {
if (lazy.CustomizableUI.getPlacementOfWidget(widgetId)) {
lazy.CustomizableUI.addWidgetToArea(
widgetId,
lazy.CustomizableUI.AREA_ADDONS
);
}
} catch (ex) {
console.error(ex);
}
}
function installAddons(addons) {
for (const addon of addons) {
if (_startedInstalls.has(addon.id)) {
continue;
}
_startedInstalls.add(addon.id);
(async () => {
try {
const install = await lazy.AddonManager.getInstallForURL(
addon.sourceURI.spec,
{ name: addon.name, icons: addon.icons }
);
await install.install();
unpinInstalledAddon(addon);
} catch (ex) {
console.error(`Failed to install ${addon.id}`, ex);
}
})();
}
}
function removeVideoBackground() {
const video = document.getElementById("zen-welcome-video");
if (!video) {
@@ -207,6 +271,12 @@
#show(index, direction) {
const previous = this.currentPage;
while (this.#pages[index]?.skip?.()) {
index += direction;
}
if (index < 0) {
return;
}
this.#index = index;
const page = this.currentPage;
if (!page) {
@@ -269,7 +339,7 @@
if (page.id) {
content.setAttribute("page", page.id);
}
page.render(content);
page.render(content, this);
this.contentContainer.appendChild(content);
this.#content = content;
animate(content, { opacity: [0, 1] }, kFade);
@@ -324,6 +394,8 @@
await animate(`#browser > *:not(${elementsToIgnore})`, {
opacity: [0, 1],
});
_adBlocker = undefined;
_startedInstalls.clear();
}
async #applyChoices() {
@@ -558,6 +630,46 @@
}
},
},
{
id: "block-ads",
title: "zen-welcome-block-ads-title",
descriptions: ["zen-welcome-block-ads-description"],
buttons: [kNextButton],
// Nothing to offer once we know the add-on can't be installed.
skip() {
return _adBlocker === null;
},
async render(content, pages) {
content.appendChild(
createOption({
id: "zen-welcome-block-ads-yes",
group: "zen-welcome-block-ads",
l10n: "zen-welcome-block-ads-yes",
checked: gChoices.blockAds,
})
);
content.appendChild(
createOption({
id: "zen-welcome-block-ads-no",
group: "zen-welcome-block-ads",
l10n: "zen-welcome-block-ads-no",
checked: !gChoices.blockAds,
})
);
// The lookup is warmed at startup, so this usually settled long ago.
if ((await fetchAdBlocker()) === null && content.isConnected) {
pages.next();
}
},
commit(content) {
gChoices.blockAds = content.querySelector(
"#zen-welcome-block-ads-yes"
).checked;
if (gChoices.blockAds && _adBlocker) {
installAddons([_adBlocker]);
}
},
},
{
id: "essentials",
title: "zen-welcome-essentials-title",
@@ -768,6 +880,7 @@
}
function startZenWelcome() {
fetchAdBlocker();
clearBrowserElements();
centerWindowOnScreen();
initializeZenWelcome();

View File

@@ -20,7 +20,7 @@
"brandShortName": "Zen",
"brandFullName": "Zen Browser",
"release": {
"displayVersion": "1.22b",
"displayVersion": "1.22.1b",
"github": {
"repo": "zen-browser/desktop"
},