// META: script=/common/get-host-info.sub.js function echoURL(content) { return `/common/echo.py?content=${encodeURIComponent(content)}`; } function setSrc(frame, type, content) { if (type === "same-origin") { frame.src = echoURL(content); } else if (type === "cross-site") { frame.src = `${get_host_info().HTTP_NOTSAMESITE_ORIGIN}${echoURL(content)}`; } else { frame.srcdoc = content; } } ["srcdoc", "same-origin", "cross-site"].forEach(type => { const initialType = type === "srcdoc" ? type : "same-origin"; [ { "namedObject": "
", "namedObjectLocalName": "div" }, { "namedObject": "", "namedObjectLocalName": "object" }, { "namedObject": "", "namedObjectLocalName": "iframe" } ].forEach(testData => { async_test(t => { const frame = document.createElement("iframe"); t.add_cleanup(() => frame.remove()); setSrc(frame, initialType, `${testData.namedObject}`); frame.onload = t.step_func(() => { const f = frame.contentWindow.f, associatedAbc = f(); frame.onload = t.step_func_done(() => { assert_equals(f(), associatedAbc); assert_equals(associatedAbc.localName, testData.namedObjectLocalName); }); setSrc(frame, type, ""); }); document.body.append(frame); }, `Window's associated Document object is used for finding named objects (<${testData.namedObjectLocalName}> via ${type}