Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

  • This WPT test may be referenced by the following Test IDs:
<!DOCTYPE html>
<title>Navigating to a cross-origin for iframe loading='lazy' before it is loaded: location.replace</title>
<script src="/common/get-host-info.sub.js"></script>
<iframe src="support/blank.htm?src" loading="lazy" hidden></iframe>
<script>
const iframe = document.querySelector('iframe');
iframe.setAttribute(
"data-src",
`${get_host_info().HTTP_NOTSAMESITE_ORIGIN}/html/semantics/embedded-content/the-iframe-element/support/blank.htm?nav`
);
const iframeLoaded = new Promise(resolve => {
iframe.onload = resolve;
});
iframe.contentWindow.location.replace(iframe.dataset.src);
iframe.hidden = false;
</script>
<!-- Loading testharness.js here is intentional to reproduce a bug in WebKit. -->
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({single_test: true});
iframeLoaded.then(() => {
// Need a timeout to detect failure when there are two navigations.
step_timeout(() => {
assert_throws_dom(
"SecurityError", // Use the SecurityError to assert this is a cross-origin iframe
() => {
iframe.contentWindow.location.href
},
"The iframe should load the cross-site url via locaiton.replace");
done();
}, 1000);
});
</script>