tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 829ced506c51e402d7face2e7a52069a953a3cff
parent 2c71cdfa065c4b0fe9d0c598f3896459e569e4e2
Author: Atila Butkovits <abutkovits@mozilla.com>
Date:   Wed,  7 Jan 2026 22:30:51 +0200

Revert "Bug 2006469 - Create AI Window switcher button r=ai-frontend-reviewers,fluent-reviewers,desktop-theme-reviewers,sessionstore-reviewers,bolsson,sthompson,Mardak,emilio" for causing failures complaining about content/browser.xhtml.

This reverts commit 25be877347b64b0fc9a1587c33b6b72e6e7876b5.

Diffstat:
Mbrowser/base/content/appmenu-viewcache.inc.xhtml | 13-------------
Mbrowser/base/content/navigator-toolbox.inc.xhtml | 7-------
Mbrowser/components/aiwindow/ui/modules/AIWindow.sys.mjs | 113++++++++-----------------------------------------------------------------------
Mbrowser/components/aiwindow/ui/test/browser/browser.toml | 2--
Dbrowser/components/aiwindow/ui/test/browser/browser_aiwindow_switcher.js | 119-------------------------------------------------------------------------------
Mbrowser/components/customizableui/content/panelUI.js | 8--------
Mbrowser/components/sessionstore/SessionStore.sys.mjs | 2--
Mbrowser/locales-preview/aiWindow.ftl | 22----------------------
Mbrowser/themes/shared/browser-shared.css | 53-----------------------------------------------------
Dbrowser/themes/shared/icons/ai-window.svg | 23-----------------------
Mbrowser/themes/shared/jar.inc.mn | 1-
Mtoolkit/modules/LightweightThemeConsumer.sys.mjs | 44+++++++++++++-------------------------------
12 files changed, 24 insertions(+), 383 deletions(-)

diff --git a/browser/base/content/appmenu-viewcache.inc.xhtml b/browser/base/content/appmenu-viewcache.inc.xhtml @@ -856,18 +856,5 @@ <vbox id="PanelUI-ipprotection-site-settings-content" class="panel-subview-body"/> </panelview> - <panelview id="ai-window-toggle-view" class="PanelUI-subView"> - <vbox class="panel-subview-body"> - <toolbarbutton id="ai-window-switch-classic" - class="subviewbutton" - data-l10n-id="ai-window-toggleview-switch-classic" - hidden="true"/> - <toolbarbutton id="ai-window-switch-ai" - class="subviewbutton" - data-l10n-id="ai-window-toggleview-switch-ai" - hidden="true"/> - </vbox> - </panelview> - #include ../../components/reportbrokensite/content/reportBrokenSitePanel.inc.xhtml </html:template> diff --git a/browser/base/content/navigator-toolbox.inc.xhtml b/browser/base/content/navigator-toolbox.inc.xhtml @@ -104,13 +104,6 @@ <hbox class="titlebar-spacer" type="post-tabs"/> #include private-browsing-indicator.inc.xhtml - - <toolbarbutton id="ai-window-toggle" - class="toolbarbutton-1 chromeclass-toolbar-additional" - data-l10n-id="toolbar-button-ai-window-toggle" - cui-areatype="toolbar" - removable="false"/> - <toolbarbutton class="content-analysis-indicator toolbarbutton-1 content-analysis-indicator-icon"/> #include titlebar-items.inc.xhtml diff --git a/browser/components/aiwindow/ui/modules/AIWindow.sys.mjs b/browser/components/aiwindow/ui/modules/AIWindow.sys.mjs @@ -10,13 +10,11 @@ const AIWINDOW_URI = Services.io.newURI(AIWINDOW_URL); const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { - AIWindowMenu: - "moz-src:///browser/components/aiwindow/ui/modules/AIWindowMenu.sys.mjs", ChatStore: "moz-src:///browser/components/aiwindow/ui/modules/ChatStore.sys.mjs", - PanelMultiView: - "moz-src:///browser/components/customizableui/PanelMultiView.sys.mjs", - PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs", + + AIWindowMenu: + "moz-src:///browser/components/aiwindow/ui/modules/AIWindowMenu.sys.mjs", }); /** @@ -33,33 +31,21 @@ export const AIWindow = { */ init(win) { - if (!this._windowStates.has(win)) { - this._windowStates.set(win, {}); - this.initializeAITabsToolbar(win); - } - if (this._initialized) { return; } - ChromeUtils.defineLazyGetter( - AIWindow, - "chatStore", - () => new lazy.ChatStore() + XPCOMUtils.defineLazyPreferenceGetter( + this, + "AIWindowEnabled", + "browser.aiwindow.enabled", + false ); - this._initialized = true; - }, - _onAIWindowEnabledPrefChange() { - for (let win of this._windowStates.keys()) { - this._updateButtonVisibility(win); - } - }, + ChromeUtils.defineLazyGetter(this, "chatStore", () => new lazy.ChatStore()); - _updateButtonVisibility(win) { - const isPrivateWindow = lazy.PrivateBrowsingUtils.isWindowPrivate(win); - const modeSwitcherButton = win.document.getElementById("ai-window-toggle"); - modeSwitcherButton.hidden = !this.isAIWindowEnabled() || isPrivateWindow; + this._initialized = true; + this._windowStates.set(win, {}); }, /** @@ -114,67 +100,6 @@ export const AIWindow = { }, /** - * Show Window Switcher button in tabs toolbar - * - * @param {object} win caller window - */ - handleAIWindowSwitcher(win) { - let view = lazy.PanelMultiView.getViewNode( - win.document, - "ai-window-toggle-view" - ); - - const isPrivateWindow = lazy.PrivateBrowsingUtils.isWindowPrivate(win); - - if (!isPrivateWindow) { - view.querySelector("#ai-window-switch-classic").hidden = false; - view.querySelector("#ai-window-switch-ai").hidden = false; - } - - let windowState = this._windowStates.get(win); - if (!windowState) { - windowState = {}; - this._windowStates.set(win, windowState); - } - - if (windowState.viewInitialized) { - return; - } - - view.addEventListener("command", event => { - switch (event.target.id) { - case "ai-window-switch-classic": - this.toggleAIWindow(win, false); - break; - case "ai-window-switch-ai": - this.toggleAIWindow(win, true); - break; - } - }); - - windowState.viewInitialized = true; - }, - - /** - * Show Window Switcher button in tabs toolbar - * - * @param {Window} win caller window - */ - initializeAITabsToolbar(win) { - const modeSwitcherButton = win.document.getElementById("ai-window-toggle"); - this._updateButtonVisibility(win); - - modeSwitcherButton.addEventListener("command", event => { - if (win.PanelUI.panel.state == "open") { - win.PanelUI.hide(); - } else if (win.PanelUI.panel.state == "closed") { - this.handleAIWindowSwitcher(win); - win.PanelUI.showSubView("ai-window-toggle-view", event.target, event); - } - }); - }, - - /** * Is current window an AI Window * * @param {Window} win current Window @@ -241,20 +166,4 @@ export const AIWindow = { get newTabURL() { return AIWINDOW_URL; }, - - async toggleAIWindow(win, isTogglingToAIWindow) { - let isActive = this.isAIWindowActive(win); - if (isActive != isTogglingToAIWindow) { - win.document.documentElement.toggleAttribute("ai-window"); - Services.obs.notifyObservers(win, "ai-window-state-changed"); - } - }, }; - -XPCOMUtils.defineLazyPreferenceGetter( - AIWindow, - "AIWindowEnabled", - "browser.aiwindow.enabled", - false, - AIWindow._onAIWindowEnabledPrefChange.bind(AIWindow) -); diff --git a/browser/components/aiwindow/ui/test/browser/browser.toml b/browser/components/aiwindow/ui/test/browser/browser.toml @@ -13,8 +13,6 @@ support-files = [ ["browser_aiwindow_integration.js"] -["browser_aiwindow_switcher.js"] - ["browser_aiwindow_transparency.js"] ["browser_aiwindowui.js"] diff --git a/browser/components/aiwindow/ui/test/browser/browser_aiwindow_switcher.js b/browser/components/aiwindow/ui/test/browser/browser_aiwindow_switcher.js @@ -1,119 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -"use strict"; - -// Ensure Window Switcher button is visible when AI Window is enabled in prefs -add_task(async function test_window_switcher_button_visibility() { - await SpecialPowers.pushPrefEnv({ - set: [["browser.aiwindow.enabled", false]], - }); - - let button = document.getElementById("ai-window-toggle"); - Assert.ok( - button?.hidden, - "Window switcher button should be hidden when AI Window is disabled" - ); - - await SpecialPowers.popPrefEnv(); - - await SpecialPowers.pushPrefEnv({ - set: [["browser.aiwindow.enabled", true]], - }); - - button = document.getElementById("ai-window-toggle"); - Assert.ok( - button && !button.hidden, - "Window switcher button should be visible when AI Window is enabled" - ); - - await SpecialPowers.popPrefEnv(); -}); - -// if (browser.aiwindow.enabled) Classic Window should switch to AI Window on click -add_task(async function test_switch_to_ai_window() { - await SpecialPowers.pushPrefEnv({ - set: [["browser.aiwindow.enabled", true]], - }); - - if (document.documentElement.hasAttribute("ai-window")) { - document.documentElement.removeAttribute("ai-window"); - } - - let button = document.getElementById("ai-window-toggle"); - let view = PanelMultiView.getViewNode(document, "ai-window-toggle-view"); - - let viewShownPromise = BrowserTestUtils.waitForEvent(view, "ViewShown"); - button.click(); - await viewShownPromise; - - let aiButton = view.querySelector("#ai-window-switch-ai"); - aiButton.click(); - - await TestUtils.waitForCondition( - () => document.documentElement.hasAttribute("ai-window"), - "Window should have ai-window attribute after switching" - ); - - Assert.ok( - document.documentElement.hasAttribute("ai-window"), - "Window should be in AI Window mode" - ); - - let iconListImage = window.getComputedStyle(button)["list-style-image"]; - Assert.ok( - iconListImage.includes("ai-window.svg"), - "Button icon should change to AI Window icon" - ); - - await TestUtils.waitForCondition( - () => PanelUI.panel.state === "closed", - "Panel should close after switching" - ); - - await SpecialPowers.popPrefEnv(); -}); - -// if (browser.aiwindow.enabled) AI Window should switch to Classic Window on click -add_task(async function test_switch_to_classic_window() { - await SpecialPowers.pushPrefEnv({ - set: [["browser.aiwindow.enabled", true]], - }); - - if (!document.documentElement.hasAttribute("ai-window")) { - document.documentElement.setAttribute("ai-window", ""); - } - - let button = document.getElementById("ai-window-toggle"); - let view = PanelMultiView.getViewNode(document, "ai-window-toggle-view"); - - let viewShownPromise = BrowserTestUtils.waitForEvent(view, "ViewShown"); - button.click(); - await viewShownPromise; - - let classicButton = view.querySelector("#ai-window-switch-classic"); - classicButton.click(); - - await TestUtils.waitForCondition( - () => !document.documentElement.hasAttribute("ai-window"), - "Window should not have ai-window attribute after switching" - ); - - Assert.ok( - !document.documentElement.hasAttribute("ai-window"), - "Window should be in Classic Window mode" - ); - - let iconListImage = window.getComputedStyle(button)["list-style-image"]; - Assert.ok( - iconListImage.includes("icon32.png"), - "Button icon should change to Classic Window icon" - ); - - await TestUtils.waitForCondition( - () => PanelUI.panel.state === "closed", - "Panel should close after switching" - ); - - await SpecialPowers.popPrefEnv(); -}); diff --git a/browser/components/customizableui/content/panelUI.js b/browser/components/customizableui/content/panelUI.js @@ -53,7 +53,6 @@ const PanelUI = { this.menuButton.addEventListener("mousedown", this); this.menuButton.addEventListener("keypress", this); - Services.obs.addObserver(this, "ai-window-state-changed"); Services.obs.addObserver(this, "fullscreen-nav-toolbox"); Services.obs.addObserver(this, "appMenu-notifications"); Services.obs.addObserver(this, "show-update-progress"); @@ -190,7 +189,6 @@ const PanelUI = { } } - Services.obs.removeObserver(this, "ai-window-state-changed"); Services.obs.removeObserver(this, "fullscreen-nav-toolbox"); Services.obs.removeObserver(this, "appMenu-notifications"); Services.obs.removeObserver(this, "show-update-progress"); @@ -276,12 +274,6 @@ const PanelUI = { observe(subject, topic, status) { switch (topic) { - case "ai-window-state-changed": - if (subject == window) { - this._showAIMenuItem(); - } - break; - case "fullscreen-nav-toolbox": if (this._notifications) { this.updateNotifications(false); diff --git a/browser/components/sessionstore/SessionStore.sys.mjs b/browser/components/sessionstore/SessionStore.sys.mjs @@ -5510,8 +5510,6 @@ var SessionStoreInternal = { if (workspaceID) { winData.workspaceID = workspaceID; } - - winData.isAIWindow = lazy.AIWindow.isAIWindowActiveAndEnabled(aWindow); }, /** diff --git a/browser/locales-preview/aiWindow.ftl b/browser/locales-preview/aiWindow.ftl @@ -22,28 +22,6 @@ menu-history-chats = menu-history-chats-recent = .label = Recent Chats -## AI Window Toggle Button - -toolbar-button-ai-window-toggle = - .label = AI window - .tooltiptext = Switch between AI and Classic windows. - -ai-window-toggleview-switch-classic = - .label = Classic Window - -ai-window-toggleview-switch-ai = - .label = AI Window - -ai-window-toggleview-switch-private = - .label = Private Window - -ai-window-toggleview-open-private = - .label = Open New Private Window - -ai-window-toggleview-status-label-active = AI Window - -ai-window-toggleview-status-label-inactive = Classic Window - ## Input CTA aiwindow-input-cta-label-chat = Chat diff --git a/browser/themes/shared/browser-shared.css b/browser/themes/shared/browser-shared.css @@ -1403,59 +1403,6 @@ popupnotificationcontent { margin: 8px 16px 16px; } -/* AI Window Toggle Button */ - -#ai-window-toggle { - list-style-image: url("chrome://branding/content/icon32.png"); - padding-inline-end: var(--space-small); - border-radius: var(--border-radius-medium); - - :root[ai-window] & { - list-style-image: url("chrome://browser/skin/ai-window.svg"); - } - - > .toolbarbutton-icon { - padding: 8px; - } -} - -#ai-window-switch-classic, -#ai-window-switch-ai { - &:hover { - background-color: var(--button-background-color-ghost-hover); - } - - .toolbarbutton-icon { - margin-inline-end: var(--space-small); - width: var(--icon-size-medium); - height: var(--icon-size-medium); - } - - &::after { - content: url("chrome://global/skin/icons/check.svg"); - -moz-context-properties: fill; - fill: currentColor; - width: 16px; - height: 16px; - } -} - -#ai-window-switch-classic { - list-style-image: url("chrome://branding/content/icon32.png"); - - :root[ai-window] &::after { - display: none; - } -} - -#ai-window-switch-ai { - list-style-image: url("chrome://browser/skin/ai-window.svg"); - - :root:not([ai-window]) &::after { - display: none; - } -} - /* Bookmarks roots menu-items */ #BMB_bookmarksToolbar, diff --git a/browser/themes/shared/icons/ai-window.svg b/browser/themes/shared/icons/ai-window.svg @@ -1,23 +0,0 @@ -<!-- 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/. --> -<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"> -<g clip-path="url(#clip0_11453_55577)"> -<mask id="mask0_11453_55577" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="1" y="1" width="20" height="20"> -<path d="M21 1H1V21H21V1Z" fill="white"/> -</mask> -<g mask="url(#mask0_11453_55577)"> -<path d="M4.375 3.828C4.30004 4.55294 4.39983 5.27806 4.67481 5.953C5.26223 5.29059 5.97475 4.7528 6.78711 4.37781C6.59964 5.05278 6.61251 5.77804 6.8125 6.453C6.89982 6.51537 6.9623 6.56521 7.03711 6.61511C7.16211 6.72761 7.31231 6.8657 7.61231 7.1532L7.6377 7.17761C8.31269 7.6526 9.0127 8.05321 9.7627 8.4032C9.52523 8.82803 9.16272 9.1657 8.71289 9.3407C6.24135 9.3407 5.81783 10.7841 5.8125 10.8026C5.9 11.4026 6.12481 11.9655 6.48731 12.453C6.84981 12.9405 7.32502 13.328 7.875 13.578C7.92498 13.603 7.97542 13.628 8.02539 13.6405C8.11262 13.6779 8.19988 13.7152 8.28711 13.7401C8.64956 13.8651 9.03737 13.9407 9.42481 13.9657C9.93828 14.0289 10.4564 13.9807 10.9453 13.8241C11.4027 14.2643 11.7801 14.7869 12.0527 15.371L13.2001 17.83C13.0388 17.8967 12.8757 17.9601 12.7099 18.0175C11.4559 18.4512 10.1273 18.5946 8.82129 18.4501C8.81819 18.4591 8.81558 18.4684 8.8125 18.4774C6.87515 18.2899 5.05015 17.453 3.6377 16.0907C1.98779 14.4908 1.0376 12.3156 1 10.0282V9.67761C1.02498 9.46521 1.03751 9.31527 1.0625 9.19031L1.08789 8.99011C1.13787 8.6528 1.1996 8.36534 1.22461 8.25281V8.203C1.44958 7.27813 1.84973 6.40293 2.41211 5.6405C2.66206 5.30308 2.93718 4.99025 3.22461 4.69031C3.48711 4.42781 3.77539 4.18992 4.08789 3.97742C4.17527 3.91508 4.27519 3.86544 4.375 3.828ZM14.8183 4.38855C14.8901 4.23466 15.1098 4.23466 15.1816 4.38855L16.2685 6.71863C16.785 7.8252 17.6746 8.71481 18.7812 9.23132L21.1113 10.3182C21.2652 10.3901 21.2652 10.6097 21.1113 10.6815L18.7812 11.7684C17.6746 12.2849 16.785 13.1746 16.2685 14.2811L15.1816 16.6112C15.1098 16.7651 14.8901 16.7651 14.8183 16.6112L13.7314 14.2811C13.2149 13.1746 12.3253 12.2849 11.2187 11.7684L8.88868 10.6815C8.73479 10.6097 8.73479 10.3901 8.88868 10.3182L11.2187 9.23132C12.3253 8.71481 13.2149 7.8252 13.7314 6.71863L14.8183 4.38855Z" fill="url(#paint0_linear_11453_55577)"/> -</g> -</g> -<defs> -<linearGradient id="paint0_linear_11453_55577" x1="5.48351" y1="4.6199" x2="23.4554" y2="7.02343" gradientUnits="userSpaceOnUse"> -<stop stop-color="#945AF2"/> -<stop offset="0.471154" stop-color="#F37E49"/> -<stop offset="1" stop-color="#FC4F43"/> -</linearGradient> -<clipPath id="clip0_11453_55577"> -<rect width="20" height="20" fill="white" transform="translate(1 1)"/> -</clipPath> -</defs> -</svg> diff --git a/browser/themes/shared/jar.inc.mn b/browser/themes/shared/jar.inc.mn @@ -179,7 +179,6 @@ skin/classic/browser/fxa/monitor.svg (../shared/fxa/monitor.svg) skin/classic/browser/add-circle-fill.svg (../shared/icons/add-circle-fill.svg) - skin/classic/browser/ai-window.svg (../shared/icons/ai-window.svg) skin/classic/browser/back.svg (../shared/icons/back.svg) skin/classic/browser/bookmark.svg (../shared/icons/bookmark.svg) skin/classic/browser/bookmark-12.svg (../shared/icons/bookmark-12.svg) diff --git a/toolkit/modules/LightweightThemeConsumer.sys.mjs b/toolkit/modules/LightweightThemeConsumer.sys.mjs @@ -241,14 +241,19 @@ export function LightweightThemeConsumer(aDocument) { this.forcedColorsMediaQuery = this._win.matchMedia("(forced-colors)"); this.forcedColorsMediaQuery.addListener(this); - this._aiWindowObserver = new this._win.MutationObserver(() => { - this.toggleAIWindowMode(this._win); - }); - this._aiWindowObserver.observe(this._doc.documentElement, { - attributeFilter: ["ai-window"], - }); - - this._update(lazy.LightweightThemeManager.themeData); + const manager = lazy.LightweightThemeManager; + const theme = + this._isAIWindow && manager.aiThemeData + ? manager.aiThemeData + : manager.themeData; + + this._update(theme); + + if (this._isAIWindow && !manager.aiThemeData) { + manager.promiseAIThemeData().then(() => { + this._update(manager.aiThemeData); + }); + } this._win.addEventListener("unload", this, { once: true }); } @@ -284,8 +289,6 @@ LightweightThemeConsumer.prototype = { case "unload": Services.obs.removeObserver(this, "lightweight-theme-styling-update"); Services.ppmm.sharedData.delete(`theme/${this._winId}`); - this._aiWindowObserver?.disconnect(); - this._aiWindowObserver = null; this._win = this._doc = null; this.darkThemeMediaQuery?.removeListener(this); this.darkThemeMediaQuery = null; @@ -296,18 +299,6 @@ LightweightThemeConsumer.prototype = { }, _update(themeData) { - if (this._isAIWindow) { - const manager = lazy.LightweightThemeManager; - if (manager.aiThemeData) { - themeData = manager.aiThemeData; - } else { - manager.promiseAIThemeData().then(() => { - if (this._isAIWindow) { - this._update(manager.aiThemeData); - } - }); - } - } this._lastData = themeData; let supportsDarkTheme = @@ -339,10 +330,6 @@ LightweightThemeConsumer.prototype = { return true; })(); - if (this._isAIWindow) { - updateGlobalThemeData = false; - } - let theme = useDarkTheme ? themeData.darkTheme : themeData.theme; let forcedColorsThemeOverride = this.FORCED_COLORS_OVERRIDE_ENABLED && @@ -507,11 +494,6 @@ LightweightThemeConsumer.prototype = { this._lastExperimentData.stylesheet = stylesheet; } }, - - toggleAIWindowMode(win) { - this._isAIWindow = win.document.documentElement.hasAttribute("ai-window"); - this._update(lazy.LightweightThemeManager.themeData); - }, }; function _getContentProperties(doc, hasTheme, data) {