Truly independent web browser
<!doctype html>
<html class="reftest-wait">
<link rel="match" href="../expected/isolated-iframe-is-composited-into-its-parent-ref.html" />
<style>
body {
margin: 0;
}
iframe {
background: green;
display: block;
width: 100px;
height: 100px;
border: 0;
}
</style>
<script>
// The frame's document is cross-site, so another process hosts it. Its document has no background, and its used
// color scheme matches the frame's, so its canvas is transparent and the frame's own green background shows
// through. The frame reports once its rendering update has finished and the compositor has received its frame.
const request = new XMLHttpRequest();
const path = `/echo/isolated-iframe-transparent-canvas-${crypto.randomUUID()}`;
request.open("POST", "/echo", false);
request.setRequestHeader("Content-Type", "application/json");
request.send(
JSON.stringify({
method: "GET",
path,
status: 200,
headers: { "Content-Type": "text/html" },
body: `<!DOCTYPE html><style>html, body { margin: 0; height: 100%; }</style>
<script>requestAnimationFrame(() => requestAnimationFrame(async () => {
const nextTask = () => new Promise(resolve => {
const channel = new MessageChannel();
channel.port1.onmessage = resolve;
channel.port2.postMessage(null);
});
do await nextTask();
while (internals.frameSchedulerState() !== "idle");
internals.synchronizeCompositor();
parent.postMessage("painted", "*");
}));<\/script>`,
})
);
const host = `oop-iframe-transparent-canvas-${crypto.randomUUID()}.localhost`;
window.addEventListener("message", () => document.documentElement.classList.remove("reftest-wait"));
document.write(`<iframe src="http://${host}:${location.port}${path}"></iframe>`);
</script>
</html>