Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /trusted-types/navigate-to-javascript-url-007-crash.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<script>
// The subframe navigates to a JavaScript URL, causing the default policy to
// be called, which in turn removes the subframe's browsing context.
let iframe = document.createElement("iframe");
iframe.srcdoc = `<!DOCTYPE html>
<meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script';">
<script>
window.addEventListener("load", _ => {
trustedTypes.createPolicy("default", {
createScript: s => {
window.frameElement.remove();
return s;
}
});
window.location = 'javascript:;';
});
<\u002Fscript>`;
document.head.appendChild(iframe);
</script>