Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- Manifest: dom/base/test/useractivation/chrome.toml
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Popup blocker a target=_blank</title>
</head>
<body>
<button>click</button>
<script>
const {BrowserTestUtils} = ChromeUtils.importESModule(
);
const gBrowser = Services.wm.getMostRecentWindow("navigator:browser").gBrowser;
add_task(async function() {
SpecialPowers.wrap(document).notifyUserGestureActivation();
let button = document.querySelector("button");
const promise = new Promise(resolve => {
button.addEventListener("click", () => {
document.querySelector("a").dispatchEvent(
new PointerEvent("click", {
bubbles: true,
cancelable: true,
view: window,
})
);
BrowserTestUtils.waitForNewTab(gBrowser, null, true).then(function(aNewTab) {
ok(true, "A new tab was opened");
BrowserTestUtils.removeTab(aNewTab);
resolve();
});
});
});
button.dispatchEvent(new PointerEvent("click", {
bubbles: true,
cancelable: true,
view: window,
}));
await promise;
});
</script>
</body>