Files
ladybird/Tests/LibWeb/Text/input/Fetch/image-accept-header.html
Tim Ledbetter 59bf30f17f LibWeb: Add AVIF and WebP to the Accept header for images
This matches the behavior of other engines. Some CDNs that do content
negotiation will fall back to non alpha-preserving formats if these
values are not present.
2026-04-25 08:49:04 +02:00

33 lines
1017 B
HTML

<!DOCTYPE html>
<script src="../include.js"></script>
<script>
promiseTest(async () => {
const httpServer = httpTestServer();
// A 1x1 transparent PNG.
const transparentPng = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";
const url = await httpServer.createEcho("GET", "/image-accept-header-probe", {
status: 200,
headers: {
"Content-Type": "image/png",
},
body_encoding: "base64",
body: transparentPng,
});
const image = new Image();
await new Promise((resolve) => {
image.onload = resolve;
image.onerror = resolve;
image.src = url;
});
const echoUrl = new URL(url);
const response = await fetch(`${echoUrl.origin}/recorded-request-headers${echoUrl.pathname}`);
const headers = await response.json();
println(headers["Accept"][0]);
});
</script>