Skip to content

Commit

Permalink
Bug 1836224 - A click on the "learn more" link in the panel should cl…
Browse files Browse the repository at this point in the history
…ose it. r=zombie

Differential Revision: https://phabricator.services.mozilla.com/D179649
  • Loading branch information
willdurand committed Jun 1, 2023
1 parent c948c8a commit f7475b0
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
5 changes: 5 additions & 0 deletions browser/base/content/browser-addons.js
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,11 @@ var gUnifiedExtensions = {
supportPage: "quarantined-domains",
dismissable: false,
});
this._messageBarQuarantinedDomain
.querySelector("a")
.addEventListener("click", () => {
this.togglePanel();
});
}

container.appendChild(this._messageBarQuarantinedDomain);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,90 @@ add_task(async function test_quarantined_domain_message() {
await extension.unload();
await SpecialPowers.popPrefEnv();
});

add_task(async function test_quarantined_domain_message_learn_more_link() {
const quarantinedDomain = "example.org";
await SpecialPowers.pushPrefEnv({
set: [
["extensions.quarantinedDomains.enabled", true],
["extensions.quarantinedDomains.list", quarantinedDomain],
],
});

// Load an extension that will have access to all domains, including the
// quarantined domain.
const extension = ExtensionTestUtils.loadExtension({
manifest: {
permissions: ["activeTab"],
browser_action: {},
},
});
await extension.startup();

const expectedSupportURL =
Services.urlFormatter.formatURLPref("app.support.baseURL") +
"quarantined-domains";

// We expect the SUMO page to be open in a new tab and the panel to be closed
// when the user clicks on the "learn more" link.
await BrowserTestUtils.withNewTab(
{ gBrowser, url: `https://${quarantinedDomain}/` },
async () => {
await openExtensionsPanel();
const messages = getMessageBars();
Assert.equal(messages.length, 1, "expected a message");

const [message] = messages;
verifyMessageBar(message);

const tabPromise = BrowserTestUtils.waitForNewTab(
gBrowser,
expectedSupportURL
);
const hidden = BrowserTestUtils.waitForEvent(
gUnifiedExtensions.panel,
"popuphidden",
true
);
message.querySelector("a").click();
const [tab] = await Promise.all([tabPromise, hidden]);
BrowserTestUtils.removeTab(tab);
}
);

// Same as above but with keyboard navigation.
await BrowserTestUtils.withNewTab(
{ gBrowser, url: `https://${quarantinedDomain}/` },
async () => {
await openExtensionsPanel();
const messages = getMessageBars();
Assert.equal(messages.length, 1, "expected a message");

const [message] = messages;
verifyMessageBar(message);

const supportLink = message.querySelector("a");

// Focus the "learn more" (support) link.
const focused = BrowserTestUtils.waitForEvent(supportLink, "focus");
EventUtils.synthesizeKey("VK_TAB", {});
await focused;

const tabPromise = BrowserTestUtils.waitForNewTab(
gBrowser,
expectedSupportURL
);
const hidden = BrowserTestUtils.waitForEvent(
gUnifiedExtensions.panel,
"popuphidden",
true
);
EventUtils.synthesizeKey("KEY_Enter", {});
const [tab] = await Promise.all([tabPromise, hidden]);
BrowserTestUtils.removeTab(tab);
}
);

await extension.unload();
await SpecialPowers.popPrefEnv();
});

0 comments on commit f7475b0

Please sign in to comment.