// META: script=/common/get-host-info.sub.js // // A test to verify that, when a srcdoc frame is created when it's parent // has a non-default base URI, and is later restored from history, it has // the same baseURI it started with, even if the parent has changed its own // baseURI in the meantime. // The parent always communicates with the child via postMessage since some // of the test cases include the child being sandboxed. async function sendMessage(frame, msg) { const result = new Promise(r => onmessage = e => r(e.data)); frame.postMessage(msg, "*"); return await result; } const runTest = (description, sandbox_flags) => { promise_test(async test => { const original_parent_baseURI = document.baseURI; // Create a URL for the child frame to navigate to. const nav_target = (new URL('./resources/send-back-base-url.html', location.href)).href; // Change parent to a non-default baseURI. const base_element = document.createElement("base"); base_element.href = get_host_info().REMOTE_ORIGIN; document.head.appendChild(base_element); assert_not_equals(document.baseURI, original_parent_baseURI, "parent baseURI failed to change."); const non_default_parent_baseURI = document.baseURI; // Create child and load a srcdoc frame. const iframe = document.createElement("iframe"); if (sandbox_flags !== null) iframe.sandbox = sandbox_flags; iframe.srcdoc = `