Source code

Revision control

Copy as Markdown

Other Tools

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script>
"use strict";
addEventListener("message", async function() {
const url = new URL("/return_headers.sjs", location).href;
const webpageFetchResult = await fetch(url).then(res => res.json());
const webpageXhrResult = await new Promise(resolve => {
const req = new XMLHttpRequest();
req.open("GET", url);
req.addEventListener("load", () => resolve(JSON.parse(req.responseText)),
{once: true});
req.addEventListener("error", () => resolve({error: "webpage xhr failed to complete"}),
{once: true});
req.send();
});
postMessage({
type: "testPageGlobals",
webpageFetchResult,
webpageXhrResult,
}, "*");
}, {once: true});
</script>
</body>
</html>