LibWeb/XHR: Isomorphic decode accessing XMLHttpRequest response headers

Fixes a crash on:

https://wpt.live/html/browsers/browsing-the-web/navigating-across-documents/refresh/subresource.any.html
This commit is contained in:
Shannon Booth 2025-01-03 18:03:42 +13:00 committed by Sam Atkins
commit e74ca82083
Notes: github-actions[bot] 2025-01-15 12:36:55 +00:00
4 changed files with 47 additions and 14 deletions

View file

@ -0,0 +1,29 @@
<script src="../include.js"></script>
<script>
asyncTest(async (done) => {
try {
const httpServer = httpTestServer();
const url = await httpServer.createEcho("GET", "/xml-http-request-response-header-decoding", {
status: 200,
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Expose-Headers": "Refresh",
"Refresh": "0;./refreshed.txt?\u0080\u00FF",
},
body: "",
});
const xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.addEventListener("load", () => {
println(`getAllResponseHeaders()\n${xhr.getAllResponseHeaders().replace('\r','')}`);
println(`getResponseHeader("Refresh") => '${xhr.getResponseHeader("Refresh")}'`);
done();
});
xhr.send();
} catch (err) {
console.log("FAIL - " + err);
}
});
</script>