Files
ladybird/Tests/LibWeb/Text/input/HTML/http-content-language.html
Aliaksandr Kalenik a79c995d8a Tests: Specify Content-Type header in tests that use HTTP server
Currently these tests work, because we are lucky to have fetched
response body available in `load_document()` to correctly sniff the MIME
type. This is a preparation for upcoming change that makes fetching
unbuffered, which will break these test unless we explicitly set the
`Content-Type` header.
2025-11-20 06:29:13 -05:00

40 lines
1.3 KiB
HTML

<!DOCTYPE html>
<script src="../include.js"></script>
<script>
asyncTest(async (done) => {
const httpServer = httpTestServer();
const url = await httpServer.createEcho("GET", "/http-content-language-test", {
status: 200,
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Expose-Headers": "Content-Language",
"Content-Language": "ko",
"Content-Type": "text/html",
},
body: `
<style>
div { width: 50px; }
#box:lang(ko) { width: 100px; }
</style>
<body><div id="box">TEST</div></body>
<script>
if (document.getElementById("box").offsetWidth == 100) {
parent.postMessage("OK", "*")
} else {
parent.postMessage("FAIL", "*")
}
<\/script>`,
});
const frame = document.createElement('iframe');
frame.src = url;
addEventListener("message", (event) => {
println(event.data);
done();
}, false);
document.body.appendChild(frame);
});
</script>