mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
add HTMLImageElement.complete property
Per spec, complete returns true when the image has no src, is fully fetched, or is broken. Since this is a headless browser that does not fetch images, complete always returns true.
This commit is contained in:
@@ -98,6 +98,22 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id="complete">
|
||||
{
|
||||
// Image with no src is complete per spec
|
||||
const img = document.createElement('img');
|
||||
testing.expectEqual(true, img.complete);
|
||||
|
||||
// Image with src is also complete (headless browser, no actual fetch)
|
||||
img.src = 'test.png';
|
||||
testing.expectEqual(true, img.complete);
|
||||
|
||||
// Image constructor also complete
|
||||
const img2 = new Image();
|
||||
testing.expectEqual(true, img2.complete);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id="load-trigger-event">
|
||||
{
|
||||
const img = document.createElement("img");
|
||||
|
||||
@@ -112,6 +112,12 @@ pub fn getNaturalHeight(_: *const Image) u32 {
|
||||
return 0;
|
||||
}
|
||||
|
||||
pub fn getComplete(_: *const Image) bool {
|
||||
// Per spec, complete is true when: no src/srcset, image fully fetched,
|
||||
// or image is broken. Since we don't fetch images, they are always complete.
|
||||
return true;
|
||||
}
|
||||
|
||||
pub const JsApi = struct {
|
||||
pub const bridge = js.Bridge(Image);
|
||||
|
||||
@@ -131,6 +137,7 @@ pub const JsApi = struct {
|
||||
pub const loading = bridge.accessor(Image.getLoading, Image.setLoading, .{});
|
||||
pub const naturalWidth = bridge.accessor(Image.getNaturalWidth, null, .{});
|
||||
pub const naturalHeight = bridge.accessor(Image.getNaturalHeight, null, .{});
|
||||
pub const complete = bridge.accessor(Image.getComplete, null, .{});
|
||||
};
|
||||
|
||||
pub const Build = struct {
|
||||
|
||||
Reference in New Issue
Block a user