mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 09:45:06 +02:00
Add 6 text tests that verify correct behavior when image loading callbacks fire after a document has been destroyed. These tests check that load/error events are properly suppressed and that no additional network activity occurs after the document becomes inactive.
39 lines
1.1 KiB
HTML
39 lines
1.1 KiB
HTML
<!DOCTYPE html>
|
|
<script src="../include.js"></script>
|
|
<script>
|
|
// Test: Image fetch returns invalid image data after the iframe's document
|
|
// has been destroyed. The error callback fires on a destroyed document.
|
|
asyncTest(async done => {
|
|
const server = httpTestServer();
|
|
|
|
// Create a delayed response that is not a valid image (200ms delay).
|
|
const imageUrl = await server.createEcho("GET", "/delayed-bad-image-1.txt", {
|
|
status: 200,
|
|
headers: {
|
|
"Content-Type": "image/png",
|
|
"Access-Control-Allow-Origin": "*",
|
|
},
|
|
body: "this is not a valid PNG image",
|
|
delay_ms: 200,
|
|
});
|
|
|
|
const iframe = document.createElement("iframe");
|
|
document.body.appendChild(iframe);
|
|
|
|
const doc = iframe.contentDocument;
|
|
const img = doc.createElement("img");
|
|
img.src = imageUrl;
|
|
doc.body.appendChild(img);
|
|
|
|
// Remove iframe before the delayed error response arrives.
|
|
setTimeout(() => {
|
|
iframe.remove();
|
|
}, 50);
|
|
|
|
setTimeout(() => {
|
|
println("PASS");
|
|
done();
|
|
}, 1000);
|
|
});
|
|
</script>
|