Source code
Revision control
Copy as Markdown
Other Tools
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<script>
function toBlobURL(data, mimeType) {
return URL.createObjectURL(
new Blob([data], {
type: mimeType,
})
);
}
// closing script element literal split up to not end the parent script element
let testurl = toBlobURL("<body></body>", "text/html");
addEventListener("message", event => {
if (event.data == "getblob") {
postMessage({ bloburl: testurl }, "*");
}
});
// the blob URL should have a content principal
</script>
</body>
</html>