Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

/* Any copyright is dedicated to the Public Domain.
add_task(async function test_inner_no_href_handling() {
await BrowserTestUtils.withNewTab(
async function (browser) {
await SpecialPowers.spawn(browser, [], async function () {
let outer = content.document.createElement("a");
outer.href = "https://example.com/outer";
const inner = content.document.createElement("a");
inner.href = "https://example.com/inner";
const button = content.document.createElement("a"); // deliberately NO href
button.setAttribute("role", "button");
const label = content.document.createElement("span");
label.id = "clickme";
label.textContent = "View page";
button.appendChild(label);
inner.appendChild(button);
outer.appendChild(inner);
content.document.body.appendChild(outer);
});
let newTabPromise = BrowserTestUtils.waitForNewTab(gBrowser, null, true);
await BrowserTestUtils.synthesizeMouseAtCenter(
"#clickme",
{ accelKey: true },
browser
);
let newTab = await newTabPromise;
is(
newTab.linkedBrowser.currentURI.spec,
"Should have opened the inner link in a new tab"
);
gBrowser.removeTab(newTab);
}
);
});