Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/embedded-content/the-iframe-element/bad-src-means-about-blank.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>location href in iframe when setting src attribute</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
"use strict";
setup({ explicit_done: true });
const tests = [
{
inputSrc: null,
expectedLocationHref: "about:blank"
},
{
inputSrc: "about:blank",
expectedLocationHref: "about:blank"
},
{
inputSrc: "",
expectedLocationHref: "about:blank"
},
{
expectedLocationHref: "about:blank"
}
];
window.onload = () => {
for (const { inputSrc, expectedLocationHref } of tests) {
async_test(t => {
const iframe = document.createElement("iframe");
iframe.onload = t.step_func_done(() => {
assert_equals(iframe.contentWindow.location.href, expectedLocationHref);
});
if (inputSrc !== null) {
iframe.src = inputSrc;
}
document.body.append(iframe);
}, "Testing location href of iframe with input src: " + inputSrc);
}
done();
};
</script>