diff --git a/src/browser/base/content/browser-init-js.patch b/src/browser/base/content/browser-init-js.patch index 5e601cda7..b8ec53782 100644 --- a/src/browser/base/content/browser-init-js.patch +++ b/src/browser/base/content/browser-init-js.patch @@ -1,12 +1,11 @@ diff --git a/browser/base/content/browser-init.js b/browser/base/content/browser-init.js -index bcbfab4a3781ff3c7349115751b3830976eec4bf..1ab08a9344b16cbe791182fce3f6fbf59ca3df91 100644 +index bcbfab4a3781ff3c7349115751b3830976eec4bf..8176656b6f5e70ccf3766ad9f5406758fdb7034b 100644 --- a/browser/base/content/browser-init.js +++ b/browser/base/content/browser-init.js -@@ -186,6 +186,8 @@ var gBrowserInit = { +@@ -186,6 +186,7 @@ var gBrowserInit = { }, onLoad() { -+ Services.scriptloader.loadSubScript("chrome://browser/content/ZenStartup.mjs", window); + Services.scriptloader.loadSubScript("chrome://browser/content/zenThemeModifier.js", window); gBrowser.addEventListener("DOMUpdateBlockedPopups", e => PopupBlockerObserver.handleEvent(e) diff --git a/src/browser/base/content/browser-xhtml.patch b/src/browser/base/content/browser-xhtml.patch index b48fbbec5..b071b2c5d 100644 --- a/src/browser/base/content/browser-xhtml.patch +++ b/src/browser/base/content/browser-xhtml.patch @@ -1,5 +1,5 @@ diff --git a/browser/base/content/browser.xhtml b/browser/base/content/browser.xhtml -index 8f8c5536cb6e54300897180ca3f950974c60e930..403f821f561a2dfcf6ad23db7e61712aac867716 100644 +index 8f8c5536cb6e54300897180ca3f950974c60e930..78076e29faf749b83d6c8e099af6767621f34d58 100644 --- a/browser/base/content/browser.xhtml +++ b/browser/base/content/browser.xhtml @@ -26,6 +26,7 @@ @@ -10,19 +10,18 @@ index 8f8c5536cb6e54300897180ca3f950974c60e930..403f821f561a2dfcf6ad23db7e61712a persist="screenX screenY width height sizemode" data-l10n-sync="true"> -@@ -105,8 +106,11 @@ +@@ -105,8 +106,10 @@ +#include zen-preloaded.inc.xhtml -+ +#include zen-assets.inc.xhtml # All sets except for popupsets (commands, keys, and stringbundles) -@@ -128,9 +132,11 @@ +@@ -128,9 +131,11 @@ diff --git a/src/browser/base/content/zen-assets.inc.xhtml b/src/browser/base/content/zen-assets.inc.xhtml index 18f8a70fa..c7fc7c4a9 100644 --- a/src/browser/base/content/zen-assets.inc.xhtml +++ b/src/browser/base/content/zen-assets.inc.xhtml @@ -1,3 +1,7 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + #include zen-locales.inc.xhtml # Styles used all over the browser @@ -28,16 +32,26 @@ +# Startup "preloaded" scripts that requre globals such as gBrowser and gURLBar +# JS files which are needed by browser.xhtml but no other top level windows to +# support MacOS specific features should be loaded directly from browser-main.js +# rather than this file. +# +# If you update this list, you may need to add a mapping within the following +# file so that ESLint works correctly: +# tools/lint/eslint/eslint-plugin-mozilla/lib/environments/browser-window.js + + # Scripts used all over the browser - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/src/browser/base/content/zen-assets.jar.inc.mn b/src/browser/base/content/zen-assets.jar.inc.mn index 131d55435..3ae8605b0 100644 --- a/src/browser/base/content/zen-assets.jar.inc.mn +++ b/src/browser/base/content/zen-assets.jar.inc.mn @@ -1,11 +1,14 @@ - +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. content/browser/zenThemeModifier.js (../../zen/common/zenThemeModifier.js) content/browser/ZenStartup.mjs (../../zen/common/ZenStartup.mjs) + content/browser/ZenPreloadedScripts.js (../../zen/common/ZenPreloadedScripts.js) content/browser/zen-sets.js (../../zen/common/zen-sets.js) content/browser/ZenUIManager.mjs (../../zen/common/ZenUIManager.mjs) content/browser/zen-components/ZenActorsManager.mjs (../../zen/common/ZenActorsManager.mjs) - content/browser/zen-components/ZenEmojis.mjs (../../zen/common/ZenEmojis.mjs) + content/browser/zen-components/ZenEmojis.mjs (../../zen/common/ZenEmojis.mjs) content/browser/ZenCustomizableUI.sys.mjs (../../zen/common/ZenCustomizableUI.sys.mjs) content/browser/zen-components/ZenUIMigration.mjs (../../zen/common/ZenUIMigration.mjs) content/browser/zen-components/ZenCommonUtils.mjs (../../zen/common/ZenCommonUtils.mjs) @@ -35,7 +38,7 @@ content/browser/zen-components/ZenViewSplitter.mjs (../../zen/split-view/ZenViewSplitter.mjs) content/browser/zen-styles/zen-decks.css (../../zen/split-view/zen-decks.css) - content/browser/zen-components/ZenMods.mjs (../../zen/mods/ZenMods.mjs) + content/browser/zen-components/ZenMods.mjs (../../zen/mods/ZenMods.mjs) content/browser/zen-components/ZenWorkspaceIcons.mjs (../../zen/workspaces/ZenWorkspaceIcons.mjs) content/browser/zen-components/ZenWorkspace.mjs (../../zen/workspaces/ZenWorkspace.mjs) @@ -80,7 +83,7 @@ content/browser/zen-images/note-indicator.svg (../../zen/images/note-indicator.svg) content/browser/zen-images/downloads/download.svg (../../zen/images/downloads/download.svg) - content/browser/zen-images/downloads/archive.svg (../../zen/images/downloads/archive.svg) + content/browser/zen-images/downloads/archive.svg (../../zen/images/downloads/archive.svg) # Fonts content/browser/zen-fonts/JunicodeVF-Italic.woff2 (../../zen/fonts/JunicodeVF-Italic.woff2) @@ -91,13 +94,13 @@ content/browser/zen-vendor/motion.min.mjs (../../zen/vendor/motion.min.mjs) # FavIcons for startup - content/browser/zen-images/favicons/calendar.ico (../../zen/images/favicons/calendar.ico) - content/browser/zen-images/favicons/discord.ico (../../zen/images/favicons/discord.ico) - content/browser/zen-images/favicons/figma.ico (../../zen/images/favicons/figma.ico) - content/browser/zen-images/favicons/github.ico (../../zen/images/favicons/github.ico) - content/browser/zen-images/favicons/notion.ico (../../zen/images/favicons/notion.ico) - content/browser/zen-images/favicons/obsidian.ico (../../zen/images/favicons/obsidian.ico) - content/browser/zen-images/favicons/slack.ico (../../zen/images/favicons/slack.ico) - content/browser/zen-images/favicons/reddit.ico (../../zen/images/favicons/reddit.ico) - content/browser/zen-images/favicons/x.ico (../../zen/images/favicons/x.ico) - content/browser/zen-images/favicons/trello.ico (../../zen/images/favicons/trello.ico) + content/browser/zen-images/favicons/calendar.ico (../../zen/images/favicons/calendar.ico) + content/browser/zen-images/favicons/discord.ico (../../zen/images/favicons/discord.ico) + content/browser/zen-images/favicons/figma.ico (../../zen/images/favicons/figma.ico) + content/browser/zen-images/favicons/github.ico (../../zen/images/favicons/github.ico) + content/browser/zen-images/favicons/notion.ico (../../zen/images/favicons/notion.ico) + content/browser/zen-images/favicons/obsidian.ico (../../zen/images/favicons/obsidian.ico) + content/browser/zen-images/favicons/slack.ico (../../zen/images/favicons/slack.ico) + content/browser/zen-images/favicons/reddit.ico (../../zen/images/favicons/reddit.ico) + content/browser/zen-images/favicons/x.ico (../../zen/images/favicons/x.ico) + content/browser/zen-images/favicons/trello.ico (../../zen/images/favicons/trello.ico) diff --git a/src/browser/base/content/zen-preloaded.inc.xhtml b/src/browser/base/content/zen-preloaded.inc.xhtml index 6f081c4de..dbf0730c6 100644 --- a/src/browser/base/content/zen-preloaded.inc.xhtml +++ b/src/browser/base/content/zen-preloaded.inc.xhtml @@ -10,4 +10,3 @@ - diff --git a/src/zen/common/ZenPreloadedScripts.js b/src/zen/common/ZenPreloadedScripts.js new file mode 100644 index 000000000..096a4eb88 --- /dev/null +++ b/src/zen/common/ZenPreloadedScripts.js @@ -0,0 +1,9 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +// prettier-ignore +// eslint-disable-next-line no-lone-blocks +{ + Services.scriptloader.loadSubScript("chrome://browser/content/ZenStartup.mjs", this); +} diff --git a/src/zen/common/ZenStartup.mjs b/src/zen/common/ZenStartup.mjs index fbda196d8..0c4ed723f 100644 --- a/src/zen/common/ZenStartup.mjs +++ b/src/zen/common/ZenStartup.mjs @@ -5,12 +5,11 @@ var ZenStartup = { _watermarkIgnoreElements: ['zen-browser-background', 'zen-toast-container'], - init() { + async init() { this.openWatermark(); - this._initBrowserBackground(); + await this._initBrowserBackground(); this._changeSidebarLocation(); this._zenInitBrowserLayout(); - this._initSearchBar(); }, _initBrowserBackground() { @@ -22,11 +21,10 @@ document.getElementById('browser').prepend(background); }, - _zenInitBrowserLayout() { + async _zenInitBrowserLayout() { if (this.__hasInitBrowserLayout) return; this.__hasInitBrowserLayout = true; try { - console.info('ZenThemeModifier: init browser layout'); const kNavbarItems = ['nav-bar', 'PersonalToolbar']; const kNewContainerId = 'zen-appcontent-navbar-container'; let newContainer = document.getElementById(kNewContainerId); @@ -46,7 +44,6 @@ this._hideUnusedElements(); gZenWorkspaces.init(); - gZenVerticalTabsManager.init(); gZenUIManager.init(); this._checkForWelcomePage(); @@ -78,6 +75,8 @@ gZenWorkspaces.promiseInitialized.then(async () => { await delayedStartupPromise; await SessionStore.promiseAllWindowsRestored; + delete gZenUIManager.promiseInitialized; + this._initSearchBar(); setTimeout(() => { gZenCompactModeManager.init(); setTimeout(() => { @@ -162,10 +161,6 @@ _initSearchBar() { // Only focus the url bar gURLBar.focus(); - - gURLBar._initCopyCutController(); - gURLBar._initPasteAndGo(); - gURLBar._initStripOnShare(); }, _checkForWelcomePage() { @@ -179,5 +174,11 @@ }, }; - ZenStartup.init(); + window.addEventListener( + 'MozBeforeInitialXULLayout', + () => { + ZenStartup.init(); + }, + { once: true } + ); } diff --git a/src/zen/common/ZenUIManager.mjs b/src/zen/common/ZenUIManager.mjs index 0def94ca0..84ea39a36 100644 --- a/src/zen/common/ZenUIManager.mjs +++ b/src/zen/common/ZenUIManager.mjs @@ -34,8 +34,6 @@ var gZenUIManager = { true ); - gURLBar._zenTrimURL = this.urlbarTrim.bind(this); - document.addEventListener('mousedown', this.handleMouseDown.bind(this), true); ChromeUtils.defineLazyGetter(this, 'motion', () => { @@ -48,6 +46,8 @@ var gZenUIManager = { return document.getElementById('zen-toast-container'); }); + gURLBar._zenTrimURL = this.urlbarTrim.bind(this); + new ResizeObserver(this.updateTabsToolbar.bind(this)).observe( document.getElementById('TabsToolbar') ); @@ -67,6 +67,7 @@ var gZenUIManager = { window.addEventListener('TabClose', this.onTabClose.bind(this)); gZenMediaController.init(); + gZenVerticalTabsManager.init(); }, handleMouseDown(event) { @@ -956,6 +957,10 @@ var gZenVerticalTabsManager = { gZenCompactModeManager.getAndApplySidebarWidth(); } gZenUIManager.updateTabsToolbar(); + + gURLBar._initCopyCutController(); + gURLBar._initPasteAndGo(); + gURLBar._initStripOnShare(); } catch (e) { console.error(e); } diff --git a/src/zen/kbs/ZenKeyboardShortcuts.mjs b/src/zen/kbs/ZenKeyboardShortcuts.mjs index 9feec1f7e..949e4464d 100644 --- a/src/zen/kbs/ZenKeyboardShortcuts.mjs +++ b/src/zen/kbs/ZenKeyboardShortcuts.mjs @@ -1019,8 +1019,6 @@ var gZenKeyboardShortcutsManager = { this._applyShortcuts(); await this._saveShortcuts(); - - console.info('Zen CKS: Initialized'); } }, diff --git a/src/zen/mods/ZenMods.mjs b/src/zen/mods/ZenMods.mjs index c63e69767..02116b3a8 100644 --- a/src/zen/mods/ZenMods.mjs +++ b/src/zen/mods/ZenMods.mjs @@ -21,8 +21,6 @@ }).format(new Date().getTime()); constructor() { - console.log('[ZenMods]: Initializing ZenMods module'); - super(); } diff --git a/src/zen/tests/glance/browser_glance_next_tab.js b/src/zen/tests/glance/browser_glance_next_tab.js index b14d3c3f9..ce006bad0 100644 --- a/src/zen/tests/glance/browser_glance_next_tab.js +++ b/src/zen/tests/glance/browser_glance_next_tab.js @@ -11,8 +11,8 @@ add_task(async function test_Glance_Next_Tab() { const tabToCheck = gBrowser.selectedTab; gBrowser.selectedTab = selectedTab; await openGlanceOnTab(async (glanceTab) => { - const next = gBrowser.tabContainer.findNextTab(glanceTab, { direction: 1 }); - Assert.equal(next, tabToCheck, 'Next glance tab should equal'); + gBrowser.tabContainer.advanceSelectedTab(1); + Assert.equal(gBrowser.selectedTab, tabToCheck, 'Next glance tab should equal'); }); await BrowserTestUtils.removeTab(gBrowser.selectedTab); }); diff --git a/src/zen/tests/glance/browser_glance_prev_tab.js b/src/zen/tests/glance/browser_glance_prev_tab.js index c2b90f016..5ff1cd723 100644 --- a/src/zen/tests/glance/browser_glance_prev_tab.js +++ b/src/zen/tests/glance/browser_glance_prev_tab.js @@ -10,8 +10,8 @@ add_task(async function test_Glance_Prev_Tab() { }); const tabToCheck = gBrowser.selectedTab; gBrowser.selectedTab = glanceTab; - const next = gBrowser.tabContainer.findNextTab(glanceTab, { direction: -1 }); - Assert.equal(next, tabToCheck, 'Previous glance tab should equal'); + gBrowser.tabContainer.advanceSelectedTab(-1); + Assert.equal(gBrowser.selectedTab, tabToCheck, 'Previous glance tab should equal'); await BrowserTestUtils.removeTab(tabToCheck); }); }); diff --git a/src/zen/tests/workspaces/browser.toml b/src/zen/tests/workspaces/browser.toml index c4c36f8b2..12d4c9027 100644 --- a/src/zen/tests/workspaces/browser.toml +++ b/src/zen/tests/workspaces/browser.toml @@ -7,3 +7,4 @@ support-files = [ ["browser_workspace_bookmarks.js"] ["browser_double_click_newtab.js"] ["browser_overflow_scrollbox.js"] +["browser_private_mode.js"] diff --git a/src/zen/tests/workspaces/browser_private_mode.js b/src/zen/tests/workspaces/browser_private_mode.js new file mode 100644 index 000000000..1bc02d42b --- /dev/null +++ b/src/zen/tests/workspaces/browser_private_mode.js @@ -0,0 +1,21 @@ +/* Any copyright is dedicated to the Public Domain. + https://creativecommons.org/publicdomain/zero/1.0/ */ + +'use strict'; + +add_task(async function testPrivateMode() { + await SpecialPowers.pushPrefEnv({ + set: [['privacy.userContext.enabled', true]], + }); + + let privateWindow = await BrowserTestUtils.openNewBrowserWindow({ + private: true, + }); + await privateWindow.gZenWorkspaces.promiseInitialized; + ok( + privateWindow.document.documentElement.hasAttribute('zen-workspace-id'), + 'Private window should have a zen-workspace-id attribute' + ); + + await BrowserTestUtils.closeWindow(privateWindow); +}); diff --git a/src/zen/workspaces/ZenWorkspaces.mjs b/src/zen/workspaces/ZenWorkspaces.mjs index a13dafc49..31e0aae52 100644 --- a/src/zen/workspaces/ZenWorkspaces.mjs +++ b/src/zen/workspaces/ZenWorkspaces.mjs @@ -42,7 +42,7 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { this._resolveInitialized = resolve; }); - async waitForPromises() { + async #waitForPromises() { if (this.privateWindowOrDisabled) { return; } @@ -116,6 +116,9 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { window.addEventListener('resize', this.onWindowResize.bind(this)); this.addPopupListeners(); + await this.#waitForPromises(); + await this._workspaces(); + await this.afterLoadInit(); } @@ -294,7 +297,6 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { return; } this._pinnedTabsResizeObserver = new ResizeObserver(this.onPinnedTabsResize.bind(this)); - await this.waitForPromises(); await this._createDefaultWorkspaceIfNeeded(); } @@ -738,11 +740,12 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { get shouldHaveWorkspaces() { if (typeof this._shouldHaveWorkspaces === 'undefined') { - let docElement = document.documentElement; - this._shouldHaveWorkspaces = !( - docElement.getAttribute('chromehidden').includes('toolbar') || - docElement.getAttribute('chromehidden').includes('menubar') - ); + let chromeFlags = docShell.treeOwner + .QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIAppWindow).chromeFlags; + this._shouldHaveWorkspaces = + chromeFlags & Ci.nsIWebBrowserChrome.CHROME_TOOLBAR || + chromeFlags & Ci.nsIWebBrowserChrome.CHROME_MENUBAR; return this._shouldHaveWorkspaces; } return this._shouldHaveWorkspaces; @@ -851,7 +854,7 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { await this.workspaceBookmarks(); await gZenPinnedTabManager.refreshPinnedTabs({ init: true }); await this.changeWorkspace(activeWorkspace, { onInit: true }); - await this._selectStartPage(); + await this.#selectStartPage(); this._fixTabPositions(); this._resolveInitialized(); this._clearAnyZombieTabs(); // Dont call with await @@ -868,7 +871,7 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { window.addEventListener('TabBrowserInserted', this.onTabBrowserInserted.bind(this)); } - async _selectStartPage() { + async #selectStartPage() { if (gZenUIManager.testingEnabled) { return; } @@ -2017,7 +2020,7 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { ) { delete this._alwaysAnimatePaddingTop; const essentialsHeight = essentialContainer.getBoundingClientRect().height; - if (!forAnimation && animateContainer) { + if (!forAnimation && animateContainer && gZenUIManager.motion) { gZenUIManager.motion.animate( workspaceElement, {