Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/links/links-created-by-a-and-area-elements/target_blank_implicit_noopener.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>Test behavior of target=_blank links</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
</head>
<body>
<a href="support/target_blank_implicit_noopener.html?a1" id="a1" rel="noopener" target="_blank">Click me</a>
<a href="support/target_blank_implicit_noopener.html?a2" id="a2" rel="opener" target="_blank">Click me</a>
<a href="support/target_blank_implicit_noopener.html?a3" id="a3" target="_blank">Click me</a>
<a href="support/target_blank_implicit_noopener.html?a4" id="a4" rel="opener noopener" target="_blank">Click me</a>
<a href="support/target_blank_implicit_noopener.html?a5" id="a5" rel="noopener opener" target="_blank">Click me</a>
<a href="support/target_blank_implicit_noopener.html?a6" id="a6" rel="noreferrer" target="_blank">Click me</a>
<a href="support/target_blank_implicit_noopener.html?a7" id="a7" rel="opener noreferrer" target="_blank">Click me</a>
<a href="support/target_blank_implicit_noopener.html?a8" id="a8" rel="noopener opener noreferrer" target="_blank">Click me</a>
<!-- Although this is not valid, per the processing model of area it ought to work -->
<area shape="rect" coords="0,0,99,50" href="support/target_blank_implicit_noopener.html?area1" id="area1" rel="noopener" target="_blank">
<area shape="rect" coords="0,0,99,50" href="support/target_blank_implicit_noopener.html?area2" id="area2" rel="opener" target="_blank">
<area shape="rect" coords="0,0,99,50" href="support/target_blank_implicit_noopener.html?area3" id="area3" target="_blank">
<area shape="rect" coords="0,0,99,50" href="support/target_blank_implicit_noopener.html?area4" id="area4" rel="opener noopener" target="_blank">
<area shape="rect" coords="0,0,99,50" href="support/target_blank_implicit_noopener.html?area5" id="area5" rel="noopener opener" target="_blank">
<script>
let tests = [
{ id: "a1", hasOpener: false, name: "Anchor element with target=_blank with rel=noopener" },
{ id: "a2", hasOpener: true, name: "Anchor element with target=_blank with rel=opener" },
{ id: "a3", hasOpener: false, name: "Anchor element with target=_blank with implicit rel=noopener" },
{ id: "a4", hasOpener: false, name: "Anchor element with target=_blank with rel=opener+noopener" },
{ id: "a5", hasOpener: false, name: "Anchor element with target=_blank with rel=noopener+opener" },
{ id: "a6", hasOpener: false, name: "Anchor element with target=_blank with rel=noreferrer" },
{ id: "a7", hasOpener: false, name: "Anchor element with target=_blank with rel=opener+noreferrer" },
{ id: "a8", hasOpener: false, name: "Anchor element with target=_blank with rel=noopener+opener+noreferrer" },
{ id: "area1", hasOpener: false, name: "Area element with target=_blank with rel=noopener" },
{ id: "area2", hasOpener: true, name: "Area element with target=_blank with rel=opener" },
{ id: "area3", hasOpener: false, name: "Area element with target=_blank with implicit rel=noopener" },
{ id: "area4", hasOpener: false, name: "Area element with target=_blank with rel=opener+noopener" },
{ id: "area5", hasOpener: false, name: "Area element with target=_blank with rel=noopener+opener" },
];
tests.forEach(data => {
async_test(
test => {
let bc = new BroadcastChannel(data.id);
bc.addEventListener("message", test.step_func_done(e => {
assert_equals(e.data.hasOpener, data.hasOpener);
}), {once: true});
document.getElementById(data.id).click();
}, data.name);
});
</script>
</body>
</html>