Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML: target=_blank implies noopener; opener support #15188

Merged
merged 3 commits into from
Feb 11, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta charset=utf-8>
<title>Test behavior of rel="noopener" links</title>
<title>Test behavior of target=_blank links</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
</head>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>Test behavior of base target=_blank links</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<base target=_blank>
</head>
<body>
<a href="support/target_blank_iplicit_noopener.html?a1" id="a1" rel="noopener">Click me</a>
annevk marked this conversation as resolved.
Show resolved Hide resolved
<a href="support/target_blank_iplicit_noopener.html?a2" id="a2" rel="opener">Click me</a>
<a href="support/target_blank_iplicit_noopener.html?a3" id="a3">Click me</a>
<a href="support/target_blank_iplicit_noopener.html?a4" id="a4" rel="opener noopener">Click me</a>
<a href="support/target_blank_iplicit_noopener.html?a5" id="a5" rel="noopener opener">Click me</a>
annevk marked this conversation as resolved.
Show resolved Hide resolved

<img src="/images/threecolors.png" />
<area shape="rect" coords="0,0,99,50" href="support/target_blank_iplicit_noopener.html?area1" id="area1" rel="noopener">
</img>
<img src="/images/threecolors.png" />
<area shape="rect" coords="0,0,99,50" href="support/target_blank_iplicit_noopener.html?area2" id="area2" rel="opener">
</img>
<img src="/images/threecolors.png" />
<area shape="rect" coords="0,0,99,50" href="support/target_blank_iplicit_noopener.html?area3" id="area3">
</img>
<img src="/images/threecolors.png" />
<area shape="rect" coords="0,0,99,50" href="support/target_blank_iplicit_noopener.html?area4" id="area4" rel="opener noopener">
</img>
<img src="/images/threecolors.png" />
<area shape="rect" coords="0,0,99,50" href="support/target_blank_iplicit_noopener.html?area5" id="area5" rel="noopener opener">
</img>

<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: "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>