tor-browser

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

commit 4bcd0de36d96bcfb977505cb0c430e9eea58dc94
parent 1f4eaf271e480f382fc90e815c393bdeb09a80a5
Author: Nick Grato <ngrato@gmail.com>
Date:   Fri,  9 Jan 2026 00:41:37 +0000

Bug 2008872 - Create flag for sidebar vs fullpage UX in AI window r=Mardak,ai-frontend-reviewers

We will need to show and hide different elements in the sidebar vs fullpage ai wind user experience. This work looks the URL of the html chrome to get a location flag and sets the 'mode' to the ai window

Differential Revision: https://phabricator.services.mozilla.com/D278074

Diffstat:
Mbrowser/components/aiwindow/ui/components/ai-window/ai-window.mjs | 16++++++++++++++++
Mbrowser/components/aiwindow/ui/modules/AIWindow.sys.mjs | 2+-
Mbrowser/components/aiwindow/ui/modules/AIWindowUI.sys.mjs | 5++---
Mbrowser/components/aiwindow/ui/test/browser/browser_open_aiwindow.js | 32++++++++++++++++++++++++++++++++
Mdom/security/DOMSecurityMonitor.cpp | 1+
5 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/browser/components/aiwindow/ui/components/ai-window/ai-window.mjs b/browser/components/aiwindow/ui/components/ai-window/ai-window.mjs @@ -29,23 +29,34 @@ ChromeUtils.defineLazyGetter(lazy, "log", function () { }); }); +const FULLPAGE = "fullpage"; +const SIDEBAR = "sidebar"; + /** * A custom element for managing AI Window */ export class AIWindow extends MozLitElement { static properties = { userPrompt: { type: String }, + mode: { type: String }, // sidebar | fullpage }; #browser; #conversation; + #detectModeFromContext() { + return window.browsingContext?.embedderElement?.id === "ai-window-browser" + ? SIDEBAR + : FULLPAGE; + } + constructor() { super(); this.userPrompt = ""; this.#browser = null; this.#conversation = new lazy.ChatConversation({}); + this.mode = this.#detectModeFromContext(); } connectedCallback() { @@ -251,6 +262,11 @@ export class AIWindow extends MozLitElement { <moz-button type="primary" size="small" @click=${this.#handleSubmit}> Submit mock prompt </moz-button> + + <!-- TODO : Example of mode-based rendering --> + ${this.mode === FULLPAGE + ? html`<div>Fullpage Footer Content</div>` + : ""} </div> `; } diff --git a/browser/components/aiwindow/ui/modules/AIWindow.sys.mjs b/browser/components/aiwindow/ui/modules/AIWindow.sys.mjs @@ -5,7 +5,7 @@ */ import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; -const AIWINDOW_URL = "chrome://browser/content/aiwindow/aiWindow.html"; +export const AIWINDOW_URL = "chrome://browser/content/aiwindow/aiWindow.html"; const AIWINDOW_URI = Services.io.newURI(AIWINDOW_URL); const FIRSTRUN_URL = "chrome://browser/content/aiwindow/firstrun.html"; const FIRSTRUN_URI = Services.io.newURI(FIRSTRUN_URL); diff --git a/browser/components/aiwindow/ui/modules/AIWindowUI.sys.mjs b/browser/components/aiwindow/ui/modules/AIWindowUI.sys.mjs @@ -4,8 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -const AIWINDOW_SIDEBAR_URL = - "chrome://browser/content/aiwindow/aiWindow.html#mode=sidebar"; +import { AIWINDOW_URL } from "moz-src:///browser/components/aiwindow/ui/modules/AIWindow.sys.mjs"; export const AIWindowUI = { BOX_ID: "ai-window-box", @@ -60,7 +59,7 @@ export const AIWindowUI = { browser.setAttribute("disablehistory", "true"); browser.setAttribute("disablefullscreen", "true"); browser.setAttribute("tooltip", "aHTMLTooltip"); - browser.setAttribute("src", AIWINDOW_SIDEBAR_URL); + browser.setAttribute("src", AIWINDOW_URL); stack.appendChild(browser); return browser; }, diff --git a/browser/components/aiwindow/ui/test/browser/browser_open_aiwindow.js b/browser/components/aiwindow/ui/test/browser/browser_open_aiwindow.js @@ -190,6 +190,38 @@ add_task(async function test_openNewBrowserWindow_and_ai_inherit() { await SpecialPowers.popPrefEnv(); }); +/** + * Test AI window mode detection in aiWindow.html + */ +add_task(async function test_aiwindow_html_mode_detection() { + await SpecialPowers.pushPrefEnv({ + set: [["browser.aiwindow.enabled", true]], + }); + + // Open aiWindow.html directly + await BrowserTestUtils.withNewTab( + "chrome://browser/content/aiwindow/aiWindow.html", + async browser => { + await SpecialPowers.spawn(browser, [], async () => { + await content.customElements.whenDefined("ai-window"); + + const aiWindowElement = content.document.querySelector("ai-window"); + Assert.ok(aiWindowElement, "ai-window element should exist"); + + // Check that mode is detected (should be FULLPAGE when loaded directly) + info(`aiWindowElement.mode: ${aiWindowElement.mode}`); + Assert.strictEqual( + aiWindowElement.mode, + "fullpage", + `Mode should be detected as fullpage, got: ${aiWindowElement.mode}` + ); + }); + } + ); + + await SpecialPowers.popPrefEnv(); +}); + function checkMenuItemVisibility( aiWindowEnabled, aiOpenerButton, diff --git a/dom/security/DOMSecurityMonitor.cpp b/dom/security/DOMSecurityMonitor.cpp @@ -70,6 +70,7 @@ void DOMSecurityMonitor::AuditParsingOfHTMLXMLFragments( "resource://devtools/client/shared/widgets/Spectrum.js"_ns, "resource://gre/modules/narrate/VoiceSelect.sys.mjs"_ns, "chrome://global/content/vendor/react-dom.js"_ns, + "chrome://browser/content/aiwindow/aiwindow.html"_ns, // ------------------------------------------------------------------ // test pages // ------------------------------------------------------------------