mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-02 20:42:11 +02:00
Tests/LibWeb: Add text tests for image loading after document destroy
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.
This commit is contained in:
committed by
Andreas Kling
parent
d0fd5dd731
commit
aafe3658fd
Notes:
github-actions[bot]
2026-02-10 20:21:11 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/aafe3658fdf Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7869
@@ -0,0 +1,47 @@
|
||||
<!DOCTYPE html>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
// Test: Image with srcset attribute loading from a delayed server.
|
||||
// The iframe is removed before the image arrives.
|
||||
asyncTest(async done => {
|
||||
const server = httpTestServer();
|
||||
|
||||
const svgBody = '<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10"><rect width="10" height="10" fill="green"/></svg>';
|
||||
|
||||
const imageUrl1x = await server.createEcho("GET", "/delayed-srcset-1x.svg", {
|
||||
status: 200,
|
||||
headers: {
|
||||
"Content-Type": "image/svg+xml",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
},
|
||||
body: svgBody,
|
||||
delay_ms: 200,
|
||||
});
|
||||
const imageUrl2x = await server.createEcho("GET", "/delayed-srcset-2x.svg", {
|
||||
status: 200,
|
||||
headers: {
|
||||
"Content-Type": "image/svg+xml",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
},
|
||||
body: svgBody,
|
||||
delay_ms: 200,
|
||||
});
|
||||
|
||||
const iframe = document.createElement("iframe");
|
||||
document.body.appendChild(iframe);
|
||||
|
||||
const doc = iframe.contentDocument;
|
||||
const img = doc.createElement("img");
|
||||
img.srcset = `${imageUrl1x} 1x, ${imageUrl2x} 2x`;
|
||||
doc.body.appendChild(img);
|
||||
|
||||
setTimeout(() => {
|
||||
iframe.remove();
|
||||
}, 50);
|
||||
|
||||
setTimeout(() => {
|
||||
println("PASS");
|
||||
done();
|
||||
}, 1000);
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user