commit 5a4a19e0909b3c15f73c09f422234fd293fdaa8e
parent 1a15dddae70fb557d1558358d87ae1147247f66c
Author: Yubin Jamora <yjamora@mozilla.com>
Date: Fri, 12 Dec 2025 23:46:39 +0000
Bug 2001725 - Restoring link-paragraph handling so Privacy/Terms links open in chatbot onboarding r=Mardak,ai-frontend-reviewers,Gijs
Differential Revision: https://phabricator.services.mozilla.com/D275024
Diffstat:
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/browser/components/genai/chat.js b/browser/components/genai/chat.js
@@ -505,6 +505,19 @@ function showOnboarding(length) {
link.setAttribute("value", name);
}
document.l10n.setAttributes(links, config.linksId);
+
+ const handleLink = ev => {
+ const { href } = ev.target;
+ if (href) {
+ ev.preventDefault();
+ openLink(href);
+ }
+ };
+
+ if (!links._listenerAdded) {
+ links?.addEventListener("click", handleLink);
+ links._listenerAdded = true;
+ }
}
break;
diff --git a/browser/components/genai/tests/browser/browser_chat_sidebar.js b/browser/components/genai/tests/browser/browser_chat_sidebar.js
@@ -1,6 +1,10 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
+const { sinon } = ChromeUtils.importESModule(
+ "resource://testing-common/Sinon.sys.mjs"
+);
+
ChromeUtils.defineESModuleGetters(this, {
PlacesTestUtils: "resource://testing-common/PlacesTestUtils.sys.mjs",
});
@@ -96,7 +100,8 @@ add_task(async function test_sidebar_onboarding() {
Services.fog.testResetFOG();
await SidebarController.show("viewGenaiChatSidebar");
- const { document, browserPromise } = SidebarController.browser.contentWindow;
+ const win = SidebarController.browser.contentWindow;
+ const { document, browserPromise } = win;
const label = await TestUtils.waitForCondition(() =>
document.querySelector("label:has(.localhost)")
);
@@ -117,6 +122,18 @@ add_task(async function test_sidebar_onboarding() {
"Should have previewed provider"
);
+ const link = await TestUtils.waitForCondition(() =>
+ document.querySelector(".link-paragraph a")
+ );
+ const expectedURL = link.href;
+
+ const stub = sinon.stub(win, "openLink");
+
+ link.click();
+
+ Assert.ok(stub.calledOnce, "openLink should call once");
+ Assert.equal(stub.firstCall.args[0], expectedURL);
+
const pickButton = await TestUtils.waitForCondition(() =>
document.querySelector(".chat_pick .primary:not([disabled])")
);