Truly independent web browser
<!DOCTYPE html>
<script src="../include.js"></script>
<canvas id="canvas" width="30" height="10"></canvas>
<script>
asyncTest(async done => {
const pixelSVG = `<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10"><rect width="10" height="10" fill="#123456"/></svg>`;
const server = httpTestServer();
const externalURL = await server.createEcho("GET", "/svg-image-does-not-load-external-resources-pixel.svg", {
status: 200,
headers: { "Content-Type": "image/svg+xml", "Cache-Control": "no-store" },
body: pixelSVG,
});
const dataURL = `data:image/svg+xml,${encodeURIComponent(pixelSVG)}`;
const blobURL = URL.createObjectURL(new Blob([pixelSVG], { type: "image/svg+xml" }));
const outerSVG = `<svg xmlns="http://www.w3.org/2000/svg" width="30" height="10">
<image href="${externalURL}" width="10" height="10"/>
<image href="${dataURL}" x="10" width="10" height="10"/>
<image href="${blobURL}" x="20" width="10" height="10"/>
</svg>`;
const image = new Image();
image.onload = async () => {
const context = canvas.getContext("2d");
context.drawImage(image, 0, 0);
println(`External image: ${context.getImageData(5, 5, 1, 1).data}`);
println(`data: image: ${context.getImageData(15, 5, 1, 1).data}`);
println(`blob: image: ${context.getImageData(25, 5, 1, 1).data}`);
const requestCount = await (await fetch(server.recordedRequestCountURL(externalURL))).json();
println(`Requests for the external image: ${requestCount}`);
done();
};
image.src = `data:image/svg+xml,${encodeURIComponent(outerSVG)}`;
});
</script>