Files
moli/moli-core/tests/fixtures/runtime/image_data.html
2026-08-11 00:10:12 +08:00

34 lines
1.1 KiB
HTML

<!doctype html>
<html>
<body
data-width=""
data-height=""
data-color-space=""
data-pixel-format=""
data-data-len=""
data-zeroes=""
data-mutable=""
data-too-large=""
>
<script>
const body = document.body;
const img = new ImageData(2, 3);
body.setAttribute("data-width", String(img.width));
body.setAttribute("data-height", String(img.height));
body.setAttribute("data-color-space", img.colorSpace);
body.setAttribute("data-pixel-format", img.pixelFormat);
body.setAttribute("data-data-len", String(img.data.length));
body.setAttribute("data-zeroes", String(Array.from(img.data).every((v) => v === 0)));
img.data[0] = 255;
img.data[3] = 255;
body.setAttribute("data-mutable", String(img.data[0] === 255 && img.data[3] === 255));
try {
new ImageData(2147483648, 2147483648);
body.setAttribute("data-too-large", "no-error");
} catch (error) {
body.setAttribute("data-too-large", String(error).includes("IndexSizeError"));
}
</script>
</body>
</html>