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: window.open() can set opener of a nested browsing context #15078

Merged
merged 1 commit into from
Jan 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
30 changes: 30 additions & 0 deletions html/browsers/windows/embedded-opener-a-form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!doctype html>
<title>opener and embedded documents; using a and form</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<iframe name=matchesastring></iframe>
<a href=/common/blank.html target=matchesastring>&lt;a></a>
<form action=/common/blank.html target=matchesastring><input type=submit value="<form>"></form>
zcorpan marked this conversation as resolved.
Show resolved Hide resolved
<script>
async_test(t => {
const frame = document.querySelector("iframe");
let counter = 0;
frame.onload = t.step_func(() => {
// Firefox and Chrome/Safari load differently
if (frame.contentWindow.location.href === "about:blank") {
return;
}

// Test bits
assert_equals(frame.contentWindow.opener, null);
if (counter === 0) {
document.querySelector("input").click();
} else {
t.done();
}
counter++;
});
document.querySelector("a").click();
});
</script>
32 changes: 32 additions & 0 deletions html/browsers/windows/embedded-opener.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!doctype html>
<title>opener and embedded documents; using window.open()</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<iframe name=matchesastring></iframe>
<script>
async_test(t => {
const frame = document.querySelector("iframe");
frame.onload = t.step_func(() => {
// Firefox and Chrome/Safari load differently
if (frame.contentWindow.location.href === "about:blank") {
return;
}

// Test bits
assert_equals(frame.contentWindow.opener, window, "opener before setting it to null");

const openerDesc = Object.getOwnPropertyDescriptor(frame.contentWindow, "opener"),
openerGet = openerDesc.get;

assert_equals(openerGet(), window, "opener before setting it to null via directly invoking the getter");
frame.contentWindow.opener = null;
frame.contentWindow.opener = "immaterial";
assert_equals(openerGet(), null, "opener after setting it to null via directly invoking the getter");
assert_equals(frame.contentWindow.opener, "immaterial");

t.done();
});
window.open("/common/blank.html", "matchesastring");
});
</script>