1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:47:45 +00:00

LibWeb: Create canvas bitmap when not existing in toDataURL and toBlob

This commit is contained in:
Bastiaan van der Plaat 2023-09-16 22:00:37 +02:00 committed by Andreas Kling
parent d24e07579f
commit 5e7a82a853
5 changed files with 34 additions and 3 deletions

View file

@ -0,0 +1,22 @@
<script src="../include.js"></script>
<script>
test(() => {
let testCounter = 1;
function testPart(part) {
println(`${testCounter++}. ${JSON.stringify(part())}`);
}
// 1. Export a canvas to PNG data URL
testPart(() => {
const canvas = document.createElement('canvas');
return canvas.toDataURL('image/png').substring(5, 14);
});
// 2. Export a canvas to JPEG data URL
// FIXME: This fails on macOS: https://github.com/SerenityOS/serenity/issues/21108
// testPart(() => {
// const canvas = document.createElement('canvas');
// return canvas.toDataURL('image/jpeg').substring(5, 15);
// });
});
</script>