Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Location.ancestorOrigins lifetime behavior</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/browsing-the-web.html#dom-location-ancestororigins">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
function createIframeAndNavigate(test, src) {
return new Promise(resolve => {
const iframe = document.createElement("iframe");
iframe.onload = () => {
resolve(iframe);
}
iframe.src = src;
document.body.appendChild(iframe);
test.add_cleanup(() => {
iframe.remove();
});
});
}


promise_test(async t => {
assert_implements(location.ancestorOrigins, "location.ancestorOrigins not implemented");
const iframe = await createIframeAndNavigate(t, "about:blank");
assert_array_equals(
iframe.contentWindow.location.ancestorOrigins,
[location.origin],
"Initial ancestorOrigins should match expected placeholder value"
);

const loc = iframe.contentWindow.location;
iframe.remove();

assert_array_equals(
Array.from(loc.ancestorOrigins),
[],
"ancestorOrigins should be empty after iframe removal"
);
}, "location.ancestorOrigins returns empty list after iframe is removed and referenced Location's relevant document is null");

promise_test(async t => {
assert_implements(location.ancestorOrigins, "location.ancestorOrigins not implemented");
const iframe = await createIframeAndNavigate(t, "about:blank");
assert_array_equals(
iframe.contentWindow.location.ancestorOrigins,
[location.origin],
"Initial ancestorOrigins should match expected placeholder value"
);

const loc = iframe.contentWindow.location;
await new Promise(resolve => {
iframe.onload = resolve;
iframe.src = "http://{{hosts[alt][]}}:{{ports[http][0]}}/common/blank.html";
});

assert_array_equals(
Array.from(loc.ancestorOrigins),
[],
"ancestorOrigins should be empty after iframe navigation"
);
}, "location.ancestorOrigins returns empty list when iframe navigated away and referenced Location's relevant document is null");
</script>
</body>

</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!doctype html>
<title>location.ancestorOrigins snapshot timing of referrerpolicy</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
promise_test(async () => {
assert_implements(location.ancestorOrigins);
const iframe = document.createElement('iframe');
iframe.src = '/common/blank.html?pipe=trickle(d1)';
iframe.referrerPolicy = 'no-referrer';
const loaded = new Promise(resolve => iframe.onload = resolve);
document.body.append(iframe);
// initial about:blank should see 'no-referrer' results
assert_array_equals(Array.from(iframe.contentWindow.location.ancestorOrigins), ['null']);
iframe.referrerPolicy = '';
await loaded;
// The referrerpolicy attribute get snapshotted at step 16 of "beginning navigation"
// https://html.spec.whatwg.org/#beginning-navigation and result should therefore,
// still be ["null"], here.
assert_array_equals(Array.from(iframe.contentWindow.location.ancestorOrigins), ["null"]);
});

promise_test(async () => {
assert_implements(location.ancestorOrigins);
const iframe = document.createElement('iframe');

iframe.referrerPolicy = 'no-referrer';
const loaded = new Promise(resolve => iframe.onload = resolve);
document.body.append(iframe);
// initial about:blank should see 'no-referrer' results
assert_array_equals(Array.from(iframe.contentWindow.location.ancestorOrigins), ['null']);
iframe.referrerPolicy = '';
await loaded;

await new Promise(resolve => {
iframe.onload = resolve;
iframe.src = '/common/blank.html?pipe=trickle(d1)';
});
assert_array_equals(Array.from(iframe.contentWindow.location.ancestorOrigins), [window.origin]);
});
</script>
Loading