ladybird/Tests/LibWeb/Text/input/test-http-test-server.html
2025-03-20 11:50:49 +01:00

30 lines
1.1 KiB
HTML

<!DOCTYPE html>
<script src="./include.js"></script>
<script>
asyncTest(async (done) => {
try {
const httpServer = httpTestServer();
const url = await httpServer.createEcho("GET", "/test-http-test-server", {
status: 200,
headers: {
"Access-Control-Allow-Origin": "*", // necessary when running test using file://...
"Access-Control-Expose-Headers": "X-Custom-Header", // tells the browser which headers to expose to JS
"Content-Type": "text/plain",
"X-Custom-Header": "well hello friends",
},
body: "hello world!",
});
const result = await fetch(url);
const headers = result.headers;
if (headers.get("X-Custom-Header") === "well hello friends") {
println("PASS");
} else {
println("FAIL");
}
} catch (err) {
println("FAIL - " + err);
}
done();
});
</script>