commit 20e321d4d0ac7ea677abaf75948b474243a54b50
parent 53a95e432ac1fe6860cf550fdfba3c4de18910ea
Author: Mark Striemer <mstriemer@mozilla.com>
Date: Wed, 19 Nov 2025 22:25:17 +0000
Bug 2000010: Part 2 - Tests for moz-support-link as option in config-based-prefs r=mkennedy
Differential Revision: https://phabricator.services.mozilla.com/D272499
Diffstat:
1 file changed, 54 insertions(+), 0 deletions(-)
diff --git a/browser/components/preferences/tests/chrome/test_setting_control_options.html b/browser/components/preferences/tests/chrome/test_setting_control_options.html
@@ -408,6 +408,60 @@
"Rendered moz-box-button as the first nested control item"
);
});
+
+ add_task(async function testMozSupportLink() {
+ await SpecialPowers.pushPrefEnv({
+ set: [["app.support.baseURL", "https://support.example.com/"]],
+ });
+ Preferences.addSetting({
+ id: "testMozSupportLink",
+ get: () => true,
+ });
+ let itemConfig = {
+ id: "testMozSupportLink",
+ options: [
+ {
+ control: "a",
+ controlAttrs: {
+ href: "https://example.com/",
+ ".textContent": "Link text",
+ slot: "support-link",
+ },
+ },
+ {
+ control: "a",
+ controlAttrs: {
+ slot: "support-link",
+ is: "moz-support-link",
+ "support-page": "get-help",
+ },
+ },
+ ],
+ };
+ let control = await renderTemplate(itemConfig);
+ let [anchor, mozSupportLink] = control.controlEl.shadowRoot
+ .querySelector('slot[name="support-link"]')
+ .assignedNodes();
+
+ function assertLinkProperties(el, { href, text }) {
+ ok(el, "Got a link element");
+ is(el.href, href, "href is correct");
+ is(el.innerText, text, "text is correct");
+ }
+
+ assertLinkProperties(anchor, {
+ href: "https://example.com/",
+ text: "Link text",
+ });
+ assertLinkProperties(mozSupportLink, {
+ href: "https://support.example.com/get-help",
+ text: "Learn more",
+ });
+ ok(
+ mozSupportLink instanceof customElements.get("moz-support-link"),
+ "moz-support-link is a MozSupportLink"
+ );
+ });
</script>
</head>
<body>