mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
26 lines
843 B
HTML
26 lines
843 B
HTML
|
|
<!DOCTYPE html>
|
||
|
|
<script src="../include.js"></script>
|
||
|
|
<script>
|
||
|
|
asyncTest((done) => {
|
||
|
|
const div = document.createElement("div");
|
||
|
|
const shadowRoot = div.attachShadow({ mode: "closed" });
|
||
|
|
|
||
|
|
const iframe = document.createElement("iframe");
|
||
|
|
|
||
|
|
window.addEventListener("message", (messageEvent) => {
|
||
|
|
println(`Received a message: '${messageEvent.data}'`);
|
||
|
|
println(`Was it from the shadow root iframe? ${messageEvent.source === iframe.contentWindow}`);
|
||
|
|
done();
|
||
|
|
});
|
||
|
|
|
||
|
|
iframe.srcdoc = `
|
||
|
|
\u003cscript\u003e
|
||
|
|
window.parent.postMessage("Hello from iframe in the shadow root of the just inserted div!");
|
||
|
|
\u003c/script\u003e
|
||
|
|
`;
|
||
|
|
shadowRoot.appendChild(iframe);
|
||
|
|
|
||
|
|
document.body.appendChild(div);
|
||
|
|
});
|
||
|
|
</script>
|