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: opener and discarded auxiliary browsing context #15518

Merged
merged 2 commits into from
Mar 7, 2019
Merged
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
61 changes: 36 additions & 25 deletions html/browsers/windows/embedded-opener-remove-frame.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
<!doctype html>
<title>opener and "removed" embedded documents</title>
<title>opener and discarded browsing contexts</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<iframe name=matchesastring></iframe>
<script>
function testOpener(otherW, thisW, discardOtherBC) {
assert_equals(otherW.opener, thisW, "opener before removal");

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

assert_equals(openerGet(), thisW, "opener before removal via directly invoking the getter");
discardOtherBC();
assert_equals(otherW.opener, null, "opener after removal");
assert_equals(openerGet(), null, "opener after removal via directly invoking the getter");

otherW.opener = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little weird to do this after the opener is already asserted to be null, but I guess we were already testing that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly to ensure the setter doesn't do anything weird. I could remove this if desired...

assert_equals(openerGet(), null, "opener after setting it null via directly invoking the getter");
const openerDescNull = Object.getOwnPropertyDescriptor(otherW, "opener");
assert_not_equals(openerDescNull, openerDesc);
assert_object_equals(openerDescNull, openerDesc);

otherW.opener = "immaterial";
assert_equals(openerGet(), null, "opener after setting it \"immaterial\" via directly invoking the getter");
const openerDescImmaterial = Object.getOwnPropertyDescriptor(otherW, "opener");
assert_equals(openerDescImmaterial.value, "immaterial");
assert_true(openerDescImmaterial.writable);
assert_true(openerDescImmaterial.enumerable);
assert_true(openerDescImmaterial.configurable);
}

async_test(t => {
const frame = document.querySelector("iframe"),
frameW = frame.contentWindow;
Expand All @@ -15,32 +41,17 @@
}

// Test bits
assert_equals(frameW.opener, window, "opener before removal");

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

assert_equals(openerGet(), window, "opener before removal via directly invoking the getter");
frame.remove();
assert_equals(frameW.opener, null, "opener after removal");
assert_equals(openerGet(), null, "opener after removal via directly invoking the getter");

frameW.opener = null;
assert_equals(openerGet(), null, "opener after setting it null via directly invoking the getter");
const openerDescNull = Object.getOwnPropertyDescriptor(frameW, "opener");
assert_not_equals(openerDescNull, openerDesc);
assert_object_equals(openerDescNull, openerDesc);

frameW.opener = "immaterial";
assert_equals(openerGet(), null, "opener after setting it \"immaterial\" via directly invoking the getter");
const openerDescImmaterial = Object.getOwnPropertyDescriptor(frameW, "opener");
assert_equals(openerDescImmaterial.value, "immaterial");
assert_true(openerDescImmaterial.writable);
assert_true(openerDescImmaterial.enumerable);
assert_true(openerDescImmaterial.configurable);
testOpener(frameW, window, () => frame.remove());

t.done();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can use t.step_func_done for this one too, right?

Copy link
Member Author

@annevk annevk Feb 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, due to different load event behavior (there's a comment to that effect).

});
window.open("/common/blank.html", "matchesastring");
});
}, "opener of discarded nested browsing context");

async_test(t => {
const popupW = window.open("/common/blank.html");
popupW.onload = t.step_func_done(t => {
testOpener(popupW, window, () => popupW.close());
});
}, "opener of discarded auxiliary browsing context");
</script>