Skip to content

Truly independent web browser

Tests: Import img natural size and relevant mutation WPT tests

Andreas Kling80b74097a8cb
diff --git a/Tests/LibWeb/TestConfig.ini b/Tests/LibWeb/TestConfig.ini
index 8659e922e4d..7e37355b22e 100644
--- a/Tests/LibWeb/TestConfig.ini
+++ b/Tests/LibWeb/TestConfig.ini
@@ -615,6 +615,10 @@ Text/input/Fetch/fetch-metadata-headers-follow-the-current-url.html
; Loads style sheets from a cross-origin host, which needs an HTTP origin.
Text/input/wpt-import/css/cssom/stylesheet-same-origin.sub.html
+; Loads images from root-relative /images/ URLs, which need an HTTP origin.
+Text/input/wpt-import/html/semantics/embedded-content/the-img-element/relevant-mutations.html
+Text/input/wpt-import/html/semantics/embedded-content/the-img-element/sizes/sizes-auto.html
+
; Reads the rules of linked or imported style sheets, which are not origin-clean when loaded from file:// URLs.
Text/input/css/shadow-root-font-face-rules.html
Text/input/css/style-engine/imported-sheet-media-text-flips.html
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-img-element/naturalWidth-naturalHeight-width-height.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-img-element/naturalWidth-naturalHeight-width-height.txt
new file mode 100644
index 00000000000..0d1cdcb0c09
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-img-element/naturalWidth-naturalHeight-width-height.txt
@@ -0,0 +1,264 @@
+Harness status: OK
+
+Found 258 tests
+
+60 Pass
+198 Fail
+Pass raster image
+Pass raster image (when not rendered)
+Pass raster image with width/height attributes
+Pass raster image with width/height attributes (when not rendered)
+Pass non existent image, no natural dimensions
+Pass non existent image, no natural dimensions (when not rendered)
+Pass non existent image with width/height attributes, no natural dimensions
+Pass non existent image with width/height attributes, no natural dimensions (when not rendered)
+Fail SVG image, no natural dimensions
+Fail SVG image, no natural dimensions (when not rendered)
+Fail SVG image with width/height attrs, no natural dimensions
+Fail SVG image with width/height attrs, no natural dimensions (when not rendered)
+Fail SVG image with width attr, no natural dimensions
+Fail SVG image with width attr, no natural dimensions (when not rendered)
+Fail SVG image with height attr, no natural dimensions
+Fail SVG image with height attr, no natural dimensions (when not rendered)
+Fail SVG image, percengage natural dimensions
+Fail SVG image, percengage natural dimensions (when not rendered)
+Fail SVG image, negative percengage natural dimensions
+Fail SVG image, negative percengage natural dimensions (when not rendered)
+Fail SVG image, with natural width
+Fail SVG image, with natural width (when not rendered)
+Fail SVG image, with natural height
+Fail SVG image, with natural height (when not rendered)
+Fail SVG image, with natural width of 0
+Fail SVG image, with natural width of 0 (when not rendered)
+Fail SVG image, with natural height of 0
+Fail SVG image, with natural height of 0 (when not rendered)
+Fail SVG image, with natural width being negative
+Fail SVG image, with natural width being negative (when not rendered)
+Fail SVG image, with natural height being negative
+Fail SVG image, with natural height being negative (when not rendered)
+Fail SVG image, no natural dimensions, and aspect ratio from viewBox
+Fail SVG image, no natural dimensions, and aspect ratio from viewBox (when not rendered)
+Fail SVG image, percengage natural dimensions, and aspect ratio from viewBox
+Fail SVG image, percengage natural dimensions, and aspect ratio from viewBox (when not rendered)
+Fail SVG image, negative percengage natural dimensions, and aspect ratio from viewBox
+Fail SVG image, negative percengage natural dimensions, and aspect ratio from viewBox (when not rendered)
+Fail SVG image, with natural width, and aspect ratio from viewBox
+Fail SVG image, with natural width, and aspect ratio from viewBox (when not rendered)
+Fail SVG image, with natural height, and aspect ratio from viewBox
+Fail SVG image, with natural height, and aspect ratio from viewBox (when not rendered)
+Pass SVG image, with natural width of 0, and aspect ratio from viewBox
+Pass SVG image, with natural width of 0, and aspect ratio from viewBox (when not rendered)
+Pass SVG image, with natural height of 0, and aspect ratio from viewBox
+Pass SVG image, with natural height of 0, and aspect ratio from viewBox (when not rendered)
+Fail SVG image, with natural width being negative, and aspect ratio from viewBox
+Fail SVG image, with natural width being negative, and aspect ratio from viewBox (when not rendered)
+Fail SVG image, with natural height being negative, and aspect ratio from viewBox
+Fail SVG image, with natural height being negative, and aspect ratio from viewBox (when not rendered)
+Fail SVG image, no natural dimensions, viewBox with 0 width/height
+Fail SVG image, no natural dimensions, viewBox with 0 width/height (when not rendered)
+Fail SVG image, no natural dimensions, viewBox with 0 width
+Fail SVG image, no natural dimensions, viewBox with 0 width (when not rendered)
+Fail SVG image, no natural dimensions, viewBox with 0 height
+Fail SVG image, no natural dimensions, viewBox with 0 height (when not rendered)
+Fail SVG image, with natural width, viewBox with 0 width/height
+Fail SVG image, with natural width, viewBox with 0 width/height (when not rendered)
+Fail SVG image, with natural width, viewBox with 0 width
+Fail SVG image, with natural width, viewBox with 0 width (when not rendered)
+Fail SVG image, with natural width, viewBox with 0 height
+Fail SVG image, with natural width, viewBox with 0 height (when not rendered)
+Fail SVG image, with natural height, viewBox with 0 width/height
+Fail SVG image, with natural height, viewBox with 0 width/height (when not rendered)
+Fail SVG image, with natural height, viewBox with 0 width
+Fail SVG image, with natural height, viewBox with 0 width (when not rendered)
+Fail SVG image, with natural height, viewBox with 0 height
+Fail SVG image, with natural height, viewBox with 0 height (when not rendered)
+Pass SVG image, with natural width and height
+Pass SVG image, with natural width and height (when not rendered)
+Pass SVG image, with natural width and height, and aspect ratio from viewBox
+Pass SVG image, with natural width and height, and aspect ratio from viewBox (when not rendered)
+Pass SVG image, with natural width and height of 0, and aspect ratio from viewBox
+Pass SVG image, with natural width and height of 0, and aspect ratio from viewBox (when not rendered)
+Fail SVG image, with natural width and height being negative, and aspect ratio from viewBox
+Fail SVG image, with natural width and height being negative, and aspect ratio from viewBox (when not rendered)
+Fail SVG image, with natural width matching default concrete object size
+Fail SVG image, with natural width matching default concrete object size (when not rendered)
+Fail SVG image, with natural height matching default concrete object size
+Fail SVG image, with natural height matching default concrete object size (when not rendered)
+Fail SVG image, with natural width matching default concrete object size, and aspect ratio from viewBox
+Fail SVG image, with natural width matching default concrete object size, and aspect ratio from viewBox (when not rendered)
+Fail SVG image, with natural height matching default concrete object size, and aspect ratio from viewBox
+Fail SVG image, with natural height matching default concrete object size, and aspect ratio from viewBox (when not rendered)
+Pass SVG image, with natural width and height matching default concrete object size
+Pass SVG image, with natural width and height matching default concrete object size (when not rendered)
+Pass raster image (with srcset/1x)
+Pass raster image (with srcset/1x) (when not rendered)
+Pass raster image with width/height attributes (with srcset/1x)
+Pass raster image with width/height attributes (with srcset/1x) (when not rendered)
+Pass non existent image, no natural dimensions (with srcset/1x)
+Pass non existent image, no natural dimensions (with srcset/1x) (when not rendered)
+Pass non existent image with width/height attributes, no natural dimensions (with srcset/1x)
+Pass non existent image with width/height attributes, no natural dimensions (with srcset/1x) (when not rendered)
+Fail SVG image, no natural dimensions (with srcset/1x)
+Fail SVG image, no natural dimensions (with srcset/1x) (when not rendered)
+Fail SVG image with width/height attrs, no natural dimensions (with srcset/1x)
+Fail SVG image with width/height attrs, no natural dimensions (with srcset/1x) (when not rendered)
+Fail SVG image with width attr, no natural dimensions (with srcset/1x)
+Fail SVG image with width attr, no natural dimensions (with srcset/1x) (when not rendered)
+Fail SVG image with height attr, no natural dimensions (with srcset/1x)
+Fail SVG image with height attr, no natural dimensions (with srcset/1x) (when not rendered)
+Fail SVG image, percengage natural dimensions (with srcset/1x)
+Fail SVG image, percengage natural dimensions (with srcset/1x) (when not rendered)
+Fail SVG image, negative percengage natural dimensions (with srcset/1x)
+Fail SVG image, negative percengage natural dimensions (with srcset/1x) (when not rendered)
+Fail SVG image, with natural width (with srcset/1x)
+Fail SVG image, with natural width (with srcset/1x) (when not rendered)
+Fail SVG image, with natural height (with srcset/1x)
+Fail SVG image, with natural height (with srcset/1x) (when not rendered)
+Fail SVG image, with natural width of 0 (with srcset/1x)
+Fail SVG image, with natural width of 0 (with srcset/1x) (when not rendered)
+Fail SVG image, with natural height of 0 (with srcset/1x)
+Fail SVG image, with natural height of 0 (with srcset/1x) (when not rendered)
+Fail SVG image, with natural width being negative (with srcset/1x)
+Fail SVG image, with natural width being negative (with srcset/1x) (when not rendered)
+Fail SVG image, with natural height being negative (with srcset/1x)
+Fail SVG image, with natural height being negative (with srcset/1x) (when not rendered)
+Fail SVG image, no natural dimensions, and aspect ratio from viewBox (with srcset/1x)
+Fail SVG image, no natural dimensions, and aspect ratio from viewBox (with srcset/1x) (when not rendered)
+Fail SVG image, percengage natural dimensions, and aspect ratio from viewBox (with srcset/1x)
+Fail SVG image, percengage natural dimensions, and aspect ratio from viewBox (with srcset/1x) (when not rendered)
+Fail SVG image, negative percengage natural dimensions, and aspect ratio from viewBox (with srcset/1x)
+Fail SVG image, negative percengage natural dimensions, and aspect ratio from viewBox (with srcset/1x) (when not rendered)
+Fail SVG image, with natural width, and aspect ratio from viewBox (with srcset/1x)
+Fail SVG image, with natural width, and aspect ratio from viewBox (with srcset/1x) (when not rendered)
+Fail SVG image, with natural height, and aspect ratio from viewBox (with srcset/1x)
+Fail SVG image, with natural height, and aspect ratio from viewBox (with srcset/1x) (when not rendered)
+Pass SVG image, with natural width of 0, and aspect ratio from viewBox (with srcset/1x)
+Pass SVG image, with natural width of 0, and aspect ratio from viewBox (with srcset/1x) (when not rendered)
+Pass SVG image, with natural height of 0, and aspect ratio from viewBox (with srcset/1x)
+Pass SVG image, with natural height of 0, and aspect ratio from viewBox (with srcset/1x) (when not rendered)
+Fail SVG image, with natural width being negative, and aspect ratio from viewBox (with srcset/1x)
+Fail SVG image, with natural width being negative, and aspect ratio from viewBox (with srcset/1x) (when not rendered)
+Fail SVG image, with natural height being negative, and aspect ratio from viewBox (with srcset/1x)
+Fail SVG image, with natural height being negative, and aspect ratio from viewBox (with srcset/1x) (when not rendered)
+Fail SVG image, no natural dimensions, viewBox with 0 width/height (with srcset/1x)
+Fail SVG image, no natural dimensions, viewBox with 0 width/height (with srcset/1x) (when not rendered)
+Fail SVG image, no natural dimensions, viewBox with 0 width (with srcset/1x)
+Fail SVG image, no natural dimensions, viewBox with 0 width (with srcset/1x) (when not rendered)
+Fail SVG image, no natural dimensions, viewBox with 0 height (with srcset/1x)
+Fail SVG image, no natural dimensions, viewBox with 0 height (with srcset/1x) (when not rendered)
+Fail SVG image, with natural width, viewBox with 0 width/height (with srcset/1x)
+Fail SVG image, with natural width, viewBox with 0 width/height (with srcset/1x) (when not rendered)
+Fail SVG image, with natural width, viewBox with 0 width (with srcset/1x)
+Fail SVG image, with natural width, viewBox with 0 width (with srcset/1x) (when not rendered)
+Fail SVG image, with natural width, viewBox with 0 height (with srcset/1x)
+Fail SVG image, with natural width, viewBox with 0 height (with srcset/1x) (when not rendered)
+Fail SVG image, with natural height, viewBox with 0 width/height (with srcset/1x)
+Fail SVG image, with natural height, viewBox with 0 width/height (with srcset/1x) (when not rendered)
+Fail SVG image, with natural height, viewBox with 0 width (with srcset/1x)
+Fail SVG image, with natural height, viewBox with 0 width (with srcset/1x) (when not rendered)
+Fail SVG image, with natural height, viewBox with 0 height (with srcset/1x)
+Fail SVG image, with natural height, viewBox with 0 height (with srcset/1x) (when not rendered)
+Pass SVG image, with natural width and height (with srcset/1x)
+Pass SVG image, with natural width and height (with srcset/1x) (when not rendered)
+Pass SVG image, with natural width and height, and aspect ratio from viewBox (with srcset/1x)
+Pass SVG image, with natural width and height, and aspect ratio from viewBox (with srcset/1x) (when not rendered)
+Pass SVG image, with natural width and height of 0, and aspect ratio from viewBox (with srcset/1x)
+Pass SVG image, with natural width and height of 0, and aspect ratio from viewBox (with srcset/1x) (when not rendered)
+Fail SVG image, with natural width and height being negative, and aspect ratio from viewBox (with srcset/1x)
+Fail SVG image, with natural width and height being negative, and aspect ratio from viewBox (with srcset/1x) (when not rendered)
+Fail SVG image, with natural width matching default concrete object size (with srcset/1x)
+Fail SVG image, with natural width matching default concrete object size (with srcset/1x) (when not rendered)
+Fail SVG image, with natural height matching default concrete object size (with srcset/1x)
+Fail SVG image, with natural height matching default concrete object size (with srcset/1x) (when not rendered)
+Fail SVG image, with natural width matching default concrete object size, and aspect ratio from viewBox (with srcset/1x)
+Fail SVG image, with natural width matching default concrete object size, and aspect ratio from viewBox (with srcset/1x) (when not rendered)
+Fail SVG image, with natural height matching default concrete object size, and aspect ratio from viewBox (with srcset/1x)
+Fail SVG image, with natural height matching default concrete object size, and aspect ratio from viewBox (with srcset/1x) (when not rendered)
+Pass SVG image, with natural width and height matching default concrete object size (with srcset/1x)
+Pass SVG image, with natural width and height matching default concrete object size (with srcset/1x) (when not rendered)
+Pass raster image (with srcset/2x)
+Pass raster image (with srcset/2x) (when not rendered)
+Pass raster image with width/height attributes (with srcset/2x)
+Pass raster image with width/height attributes (with srcset/2x) (when not rendered)
+Pass non existent image, no natural dimensions (with srcset/2x)
+Pass non existent image, no natural dimensions (with srcset/2x) (when not rendered)
+Pass non existent image with width/height attributes, no natural dimensions (with srcset/2x)
+Pass non existent image with width/height attributes, no natural dimensions (with srcset/2x) (when not rendered)
+Fail SVG image, no natural dimensions (with srcset/2x)
+Fail SVG image, no natural dimensions (with srcset/2x) (when not rendered)
+Fail SVG image with width/height attrs, no natural dimensions (with srcset/2x)
+Fail SVG image with width/height attrs, no natural dimensions (with srcset/2x) (when not rendered)
+Fail SVG image with width attr, no natural dimensions (with srcset/2x)
+Fail SVG image with width attr, no natural dimensions (with srcset/2x) (when not rendered)
+Fail SVG image with height attr, no natural dimensions (with srcset/2x)
+Fail SVG image with height attr, no natural dimensions (with srcset/2x) (when not rendered)
+Fail SVG image, percengage natural dimensions (with srcset/2x)
+Fail SVG image, percengage natural dimensions (with srcset/2x) (when not rendered)
+Fail SVG image, negative percengage natural dimensions (with srcset/2x)
+Fail SVG image, negative percengage natural dimensions (with srcset/2x) (when not rendered)
+Fail SVG image, with natural width (with srcset/2x)
+Fail SVG image, with natural width (with srcset/2x) (when not rendered)
+Fail SVG image, with natural height (with srcset/2x)
+Fail SVG image, with natural height (with srcset/2x) (when not rendered)
+Fail SVG image, with natural width of 0 (with srcset/2x)
+Fail SVG image, with natural width of 0 (with srcset/2x) (when not rendered)
+Fail SVG image, with natural height of 0 (with srcset/2x)
+Fail SVG image, with natural height of 0 (with srcset/2x) (when not rendered)
+Fail SVG image, with natural width being negative (with srcset/2x)
+Fail SVG image, with natural width being negative (with srcset/2x) (when not rendered)
+Fail SVG image, with natural height being negative (with srcset/2x)
+Fail SVG image, with natural height being negative (with srcset/2x) (when not rendered)
+Fail SVG image, no natural dimensions, and aspect ratio from viewBox (with srcset/2x)
+Fail SVG image, no natural dimensions, and aspect ratio from viewBox (with srcset/2x) (when not rendered)
+Fail SVG image, percengage natural dimensions, and aspect ratio from viewBox (with srcset/2x)
+Fail SVG image, percengage natural dimensions, and aspect ratio from viewBox (with srcset/2x) (when not rendered)
+Fail SVG image, negative percengage natural dimensions, and aspect ratio from viewBox (with srcset/2x)
+Fail SVG image, negative percengage natural dimensions, and aspect ratio from viewBox (with srcset/2x) (when not rendered)
+Fail SVG image, with natural width, and aspect ratio from viewBox (with srcset/2x)
+Fail SVG image, with natural width, and aspect ratio from viewBox (with srcset/2x) (when not rendered)
+Fail SVG image, with natural height, and aspect ratio from viewBox (with srcset/2x)
+Fail SVG image, with natural height, and aspect ratio from viewBox (with srcset/2x) (when not rendered)
+Pass SVG image, with natural width of 0, and aspect ratio from viewBox (with srcset/2x)
+Pass SVG image, with natural width of 0, and aspect ratio from viewBox (with srcset/2x) (when not rendered)
+Pass SVG image, with natural height of 0, and aspect ratio from viewBox (with srcset/2x)
+Pass SVG image, with natural height of 0, and aspect ratio from viewBox (with srcset/2x) (when not rendered)
+Fail SVG image, with natural width being negative, and aspect ratio from viewBox (with srcset/2x)
+Fail SVG image, with natural width being negative, and aspect ratio from viewBox (with srcset/2x) (when not rendered)
+Fail SVG image, with natural height being negative, and aspect ratio from viewBox (with srcset/2x)
+Fail SVG image, with natural height being negative, and aspect ratio from viewBox (with srcset/2x) (when not rendered)
+Fail SVG image, no natural dimensions, viewBox with 0 width/height (with srcset/2x)
+Fail SVG image, no natural dimensions, viewBox with 0 width/height (with srcset/2x) (when not rendered)
+Fail SVG image, no natural dimensions, viewBox with 0 width (with srcset/2x)
+Fail SVG image, no natural dimensions, viewBox with 0 width (with srcset/2x) (when not rendered)
+Fail SVG image, no natural dimensions, viewBox with 0 height (with srcset/2x)
+Fail SVG image, no natural dimensions, viewBox with 0 height (with srcset/2x) (when not rendered)
+Fail SVG image, with natural width, viewBox with 0 width/height (with srcset/2x)
+Fail SVG image, with natural width, viewBox with 0 width/height (with srcset/2x) (when not rendered)
+Fail SVG image, with natural width, viewBox with 0 width (with srcset/2x)
+Fail SVG image, with natural width, viewBox with 0 width (with srcset/2x) (when not rendered)
+Fail SVG image, with natural width, viewBox with 0 height (with srcset/2x)
+Fail SVG image, with natural width, viewBox with 0 height (with srcset/2x) (when not rendered)
+Fail SVG image, with natural height, viewBox with 0 width/height (with srcset/2x)
+Fail SVG image, with natural height, viewBox with 0 width/height (with srcset/2x) (when not rendered)
+Fail SVG image, with natural height, viewBox with 0 width (with srcset/2x)
+Fail SVG image, with natural height, viewBox with 0 width (with srcset/2x) (when not rendered)
+Fail SVG image, with natural height, viewBox with 0 height (with srcset/2x)
+Fail SVG image, with natural height, viewBox with 0 height (with srcset/2x) (when not rendered)
+Pass SVG image, with natural width and height (with srcset/2x)
+Pass SVG image, with natural width and height (with srcset/2x) (when not rendered)
+Pass SVG image, with natural width and height, and aspect ratio from viewBox (with srcset/2x)
+Pass SVG image, with natural width and height, and aspect ratio from viewBox (with srcset/2x) (when not rendered)
+Pass SVG image, with natural width and height of 0, and aspect ratio from viewBox (with srcset/2x)
+Pass SVG image, with natural width and height of 0, and aspect ratio from viewBox (with srcset/2x) (when not rendered)
+Fail SVG image, with natural width and height being negative, and aspect ratio from viewBox (with srcset/2x)
+Fail SVG image, with natural width and height being negative, and aspect ratio from viewBox (with srcset/2x) (when not rendered)
+Fail SVG image, with natural width matching default concrete object size (with srcset/2x)
+Fail SVG image, with natural width matching default concrete object size (with srcset/2x) (when not rendered)
+Fail SVG image, with natural height matching default concrete object size (with srcset/2x)
+Fail SVG image, with natural height matching default concrete object size (with srcset/2x) (when not rendered)
+Fail SVG image, with natural width matching default concrete object size, and aspect ratio from viewBox (with srcset/2x)
+Fail SVG image, with natural width matching default concrete object size, and aspect ratio from viewBox (with srcset/2x) (when not rendered)
+Fail SVG image, with natural height matching default concrete object size, and aspect ratio from viewBox (with srcset/2x)
+Fail SVG image, with natural height matching default concrete object size, and aspect ratio from viewBox (with srcset/2x) (when not rendered)
+Pass SVG image, with natural width and height matching default concrete object size (with srcset/2x)
+Pass SVG image, with natural width and height matching default concrete object size (with srcset/2x) (when not rendered)
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-img-element/relevant-mutations.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-img-element/relevant-mutations.txt
new file mode 100644
index 00000000000..e44808cb1a0
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-img-element/relevant-mutations.txt
@@ -0,0 +1,119 @@
+Harness status: OK
+
+Found 113 tests
+
+83 Pass
+30 Fail
+Pass src set
+Pass src changed
+Pass src removed
+Pass srcset set
+Pass srcset changed
+Pass srcset removed
+Pass sizes set
+Pass sizes changed
+Pass sizes removed
+Pass src set to same value
+Pass crossorigin absent to empty, src absent
+Pass crossorigin absent to anonymous, src absent
+Pass crossorigin absent to use-credentials, src absent
+Pass crossorigin empty to absent, src absent
+Pass crossorigin empty to use-credentials, src absent
+Pass crossorigin anonymous to absent, src absent
+Pass crossorigin anonymous to use-credentials, src absent
+Pass crossorigin use-credentials to absent, src absent
+Pass crossorigin use-credentials to empty, src absent
+Pass crossorigin use-credentials to anonymous, src absent
+Pass crossorigin use-credentials to invalid, src absent
+Fail crossorigin absent to empty, src already set
+Fail crossorigin absent to anonymous, src already set
+Fail crossorigin absent to use-credentials, src already set
+Fail crossorigin empty to absent, src already set
+Fail crossorigin empty to use-credentials, src already set
+Fail crossorigin anonymous to absent, src already set
+Fail crossorigin anonymous to use-credentials, src already set
+Fail crossorigin use-credentials to absent, src already set
+Fail crossorigin use-credentials to empty, src already set
+Fail crossorigin use-credentials to anonymous, src already set
+Fail crossorigin use-credentials to invalid, src already set
+Pass referrerpolicy absent to no-referrer-when-downgrade, src absent
+Pass referrerpolicy absent to no-referrer, src absent
+Pass referrerpolicy empty to no-referrer-when-downgrade, src absent
+Pass referrerpolicy empty to no-referrer, src absent
+Pass referrerpolicy no-referrer-when-downgrade to absent, src absent
+Pass referrerpolicy no-referrer-when-downgrade to empty, src absent
+Pass referrerpolicy no-referrer-when-downgrade to no-referrer, src absent
+Pass referrerpolicy no-referrer-when-downgrade to invalid, src absent
+Pass referrerpolicy no-referrer to absent, src absent
+Pass referrerpolicy no-referrer to empty, src absent
+Pass referrerpolicy no-referrer to no-referrer-when-downgrade, src absent
+Pass referrerpolicy no-referrer to invalid, src absent
+Fail referrerpolicy absent to no-referrer-when-downgrade, src already set
+Fail referrerpolicy absent to no-referrer, src already set
+Fail referrerpolicy empty to no-referrer-when-downgrade, src already set
+Fail referrerpolicy empty to no-referrer, src already set
+Fail referrerpolicy no-referrer-when-downgrade to absent, src already set
+Fail referrerpolicy no-referrer-when-downgrade to empty, src already set
+Fail referrerpolicy no-referrer-when-downgrade to no-referrer, src already set
+Fail referrerpolicy no-referrer-when-downgrade to invalid, src already set
+Fail referrerpolicy no-referrer to absent, src already set
+Fail referrerpolicy no-referrer to empty, src already set
+Fail referrerpolicy no-referrer to no-referrer-when-downgrade, src already set
+Fail referrerpolicy no-referrer to invalid, src already set
+Fail inserted into picture
+Fail removed from picture
+Pass parent is picture, previous source inserted
+Pass parent is picture, previous source removed
+Pass parent is picture, previous source has srcset set
+Pass parent is picture, previous source has srcset changed
+Pass parent is picture, previous source has srcset removed
+Pass parent is picture, previous source has sizes set
+Pass parent is picture, previous source has sizes changed
+Pass parent is picture, previous source has sizes removed
+Pass parent is picture, previous source has media set
+Pass parent is picture, previous source has media changed
+Pass parent is picture, previous source has media removed
+Pass parent is picture, previous source has type set
+Pass parent is picture, previous source has type changed
+Pass parent is picture, previous source has type removed
+Pass srcset is set to same value
+Fail sizes is set to same value
+Pass crossorigin state not changed: absent, removeAttribute
+Pass crossorigin state not changed: empty to anonymous
+Pass crossorigin state not changed: anonymous to foobar
+Pass crossorigin state not changed: use-credentials to USE-CREDENTIALS
+Pass referrerpolicy state not changed: absent, removeAttribute
+Pass referrerpolicy state not changed: empty to empty
+Pass referrerpolicy state not changed: empty to invalid
+Pass referrerpolicy state not changed: absent to invalid
+Pass referrerpolicy state not changed: no-referrer to NO-REFERRER
+Pass referrerpolicy state not changed: invalid to other-invalid
+Pass inserted into picture ancestor
+Pass removed from picture ancestor
+Pass ancestor picture has a source inserted
+Pass ancestor picture has a source removed
+Pass ancestor picture; previous sibling source inserted
+Pass ancestor picture; previous sibling source removed
+Fail parent is picture, following sibling source inserted
+Fail parent is picture, following sibling source removed
+Pass parent is picture, following sibling source has srcset set
+Pass media on img set
+Pass type on img set
+Pass class on img set
+Pass alt on img set
+Pass src on previous sibling source set
+Pass class on previous sibling source set
+Pass inserted/removed children of img
+Pass picture is inserted; img has src
+Pass picture is inserted; img has srcset
+Fail picture is inserted; img has previous sibling source
+Fail picture is inserted; img has following sibling source
+Pass picture is removed; img has src
+Pass picture is removed; img has srcset
+Pass picture is removed; img has previous sibling source
+Pass picture is removed; img has following sibling source
+Pass parent is picture, following img inserted
+Pass parent is picture, following img removed
+Pass parent is picture, following img has src set
+Pass parent is picture, following img has srcset set
+Pass parent is picture, following img has sizes set
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-img-element/sizes/sizes-auto.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-img-element/sizes/sizes-auto.txt
new file mode 100644
index 00000000000..9d21a2967c2
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-img-element/sizes/sizes-auto.txt
@@ -0,0 +1,80 @@
+Harness status: OK
+
+Found 74 tests
+
+38 Pass
+36 Fail
+Pass <img sizes="1px" data-ref="ref1" srcset="/images/green-1x1.png?img1 50w, /images/green-16x16.png?img1 51w">
+Pass <picture><source sizes="1px" srcset="/images/green-1x1.png?picture1 50w, /images/green-16x16.png?picture1 51w"><img data-ref="ref1"></picture>
+Pass <img sizes="" data-ref="ref2" srcset="/images/green-1x1.png?img2 50w, /images/green-16x16.png?img2 51w">
+Pass <picture><source sizes="" srcset="/images/green-1x1.png?picture2 50w, /images/green-16x16.png?picture2 51w"><img data-ref="ref2"></picture>
+Fail <img loading="lazy" sizes="auto" width="10" data-ref="ref1" srcset="/images/green-1x1.png?img3 50w, /images/green-16x16.png?img3 51w">
+Fail <picture><source srcset="/images/green-1x1.png?picture3 50w, /images/green-16x16.png?picture3 51w"><img loading="lazy" sizes="auto" width="10" data-ref="ref1"></picture>
+Fail <img loading="lazy" sizes="AUTO" width="10" data-ref="ref1" srcset="/images/green-1x1.png?img4 50w, /images/green-16x16.png?img4 51w">
+Fail <picture><source srcset="/images/green-1x1.png?picture4 50w, /images/green-16x16.png?picture4 51w"><img loading="lazy" sizes="AUTO" width="10" data-ref="ref1"></picture>
+Pass <img loading="lazy" width="10" data-ref="ref2" srcset="/images/green-1x1.png?img5 50w, /images/green-16x16.png?img5 51w">
+Pass <picture><source srcset="/images/green-1x1.png?picture5 50w, /images/green-16x16.png?picture5 51w"><img loading="lazy" width="10" data-ref="ref2"></picture>
+Pass <img loading="lazy" style="width: 10px" data-ref="ref2" srcset="/images/green-1x1.png?img6 50w, /images/green-16x16.png?img6 51w">
+Pass <picture><source srcset="/images/green-1x1.png?picture6 50w, /images/green-16x16.png?picture6 51w"><img loading="lazy" style="width: 10px" data-ref="ref2"></picture>
+Pass <img loading="lazy" style="max-width: 10px" data-ref="ref2" srcset="/images/green-1x1.png?img7 50w, /images/green-16x16.png?img7 51w">
+Pass <picture><source srcset="/images/green-1x1.png?picture7 50w, /images/green-16x16.png?picture7 51w"><img loading="lazy" style="max-width: 10px" data-ref="ref2"></picture>
+Pass <img loading="lazy" style="width: 100%; max-width: 10px" data-ref="ref2" srcset="/images/green-1x1.png?img8 50w, /images/green-16x16.png?img8 51w">
+Pass <picture><source srcset="/images/green-1x1.png?picture8 50w, /images/green-16x16.png?picture8 51w"><img loading="lazy" style="width: 100%; max-width: 10px" data-ref="ref2"></picture>
+Pass <img loading="lazy" sizes="auto" width="500" data-ref="ref2" srcset="/images/green-1x1.png?img9 50w, /images/green-16x16.png?img9 51w">
+Pass <picture><source srcset="/images/green-1x1.png?picture9 50w, /images/green-16x16.png?picture9 51w"><img loading="lazy" sizes="auto" width="500" data-ref="ref2"></picture>
+Fail <img loading="lazy" sizes="auto" width="10" style="visibility: hidden" data-ref="ref1" srcset="/images/green-1x1.png?img10 50w, /images/green-16x16.png?img10 51w">
+Fail <picture><source srcset="/images/green-1x1.png?picture10 50w, /images/green-16x16.png?picture10 51w"><img loading="lazy" sizes="auto" width="10" style="visibility: hidden" data-ref="ref1"></picture>
+Fail <img loading="lazy" sizes="auto" width="10" style="display: inline" hidden="" data-ref="ref1" srcset="/images/green-1x1.png?img11 50w, /images/green-16x16.png?img11 51w">
+Fail <picture><source srcset="/images/green-1x1.png?picture11 50w, /images/green-16x16.png?picture11 51w"><img loading="lazy" sizes="auto" width="10" style="display: inline" hidden="" data-ref="ref1"></picture>
+Fail <img loading="lazy" sizes="auto" width="0" data-ref="ref1" srcset="/images/green-1x1.png?img12 50w, /images/green-16x16.png?img12 51w">
+Fail <picture><source srcset="/images/green-1x1.png?picture12 50w, /images/green-16x16.png?picture12 51w"><img loading="lazy" sizes="auto" width="0" data-ref="ref1"></picture>
+Fail <img loading="lazy" sizes="auto" style="width: 0px" data-ref="ref1" srcset="/images/green-1x1.png?img13 50w, /images/green-16x16.png?img13 51w">
+Fail <picture><source srcset="/images/green-1x1.png?picture13 50w, /images/green-16x16.png?picture13 51w"><img loading="lazy" sizes="auto" style="width: 0px" data-ref="ref1"></picture>
+Pass <img loading="lazy" sizes="auto" data-ref="ref2" srcset="/images/green-1x1.png?img14 50w, /images/green-16x16.png?img14 51w">
+Pass <picture><source srcset="/images/green-1x1.png?picture14 50w, /images/green-16x16.png?picture14 51w"><img loading="lazy" sizes="auto" data-ref="ref2"></picture>
+Fail <img loading="lazy" sizes="auto, 100vw" width="10" data-ref="ref1" srcset="/images/green-1x1.png?img15 50w, /images/green-16x16.png?img15 51w">
+Fail <picture><source srcset="/images/green-1x1.png?picture15 50w, /images/green-16x16.png?picture15 51w"><img loading="lazy" sizes="auto, 100vw" width="10" data-ref="ref1"></picture>
+Pass <img loading="lazy" sizes="100vw, auto" width="10" data-ref="ref2" srcset="/images/green-1x1.png?img16 50w, /images/green-16x16.png?img16 51w">
+Pass <picture><source sizes="100vw, auto" srcset="/images/green-1x1.png?picture16 50w, /images/green-16x16.png?picture16 51w"><img loading="lazy" width="10" data-ref="ref2"></picture>
+Pass <img loading="eager" sizes="auto" width="10" data-ref="ref2" srcset="/images/green-1x1.png?img17 50w, /images/green-16x16.png?img17 51w">
+Pass <picture><source srcset="/images/green-1x1.png?picture17 50w, /images/green-16x16.png?picture17 51w"><img loading="eager" sizes="auto" width="10" data-ref="ref2"></picture>
+Fail <img loading="lazy" sizes="auto" width="100%" data-ref="ref1" srcset="/images/green-1x1.png?img18 50w, /images/green-16x16.png?img18 51w">
+Fail <picture><source srcset="/images/green-1x1.png?picture18 50w, /images/green-16x16.png?picture18 51w"><img loading="lazy" sizes="auto" width="100%" data-ref="ref1"></picture>
+Pass <img loading="lazy" sizes="auto" width="100%" data-ref="ref2" srcset="/images/green-1x1.png?img19 50w, /images/green-16x16.png?img19 51w">
+Pass <picture><source srcset="/images/green-1x1.png?picture19 50w, /images/green-16x16.png?picture19 51w"><img loading="lazy" sizes="auto" width="100%" data-ref="ref2"></picture>
+Fail <img loading="lazy" sizes="auto" style="height: 10px; aspect-ratio: 10 / 10" data-ref="ref1" srcset="/images/green-1x1.png?img20 50w, /images/green-16x16.png?img20 51w">
+Fail <picture><source srcset="/images/green-1x1.png?picture20 50w, /images/green-16x16.png?picture20 51w"><img loading="lazy" sizes="auto" style="height: 10px; aspect-ratio: 10 / 10" data-ref="ref1"></picture>
+Pass <img loading="lazy" sizes="auto" style="height: 10px; aspect-ratio: 500 / 10" data-ref="ref2" srcset="/images/green-1x1.png?img21 50w, /images/green-16x16.png?img21 51w">
+Pass <picture><source srcset="/images/green-1x1.png?picture21 50w, /images/green-16x16.png?picture21 51w"><img loading="lazy" sizes="auto" style="height: 10px; aspect-ratio: 500 / 10" data-ref="ref2"></picture>
+Fail <img loading="lazy" sizes="auto" style="min-height: 10px; aspect-ratio: 10 / 10" data-ref="ref1" srcset="/images/green-1x1.png?img22 50w, /images/green-16x16.png?img22 51w">
+Fail <picture><source srcset="/images/green-1x1.png?picture22 50w, /images/green-16x16.png?picture22 51w"><img loading="lazy" sizes="auto" style="min-height: 10px; aspect-ratio: 10 / 10" data-ref="ref1"></picture>
+Pass <img loading="lazy" sizes="auto" style="min-height: 10px; aspect-ratio: 500 / 10" data-ref="ref2" srcset="/images/green-1x1.png?img23 50w, /images/green-16x16.png?img23 51w">
+Pass <picture><source srcset="/images/green-1x1.png?picture23 50w, /images/green-16x16.png?picture23 51w"><img loading="lazy" sizes="auto" style="min-height: 10px; aspect-ratio: 500 / 10" data-ref="ref2"></picture>
+Fail <img loading="lazy" sizes="auto" style="inline-size: 10px" data-ref="ref1" srcset="/images/green-1x1.png?img24 50w, /images/green-16x16.png?img24 51w">
+Fail <picture><source srcset="/images/green-1x1.png?picture24 50w, /images/green-16x16.png?picture24 51w"><img loading="lazy" sizes="auto" style="inline-size: 10px" data-ref="ref1"></picture>
+Pass <img loading="lazy" sizes="auto" style="min-inline-size: 10px" data-ref="ref2" srcset="/images/green-1x1.png?img25 50w, /images/green-16x16.png?img25 51w">
+Pass <picture><source srcset="/images/green-1x1.png?picture25 50w, /images/green-16x16.png?picture25 51w"><img loading="lazy" sizes="auto" style="min-inline-size: 10px" data-ref="ref2"></picture>
+Fail <img loading="lazy" sizes="auto" style="block-size: 10px; aspect-ratio: 10 / 10" data-ref="ref1" srcset="/images/green-1x1.png?img26 50w, /images/green-16x16.png?img26 51w">
+Fail <picture><source srcset="/images/green-1x1.png?picture26 50w, /images/green-16x16.png?picture26 51w"><img loading="lazy" sizes="auto" style="block-size: 10px; aspect-ratio: 10 / 10" data-ref="ref1"></picture>
+Fail <img loading="lazy" sizes="auto" style="min-block-size: 10px; aspect-ratio: 10 / 10" data-ref="ref1" srcset="/images/green-1x1.png?img27 50w, /images/green-16x16.png?img27 51w">
+Fail <picture><source srcset="/images/green-1x1.png?picture27 50w, /images/green-16x16.png?picture27 51w"><img loading="lazy" sizes="auto" style="min-block-size: 10px; aspect-ratio: 10 / 10" data-ref="ref1"></picture>
+Fail <img loading="lazy" sizes="auto" style="block-size: 10px; writing-mode: vertical-rl" data-ref="ref1" srcset="/images/green-1x1.png?img28 50w, /images/green-16x16.png?img28 51w">
+Fail <picture><source srcset="/images/green-1x1.png?picture28 50w, /images/green-16x16.png?picture28 51w"><img loading="lazy" sizes="auto" style="block-size: 10px; writing-mode: vertical-rl" data-ref="ref1"></picture>
+Pass <img loading="lazy" sizes="auto" style="min-block-size: 10px; writing-mode: vertical-rl" data-ref="ref2" srcset="/images/green-1x1.png?img29 50w, /images/green-16x16.png?img29 51w">
+Pass <picture><source srcset="/images/green-1x1.png?picture29 50w, /images/green-16x16.png?picture29 51w"><img loading="lazy" sizes="auto" style="min-block-size: 10px; writing-mode: vertical-rl" data-ref="ref2"></picture>
+Fail <img loading="lazy" sizes="auto" style="inline-size: 10px; aspect-ratio: 10/10; writing-mode: vertical-rl" data-ref="ref1" srcset="/images/green-1x1.png?img30 50w, /images/green-16x16.png?img30 51w">
+Fail <picture><source srcset="/images/green-1x1.png?picture30 50w, /images/green-16x16.png?picture30 51w"><img loading="lazy" sizes="auto" style="inline-size: 10px; aspect-ratio: 10/10; writing-mode: vertical-rl" data-ref="ref1"></picture>
+Fail <img loading="lazy" sizes="auto" style="min-inline-size: 10px; aspect-ratio: 10/10; writing-mode: vertical-rl" data-ref="ref1" srcset="/images/green-1x1.png?img31 50w, /images/green-16x16.png?img31 51w">
+Fail <picture><source srcset="/images/green-1x1.png?picture31 50w, /images/green-16x16.png?picture31 51w"><img loading="lazy" sizes="auto" style="min-inline-size: 10px; aspect-ratio: 10/10; writing-mode: vertical-rl" data-ref="ref1"></picture>
+Fail <img loading="lazy" sizes="auto" style="--my-width: 10px; width: var(--my-width)" data-ref="ref1" srcset="/images/green-1x1.png?img32 50w, /images/green-16x16.png?img32 51w">
+Fail <picture><source srcset="/images/green-1x1.png?picture32 50w, /images/green-16x16.png?picture32 51w"><img loading="lazy" sizes="auto" style="--my-width: 10px; width: var(--my-width)" data-ref="ref1"></picture>
+Fail <img loading="lazy" sizes="auto" style="width: calc(5px + 5px)" data-ref="ref1" srcset="/images/green-1x1.png?img33 50w, /images/green-16x16.png?img33 51w">
+Fail <picture><source srcset="/images/green-1x1.png?picture33 50w, /images/green-16x16.png?picture33 51w"><img loading="lazy" sizes="auto" style="width: calc(5px + 5px)" data-ref="ref1"></picture>
+Pass <img loading="lazy" sizes="auto" style="position: absolute; left: 50%; right: 49%" data-ref="ref2" srcset="/images/green-1x1.png?img34 50w, /images/green-16x16.png?img34 51w">
+Pass <picture><source srcset="/images/green-1x1.png?picture34 50w, /images/green-16x16.png?picture34 51w"><img loading="lazy" sizes="auto" style="position: absolute; left: 50%; right: 49%" data-ref="ref2"></picture>
+Pass <img loading="lazy" sizes="(max-width: 0px) 10px, auto" style="width: 10px" data-ref="ref2" srcset="/images/green-1x1.png?img35 50w, /images/green-16x16.png?img35 51w">
+Pass <picture><source sizes="(max-width: 0px) 10px, auto" srcset="/images/green-1x1.png?picture35 50w, /images/green-16x16.png?picture35 51w"><img loading="lazy" style="width: 10px" data-ref="ref2"></picture>
+Pass <img loading="lazy" sizes="(min-width: 0px) auto" style="width: 10px" data-ref="ref2" srcset="/images/green-1x1.png?img36 50w, /images/green-16x16.png?img36 51w">
+Pass <picture><source sizes="(min-width: 0px) auto" srcset="/images/green-1x1.png?picture36 50w, /images/green-16x16.png?picture36 51w"><img loading="lazy" style="width: 10px" data-ref="ref2"></picture>
+Pass <img loading="lazy" sizes="(min-width: 0px) 100vw, auto" style="width: 10px" data-ref="ref2" srcset="/images/green-1x1.png?img37 50w, /images/green-16x16.png?img37 51w">
+Pass <picture><source sizes="(min-width: 0px) 100vw, auto" srcset="/images/green-1x1.png?picture37 50w, /images/green-16x16.png?picture37 51w"><img loading="lazy" style="width: 10px" data-ref="ref2"></picture>
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-img-element/naturalWidth-naturalHeight-width-height.html b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-img-element/naturalWidth-naturalHeight-width-height.html
new file mode 100644
index 00000000000..b5ba92d6ee0
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-img-element/naturalWidth-naturalHeight-width-height.html
@@ -0,0 +1,430 @@
+<!doctype html>
+<head>
+<meta charset="utf-8">
+<title>HTMLImageElement attributes naturalWidth, naturalHeight, width, height</title>
+<link rel="help" href="https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-naturalwidth-dev">
+<link rel="help" href="https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-width">
+<link rel="help" href="https://html.spec.whatwg.org/multipage/images.html#density-corrected-intrinsic-width-and-height">
+<link rel="help" href="https://drafts.csswg.org/css-images/#natural-dimensions">
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<style>
+#scroller {
+ /* We wrap all the test content in a scroller so that it doesn't push
+ * the textual test-results too far out of view.
+ */
+ border: 1px solid black;
+ height: 400px;
+ width: max-content;
+ overflow: scroll;
+}
+#containingBlock {
+ /* There are a few SVG images here that size so that their margin-box fills
+ * their containing block width. We define a specific size here so that we
+ * can then check for it (minus the margins) in the "data-width" attribute.
+ */
+ width: 740px;
+}
+img {
+ /* This styling is just cosmetic, to help visualize the images. */
+ border: 5px solid teal;
+ margin: 5px;
+ display: block;
+}
+</style>
+<!-- We specify the img elements in a <template> and then clone them for
+ testing, so that we can dynamically generate and test several variants
+ of each img. -->
+<template id="imgTemplates">
+<!-- For each img element:
+ * The "data-natural-{width,height}" attributes represent the expected
+ values of the img element's "naturalWidth" and "naturalHeight" IDL
+ attributes. This test implicitly expects the "width" and "height" IDL
+ attributes to have those same expected values; but in cases where that's
+ not correct, we provide the actual expected value in the
+ "data-{width,height}" attributes (as distinguished from
+ data-natural-{width,height}).
+ * The "data-not-rendered-{width,height}" attributes are the same thing,
+ but for when the img is not being rendered. These and "data-{width,height}"
+ both default to "data-natural-{width,height}", so an expectation that only
+ applies while rendered, such as an img stretched by its containing block, is
+ encoded by specifying "data-{width,height}" and leaving
+ "data-not-rendered-{width,height}" out. A width/height content attribute is
+ reported either way, so those cases specify the same value twice.
+ * The "data-density" attribute indicates which natural dimensions are
+ SVG-intrinsic (and thus should be density-corrected): "both" (default for
+ raster), "width", "height", or "none". Default dimensions (300x150) and
+ dimensions derived from fitting an aspect ratio into the default object
+ size are not density-corrected.
+ * The "title" attribute is a description of the scenario being tested, and
+ it must be unique to satisfy the test harness requirements. -->
+
+<!-- JPG images -->
+<img src="resources/cat.jpg"
+ title="raster image"
+ data-natural-width="320" data-natural-height="240">
+<img src="resources/cat.jpg" width="10" height="10"
+ title="raster image with width/height attributes"
+ data-natural-width="320" data-natural-height="240"
+ data-width="10" data-height="10"
+ data-not-rendered-width="10" data-not-rendered-height="10">
+<!-- Use "size-comes-from-broken-image-icon" attribute to opt out of checking
+ img.width and img.height, because they come from the UA-dependent
+ size of the broken image icon: -->
+<img src="non-existent.jpg"
+ title="non existent image, no natural dimensions"
+ data-natural-width="0" data-natural-height="0"
+ size-comes-from-broken-image-icon>
+<img src="non-existent.jpg" width="10" height="10"
+ title="non existent image with width/height attributes, no natural dimensions"
+ data-natural-width="0" data-natural-height="0"
+ data-width="10" data-height="10"
+ data-not-rendered-width="10" data-not-rendered-height="10">
+
+<!-- First group of SVG images: no viewBox, with a missing (or edge-casey, i.e.
+ negative or percent-valued) value for the width and/or height attr on the
+ root svg element in a SVG image. -->
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>"
+ title="SVG image, no natural dimensions"
+ data-density="none"
+ data-natural-width="300" data-natural-height="150">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>"
+ width="40" height="10"
+ data-width="40" data-height="10"
+ data-not-rendered-width="40" data-not-rendered-height="10"
+ title="SVG image with width/height attrs, no natural dimensions"
+ data-density="none"
+ data-natural-width="300" data-natural-height="150">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>"
+ width="40"
+ data-width="40" data-not-rendered-width="40"
+ title="SVG image with width attr, no natural dimensions"
+ data-density="none"
+ data-natural-width="300" data-natural-height="150">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>"
+ height="10"
+ data-height="10" data-not-rendered-height="10"
+ title="SVG image with height attr, no natural dimensions"
+ data-density="none"
+ data-natural-width="300" data-natural-height="150">
+<!-- Note: percent values can't be resolved when determining natural
+ dimensions, so the exact percentage shouldn't matter. -->
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='400%' height='10%'></svg>"
+ title="SVG image, percengage natural dimensions"
+ data-density="none"
+ data-natural-width="300" data-natural-height="150">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='-400%' height='-10%'></svg>"
+ title="SVG image, negative percengage natural dimensions"
+ data-density="none"
+ data-natural-width="300" data-natural-height="150">
+<!-- If only one attribute is present, it should show up as a natural
+ dimension, without influencing the other natural dimension. -->
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='60'></svg>"
+ title="SVG image, with natural width"
+ data-density="width"
+ data-natural-width="60" data-natural-height="150">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' height='60'></svg>"
+ title="SVG image, with natural height"
+ data-density="height"
+ data-natural-width="300" data-natural-height="60">
+<!-- If either attribute is 0 or a negative length, it should show up as a
+ natural dimension: of 0. -->
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='0'></svg>"
+ title="SVG image, with natural width of 0"
+ data-density="width"
+ data-natural-width="0" data-natural-height="150">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' height='0'></svg>"
+ title="SVG image, with natural height of 0"
+ data-density="height"
+ data-natural-width="300" data-natural-height="0">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='-5'></svg>"
+ title="SVG image, with natural width being negative"
+ data-density="none"
+ data-natural-width="300" data-natural-height="150">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' height='-5'></svg>"
+ title="SVG image, with natural height being negative"
+ data-density="none"
+ data-natural-width="300" data-natural-height="150">
+
+<!-- Second group of SVG images: Same as above, but now with a viewBox that grants a
+ 3:1 aspect-ratio; whenever we know one natural dimension, that should
+ combine with the aspect ratio to produce the other natural dimension.
+
+ NOTE: for a few subtests here, the image ends up expanding to fill the
+ containing block's width, i.e. rendering at a larger size than its natural
+ size. In those cases, we include 'data-width' & 'data-height' attributes,
+ so that this test's JS can validate that img.width and img.height return
+ these expected larger values. (Otherwise, we expect img.width and
+ img.height to return the same values as img.naturalWidth and
+ img.naturalHeight). -->
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 200'></svg>"
+ title="SVG image, no natural dimensions, and aspect ratio from viewBox"
+ data-density="none"
+ data-natural-width="300" data-natural-height="100"
+ data-width="720" data-height="240">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='400%' height='10%' viewBox='0 0 600 200'></svg>"
+ title="SVG image, percengage natural dimensions, and aspect ratio from viewBox"
+ data-density="none"
+ data-natural-width="300" data-natural-height="100"
+ data-width="720" data-height="240">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='-400%' height='-10%' viewBox='0 0 600 200'></svg>"
+ title="SVG image, negative percengage natural dimensions, and aspect ratio from viewBox"
+ data-density="none"
+ data-natural-width="300" data-natural-height="100"
+ data-width="720" data-height="240">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='60' viewBox='0 0 600 200'></svg>"
+ title="SVG image, with natural width, and aspect ratio from viewBox"
+ data-density="both"
+ data-natural-width="60" data-natural-height="20">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' height='60' viewBox='0 0 600 200'></svg>"
+ title="SVG image, with natural height, and aspect ratio from viewBox"
+ data-density="both"
+ data-natural-width="180" data-natural-height="60">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='0' viewBox='0 0 600 200'></svg>"
+ title="SVG image, with natural width of 0, and aspect ratio from viewBox"
+ data-density="both"
+ data-natural-width="0" data-natural-height="0">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' height='0' viewBox='0 0 600 200'></svg>"
+ title="SVG image, with natural height of 0, and aspect ratio from viewBox"
+ data-density="both"
+ data-natural-width="0" data-natural-height="0">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='-5' viewBox='0 0 600 200'></svg>"
+ title="SVG image, with natural width being negative, and aspect ratio from viewBox"
+ data-density="none"
+ data-natural-width="300" data-natural-height="100"
+ data-width="720" data-height="240">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' height='-5' viewBox='0 0 600 200'></svg>"
+ title="SVG image, with natural height being negative, and aspect ratio from viewBox"
+ data-density="none"
+ data-natural-width="300" data-natural-height="100"
+ data-width="720" data-height="240">
+
+<!-- Third group of SVG images: Check a degenerate 0-sized viewBox for some of the
+ cases; it should have no impact. -->
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 0 0'></svg>"
+ title="SVG image, no natural dimensions, viewBox with 0 width/height"
+ data-density="none"
+ data-natural-width="300" data-natural-height="150">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 0'></svg>"
+ title="SVG image, no natural dimensions, viewBox with 0 width"
+ data-density="none"
+ data-natural-width="300" data-natural-height="150">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 0 10'></svg>"
+ title="SVG image, no natural dimensions, viewBox with 0 height"
+ data-density="none"
+ data-natural-width="300" data-natural-height="150">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='60' viewBox='0 0 0 0'></svg>"
+ title="SVG image, with natural width, viewBox with 0 width/height"
+ data-density="width"
+ data-natural-width="60" data-natural-height="150">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='60' viewBox='0 0 10 0'></svg>"
+ title="SVG image, with natural width, viewBox with 0 width"
+ data-density="width"
+ data-natural-width="60" data-natural-height="150">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='60' viewBox='0 0 0 10'></svg>"
+ title="SVG image, with natural width, viewBox with 0 height"
+ data-density="width"
+ data-natural-width="60" data-natural-height="150">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' height='60' viewBox='0 0 0 0'></svg>"
+ title="SVG image, with natural height, viewBox with 0 width/height"
+ data-density="height"
+ data-natural-width="300" data-natural-height="60">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' height='60' viewBox='0 0 10 0'></svg>"
+ title="SVG image, with natural height, viewBox with 0 width"
+ data-density="height"
+ data-natural-width="300" data-natural-height="60">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' height='60' viewBox='0 0 0 10'></svg>"
+ title="SVG image, with natural height, viewBox with 0 height"
+ data-density="height"
+ data-natural-width="300" data-natural-height="60">
+
+<!--~- Final group of SVG images: we have pixel-valued width/height on the root
+ svg element, and possibly viewBox as well. The width and height attrs should
+ determine the natural dimensions, with no impact from viewBox. ---->
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='60' height='40'></svg>"
+ title="SVG image, with natural width and height"
+ data-density="both"
+ data-natural-width="60" data-natural-height="40">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='60' height='40' viewBox='0 0 600 200'></svg>"
+ title="SVG image, with natural width and height, and aspect ratio from viewBox"
+ data-density="both"
+ data-natural-width="60" data-natural-height="40">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='0' height='0' viewBox='0 0 600 200'></svg>"
+ title="SVG image, with natural width and height of 0, and aspect ratio from viewBox"
+ data-density="both"
+ data-natural-width="0" data-natural-height="0">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='-5' height='-5' viewBox='0 0 600 200'></svg>"
+ title="SVG image, with natural width and height being negative, and aspect ratio from viewBox"
+ data-density="none"
+ data-natural-width="300" data-natural-height="100"
+ data-width="720" data-height="240">
+
+<!-- SVG images with intrinsic dimensions that happen to match the default
+ concrete object size (300x150). This group screens for a possible bug
+ where a browser recognizes 300 and/or 150 as "special" values and
+ declines to density-correct them, mistakenly assuming they came from
+ the default concrete object size rather than from the SVG's own
+ intrinsic dimensions. -->
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='300'></svg>"
+ title="SVG image, with natural width matching default concrete object size"
+ data-density="width"
+ data-natural-width="300" data-natural-height="150">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' height='150'></svg>"
+ title="SVG image, with natural height matching default concrete object size"
+ data-density="height"
+ data-natural-width="300" data-natural-height="150">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='300' viewBox='0 0 300 150'></svg>"
+ title="SVG image, with natural width matching default concrete object size, and aspect ratio from viewBox"
+ data-density="both"
+ data-natural-width="300" data-natural-height="150">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' height='150' viewBox='0 0 300 150'></svg>"
+ title="SVG image, with natural height matching default concrete object size, and aspect ratio from viewBox"
+ data-density="both"
+ data-natural-width="300" data-natural-height="150">
+<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='150'></svg>"
+ title="SVG image, with natural width and height matching default concrete object size"
+ data-density="both"
+ data-natural-width="300" data-natural-height="150">
+</template>
+</head>
+<body>
+<div id="scroller">
+ <div id="containingBlock">
+ </div>
+</div>
+<!-- We generate and append all of the tested <img> elements while we're inside
+ the <body>, so that all of the <img> elements' "load" events will block
+ the window onload event: -->
+<script>
+setup({explicit_done:true});
+
+// Utility function to generate a clone of imgTemplates using "srcset" and a
+// given density value, with expectations adjusted per the density:
+function cloneTemplateWithDensity(density) {
+ if (typeof(density) !== "number" || density <= 0) {
+ // If we get here, there's a bug in the test itself; throw an exception:
+ throw new Error("test error: param should be a positive number");
+ }
+ let clone = imgTemplates.content.cloneNode("true");
+
+ for (let img of clone.children) {
+ // Swap out "src" for "srcset":
+ // The srcset attribute uses a space-separated list of tokens,
+ // so we need to encode any spaces that are in the URI itself
+ // before we put it in srcset:
+ let srcVal = img.getAttribute("src").replaceAll(" ", "%20");
+ img.removeAttribute("src");
+ img.setAttribute("srcSet", `${srcVal} ${density}x`);
+
+ // Mention the density in the 'title' to keep the title values unique:
+ img.setAttribute("title",
+ `${img.getAttribute("title")} (with srcset/${density}x)`);
+
+ // Determine which dimensions are density-corrected. For raster images
+ // (no data-density attribute), both dimensions are always corrected.
+ // For SVG images, only intrinsic (non-default) dimensions are corrected.
+ const densityAttr = img.dataset.density || "both";
+ const validDensityValues = ["none", "both", "width", "height"];
+ if (!validDensityValues.includes(densityAttr)) {
+ throw new Error(`test error: data-density="${densityAttr}" on "${img.getAttribute("title")}" is not a recognized value (expected one of: ${validDensityValues})`);
+ }
+ const scaleWidth = (densityAttr === "both" || densityAttr === "width");
+ const scaleHeight = (densityAttr === "both" || densityAttr === "height");
+
+ // Scale our 'data-natural-{width,height}' expectations by the density,
+ // but only for dimensions that are density-corrected (i.e., derived from
+ // the image's own intrinsic dimensions, not from the default object size).
+ for (let name in img.dataset) {
+ if (name.startsWith("natural")) {
+ let origExpectation = img.dataset[name];
+
+ let isWidthAxis = (name == "naturalWidth");
+ let shouldScale = isWidthAxis ? scaleWidth : scaleHeight;
+
+ // Scale our img.natural{Width,Height} expectation:
+ if (shouldScale) {
+ img.dataset[name] = origExpectation / density;
+ }
+ }
+ }
+ }
+ return clone;
+}
+
+// Clone and append a copy of the contents of imgTemplates, for testing:
+let clone = imgTemplates.content.cloneNode("true");
+containingBlock.appendChild(clone);
+
+// Append additional clones, modified to use srcset with specified density.
+// Note:
+// * '1' is the trivial case; we're just testing that for completeness,
+// to be sure there aren't any unexpected differences between
+// <img src="..."> and <img srcset="... 1x">).
+// * It's best for whatever density we test here to be something that evenly
+// divides all of the image sizes in this test (so 1 and 2 are easy choices).
+containingBlock.appendChild(cloneTemplateWithDensity(1));
+containingBlock.appendChild(cloneTemplateWithDensity(2));
+
+// After all the img elements have loaded (indicated by the window load event),
+// we run the various tests:
+onload = function() {
+ Array.from(document.images).forEach(img => {
+ const expectedNaturalWidth = parseFloat(img.dataset.naturalWidth);
+ const expectedNaturalHeight = parseFloat(img.dataset.naturalHeight);
+
+ test(function() {
+ // We expect naturalWidth to match the provided data-natural-width
+ // (and similar for 'height').
+ assert_equals(img.naturalWidth, expectedNaturalWidth, 'naturalWidth');
+ assert_equals(img.naturalHeight, expectedNaturalHeight, 'naturalHeight');
+
+ let shouldCheckWidthAndHeight =
+ !img.hasAttribute("size-comes-from-broken-image-icon");
+
+ if (shouldCheckWidthAndHeight) {
+ // If 'data-width' is provided, then we expect img.width to match it.
+ // Otherwise we expect img.width to match the 'data-natural-width'.
+ // (And similar for 'height'.)
+ const expectedWidth = 'width' in img.dataset ?
+ parseFloat(img.dataset.width) : expectedNaturalWidth;
+ const expectedHeight = 'height' in img.dataset ?
+ parseFloat(img.dataset.height) : expectedNaturalHeight;
+ assert_equals(img.width, expectedWidth, 'width');
+ assert_equals(img.height, expectedHeight, 'height');
+ }
+ }, `${img.title}`);
+
+ test(function() {
+ // Now test what we get when the img is not rendered.
+ // * naturalWidth and naturalHeight shouldn't change.
+ // * width and height should generally match naturalWidth and
+ // naturalHeight, except that the width and height content attributes
+ // (if present and parseable) take precedence, per axis. Those cases are
+ // indicated via the 'data-not-rendered-{width,height}' attributes.
+ this.add_cleanup(function() {
+ img.style.display = "";
+ });
+
+ img.style.display = "none";
+ img.getBoundingClientRect(); // Flush layout.
+
+ assert_equals(img.naturalWidth, expectedNaturalWidth,
+ 'naturalWidth when not rendered');
+ assert_equals(img.naturalHeight, expectedNaturalHeight,
+ 'naturalHeight when not rendered');
+
+ const expectedNotRenderedWidth = 'notRenderedWidth' in img.dataset ?
+ parseFloat(img.dataset.notRenderedWidth) : expectedNaturalWidth;
+ const expectedNotRenderedHeight = 'notRenderedHeight' in img.dataset ?
+ parseFloat(img.dataset.notRenderedHeight) : expectedNaturalHeight;
+
+ assert_equals(img.width, expectedNotRenderedWidth,
+ 'width when not rendered');
+ assert_equals(img.height, expectedNotRenderedHeight,
+ 'height when not rendered');
+ }, `${img.title} (when not rendered)`);
+ });
+ done();
+};
+</script>
+</body>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-img-element/relevant-mutations.html b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-img-element/relevant-mutations.html
new file mode 100644
index 00000000000..71d0ce05e89
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-img-element/relevant-mutations.html
@@ -0,0 +1,628 @@
+<!doctype html>
+<title>img relevant mutations</title>
+<meta name="timeout" content="long">
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<script src="support/relevant-mutations.js"></script>
+<div id=log></div>
+
+<!-- should invoke update the image data -->
+
+<img data-desc="src set">
+<img src="../../../../images/green-2x2.png" data-desc="src changed">
+<img src="../../../../images/green-2x2.png" data-desc="src removed">
+
+<img data-desc="srcset set">
+<img srcset="../../../../images/green-2x2.png" data-desc="srcset changed">
+<img srcset="../../../../images/green-2x2.png" data-desc="srcset removed">
+
+<img data-desc="sizes set">
+<img sizes="" data-desc="sizes changed">
+<img sizes="" data-desc="sizes removed">
+
+<img src="../../../../images/green-2x2.png" data-desc="src set to same value">
+
+<img data-desc="crossorigin absent to empty, src absent">
+<img data-desc="crossorigin absent to anonymous, src absent">
+<img data-desc="crossorigin absent to use-credentials, src absent">
+<img crossorigin data-desc="crossorigin empty to absent, src absent">
+<img crossorigin data-desc="crossorigin empty to use-credentials, src absent">
+<img crossorigin=anonymous data-desc="crossorigin anonymous to absent, src absent">
+<img crossorigin=anonymous data-desc="crossorigin anonymous to use-credentials, src absent">
+<img crossorigin=use-credentials data-desc="crossorigin use-credentials to absent, src absent">
+<img crossorigin=use-credentials data-desc="crossorigin use-credentials to empty, src absent">
+<img crossorigin=use-credentials data-desc="crossorigin use-credentials to anonymous, src absent">
+<img crossorigin=use-credentials data-desc="crossorigin use-credentials to invalid, src absent">
+
+<img src="../../../../images/green-2x2.png" data-desc="crossorigin absent to empty, src already set">
+<img src="../../../../images/green-2x2.png" data-desc="crossorigin absent to anonymous, src already set">
+<img src="../../../../images/green-2x2.png" data-desc="crossorigin absent to use-credentials, src already set">
+<img src="../../../../images/green-2x2.png" crossorigin data-desc="crossorigin empty to absent, src already set">
+<img src="../../../../images/green-2x2.png" crossorigin data-desc="crossorigin empty to use-credentials, src already set">
+<img src="../../../../images/green-2x2.png" crossorigin=anonymous data-desc="crossorigin anonymous to absent, src already set">
+<img src="../../../../images/green-2x2.png" crossorigin=anonymous data-desc="crossorigin anonymous to use-credentials, src already set">
+<img src="../../../../images/green-2x2.png" crossorigin=use-credentials data-desc="crossorigin use-credentials to absent, src already set">
+<img src="../../../../images/green-2x2.png" crossorigin=use-credentials data-desc="crossorigin use-credentials to empty, src already set">
+<img src="../../../../images/green-2x2.png" crossorigin=use-credentials data-desc="crossorigin use-credentials to anonymous, src already set">
+<img src="../../../../images/green-2x2.png" crossorigin=use-credentials data-desc="crossorigin use-credentials to invalid, src already set">
+
+<img data-desc="referrerpolicy absent to no-referrer-when-downgrade, src absent">
+<img data-desc="referrerpolicy absent to no-referrer, src absent">
+<img referrerpolicy data-desc="referrerpolicy empty to no-referrer-when-downgrade, src absent">
+<img referrerpolicy data-desc="referrerpolicy empty to no-referrer, src absent">
+<img referrerpolicy=no-referrer-when-downgrade data-desc="referrerpolicy no-referrer-when-downgrade to absent, src absent">
+<img referrerpolicy=no-referrer-when-downgrade data-desc="referrerpolicy no-referrer-when-downgrade to empty, src absent">
+<img referrerpolicy=no-referrer-when-downgrade data-desc="referrerpolicy no-referrer-when-downgrade to no-referrer, src absent">
+<img referrerpolicy=no-referrer-when-downgrade data-desc="referrerpolicy no-referrer-when-downgrade to invalid, src absent">
+<img referrerpolicy=no-referrer data-desc="referrerpolicy no-referrer to absent, src absent">
+<img referrerpolicy=no-referrer data-desc="referrerpolicy no-referrer to empty, src absent">
+<img referrerpolicy=no-referrer data-desc="referrerpolicy no-referrer to no-referrer-when-downgrade, src absent">
+<img referrerpolicy=no-referrer data-desc="referrerpolicy no-referrer to invalid, src absent">
+
+<img src="../../../../images/green-2x2.png" data-desc="referrerpolicy absent to no-referrer-when-downgrade, src already set">
+<img src="../../../../images/green-2x2.png" data-desc="referrerpolicy absent to no-referrer, src already set">
+<img src="../../../../images/green-2x2.png" referrerpolicy data-desc="referrerpolicy empty to no-referrer-when-downgrade, src already set">
+<img src="../../../../images/green-2x2.png" referrerpolicy data-desc="referrerpolicy empty to no-referrer, src already set">
+<img src="../../../../images/green-2x2.png" referrerpolicy=no-referrer-when-downgrade data-desc="referrerpolicy no-referrer-when-downgrade to absent, src already set">
+<img src="../../../../images/green-2x2.png" referrerpolicy=no-referrer-when-downgrade data-desc="referrerpolicy no-referrer-when-downgrade to empty, src already set">
+<img src="../../../../images/green-2x2.png" referrerpolicy=no-referrer-when-downgrade data-desc="referrerpolicy no-referrer-when-downgrade to no-referrer, src already set">
+<img src="../../../../images/green-2x2.png" referrerpolicy=no-referrer-when-downgrade data-desc="referrerpolicy no-referrer-when-downgrade to invalid, src already set">
+<img src="../../../../images/green-2x2.png" referrerpolicy=no-referrer data-desc="referrerpolicy no-referrer to absent, src already set">
+<img src="../../../../images/green-2x2.png" referrerpolicy=no-referrer data-desc="referrerpolicy no-referrer to empty, src already set">
+<img src="../../../../images/green-2x2.png" referrerpolicy=no-referrer data-desc="referrerpolicy no-referrer to no-referrer-when-downgrade, src already set">
+<img src="../../../../images/green-2x2.png" referrerpolicy=no-referrer data-desc="referrerpolicy no-referrer to invalid, src already set">
+
+<img src="../../../../images/green-2x2.png" data-desc="inserted into picture"><picture></picture>
+
+<picture><img src="../../../../images/green-2x2.png" data-desc="removed from picture"></picture>
+
+<picture><img src="../../../../images/green-2x2.png" data-desc="parent is picture, previous source inserted"></picture>
+
+<picture><source><img src="../../../../images/green-2x2.png" data-desc="parent is picture, previous source removed"></picture>
+
+<picture><source><img src="../../../../images/green-2x2.png" data-desc="parent is picture, previous source has srcset set"></picture>
+<picture><source srcset=""><img src="../../../../images/green-2x2.png" data-desc="parent is picture, previous source has srcset changed"></picture>
+<picture><source srcset=""><img src="../../../../images/green-2x2.png" data-desc="parent is picture, previous source has srcset removed"></picture>
+
+<picture><source><img src="../../../../images/green-2x2.png" data-desc="parent is picture, previous source has sizes set"></picture>
+<picture><source sizes=""><img src="../../../../images/green-2x2.png" data-desc="parent is picture, previous source has sizes changed"></picture>
+<picture><source sizes=""><img src="../../../../images/green-2x2.png" data-desc="parent is picture, previous source has sizes removed"></picture>
+
+<picture><source><img src="../../../../images/green-2x2.png" data-desc="parent is picture, previous source has media set"></picture>
+<picture><source media=""><img src="../../../../images/green-2x2.png" data-desc="parent is picture, previous source has media changed"></picture>
+<picture><source media=""><img src="../../../../images/green-2x2.png" data-desc="parent is picture, previous source has media removed"></picture>
+
+<picture><source><img src="../../../../images/green-2x2.png" data-desc="parent is picture, previous source has type set"></picture>
+<picture><source type=""><img src="../../../../images/green-2x2.png" data-desc="parent is picture, previous source has type changed"></picture>
+<picture><source type=""><img src="../../../../images/green-2x2.png" data-desc="parent is picture, previous source has type removed"></picture>
+
+<img srcset="../../../../images/green-2x2.png" data-desc="srcset is set to same value">
+<img srcset="../../../../images/green-2x2.png" sizes data-desc="sizes is set to same value">
+
+<img src="../../../../images/green-2x2.png" data-desc="crossorigin state not changed: absent, removeAttribute">
+<img src="../../../../images/green-2x2.png" crossorigin data-desc="crossorigin state not changed: empty to anonymous">
+<img src="../../../../images/green-2x2.png" crossorigin=anonymous data-desc="crossorigin state not changed: anonymous to foobar">
+<img src="../../../../images/green-2x2.png" crossorigin=use-credentials data-desc="crossorigin state not changed: use-credentials to USE-CREDENTIALS">
+
+<img src="../../../../images/green-2x2.png" data-desc="referrerpolicy state not changed: absent, removeAttribute">
+<img src="../../../../images/green-2x2.png" referrerpolicy data-desc="referrerpolicy state not changed: empty to empty">
+<img src="../../../../images/green-2x2.png" referrerpolicy data-desc="referrerpolicy state not changed: empty to invalid">
+<img src="../../../../images/green-2x2.png" data-desc="referrerpolicy state not changed: absent to invalid">
+<img src="../../../../images/green-2x2.png" referrerpolicy=no-referrer data-desc="referrerpolicy state not changed: no-referrer to NO-REFERRER">
+<img src="../../../../images/green-2x2.png" referrerpolicy=foobar data-desc="referrerpolicy state not changed: invalid to other-invalid">
+
+<img src="../../../../images/green-2x2.png" data-desc="inserted into picture ancestor"><picture><span></span></picture>
+<picture><span><img src="../../../../images/green-2x2.png" data-desc="removed from picture ancestor"></span></picture>
+
+<picture><span><img src="../../../../images/green-2x2.png" data-desc="ancestor picture has a source inserted"></span></picture>
+<picture><source><span><img src="../../../../images/green-2x2.png" data-desc="ancestor picture has a source removed"></span></picture>
+
+<picture><span><img src="../../../../images/green-2x2.png" data-desc="ancestor picture; previous sibling source inserted"></span></picture>
+<picture><span><source><img src="../../../../images/green-2x2.png" data-desc="ancestor picture; previous sibling source removed"></span></picture>
+
+<picture><img src="../../../../images/green-2x2.png" data-desc="parent is picture, following sibling source inserted"></picture>
+<picture><img src="../../../../images/green-2x2.png" data-desc="parent is picture, following sibling source removed"><source></picture>
+
+<picture><img src="../../../../images/green-2x2.png" data-desc="parent is picture, following sibling source has srcset set"><source></picture>
+
+<img src="../../../../images/green-2x2.png" data-desc="media on img set">
+<img src="../../../../images/green-2x2.png" data-desc="type on img set">
+<img src="../../../../images/green-2x2.png" data-desc="class on img set">
+<img src="../../../../images/green-2x2.png" data-desc="alt on img set">
+
+<picture><source><img src="../../../../images/green-2x2.png" data-desc="src on previous sibling source set"></picture>
+<picture><source><img src="../../../../images/green-2x2.png" data-desc="class on previous sibling source set"></picture>
+
+<img src="../../../../images/green-2x2.png" data-desc="inserted/removed children of img">
+
+<picture><img src="../../../../images/green-2x2.png" data-desc="picture is inserted; img has src"></picture><span></span>
+<picture><img srcset="../../../../images/green-2x2.png" data-desc="picture is inserted; img has srcset"></picture><span></span>
+<picture><source srcset="../../../../images/green-2x2.png"><img src="../../../../images/green-2x2.png" data-desc="picture is inserted; img has previous sibling source"></picture><span></span>
+<picture><img src="../../../../images/green-2x2.png" data-desc="picture is inserted; img has following sibling source"><source srcset="../../../../images/green-2x2.png"></picture><span></span>
+
+<picture><img src="../../../../images/green-2x2.png" data-desc="picture is removed; img has src"></picture>
+<picture><img srcset="../../../../images/green-2x2.png" data-desc="picture is removed; img has srcset"></picture>
+<picture><source srcset="../../../../images/green-2x2.png"><img src="../../../../images/green-2x2.png" data-desc="picture is removed; img has previous sibling source"></picture>
+<picture><img src="../../../../images/green-2x2.png" data-desc="picture is removed; img has following sibling source"><source srcset="../../../../images/green-2x2.png"></picture>
+
+<picture><img src="../../../../images/green-2x2.png" data-desc="parent is picture, following img inserted"></picture>
+<picture><img src="../../../../images/green-2x2.png" data-desc="parent is picture, following img removed"><img></picture>
+<picture><img src="../../../../images/green-2x2.png" data-desc="parent is picture, following img has src set"><img></picture>
+<picture><img src="../../../../images/green-2x2.png" data-desc="parent is picture, following img has srcset set"><img></picture>
+<picture><img src="../../../../images/green-2x2.png" data-desc="parent is picture, following img has sizes set"><img></picture>
+
+
+<script>
+onload = function() {
+
+ t('src set', function(img) {
+ img.src = '../../../../images/green-2x2.png';
+ }, 'load');
+
+ t('src changed', function(img) {
+ img.src = '../../../../images/green-2x2.png ';
+ }, 'load');
+
+ t('src removed', function(img) {
+ img.removeAttribute('src');
+ }, 'timeout');
+
+ t('srcset set', function(img) {
+ img.srcset = '../../../../images/green-2x2.png';
+ }, 'load');
+
+ t('srcset changed', function(img) {
+ img.srcset = '../../../../images/green-2x2.png ';
+ }, 'load');
+
+ t('srcset removed', function(img) {
+ img.removeAttribute('srcset');
+ }, 'timeout');
+
+ t('sizes set', function(img) {
+ img.sizes = '';
+ }, 'timeout');
+
+ t('sizes changed', function(img) {
+ img.sizes = ' ';
+ }, 'timeout');
+
+ t('sizes removed', function(img) {
+ img.removeAttribute('sizes');
+ }, 'timeout');
+
+ t('src set to same value', function(img) {
+ img.src = '../../../../images/green-2x2.png';
+ }, 'load');
+
+ // When src is absent, changing the crossorigin attribute state MUST NOT
+ // generate events.
+
+ t('crossorigin absent to empty, src absent', function(img) {
+ img.crossOrigin = '';
+ }, 'timeout');
+
+ t('crossorigin absent to anonymous, src absent', function(img) {
+ img.crossOrigin = 'anonymous';
+ }, 'timeout');
+
+ t('crossorigin absent to use-credentials, src absent', function(img) {
+ img.crossOrigin = 'use-credentials';
+ }, 'timeout');
+
+ t('crossorigin empty to absent, src absent', function(img) {
+ img.removeAttribute('crossorigin');
+ }, 'timeout');
+
+ t('crossorigin empty to use-credentials, src absent', function(img) {
+ img.crossOrigin = 'use-credentials';
+ }, 'timeout');
+
+ t('crossorigin anonymous to absent, src absent', function(img) {
+ img.removeAttribute('crossorigin');
+ }, 'timeout');
+
+ t('crossorigin anonymous to use-credentials, src absent', function(img) {
+ img.crossOrigin = 'use-credentials';
+ }, 'timeout');
+
+ t('crossorigin use-credentials to absent, src absent', function(img) {
+ img.removeAttribute('crossorigin');
+ }, 'timeout');
+
+ t('crossorigin use-credentials to empty, src absent', function(img) {
+ img.crossOrigin = '';
+ }, 'timeout');
+
+ t('crossorigin use-credentials to anonymous, src absent', function(img) {
+ img.crossOrigin = 'anonymous';
+ }, 'timeout');
+
+ t('crossorigin use-credentials to invalid, src absent', function(img) {
+ img.crossOrigin = 'foobar';
+ }, 'timeout');
+
+ // When src is set, changing the crossorigin attribute state MUST generate
+ // events.
+
+ t('crossorigin absent to empty, src already set', function(img) {
+ img.crossOrigin = '';
+ }, 'load');
+
+ t('crossorigin absent to anonymous, src already set', function(img) {
+ img.crossOrigin = 'anonymous';
+ }, 'load');
+
+ t('crossorigin absent to use-credentials, src already set', function(img) {
+ img.crossOrigin = 'use-credentials';
+ }, 'load');
+
+ t('crossorigin empty to absent, src already set', function(img) {
+ img.removeAttribute('crossorigin');
+ }, 'load');
+
+ t('crossorigin empty to use-credentials, src already set', function(img) {
+ img.crossOrigin = 'use-credentials';
+ }, 'load');
+
+ t('crossorigin anonymous to absent, src already set', function(img) {
+ img.removeAttribute('crossorigin');
+ }, 'load');
+
+ t('crossorigin anonymous to use-credentials, src already set', function(img) {
+ img.crossOrigin = 'use-credentials';
+ }, 'load');
+
+ t('crossorigin use-credentials to absent, src already set', function(img) {
+ img.removeAttribute('crossorigin');
+ }, 'load');
+
+ t('crossorigin use-credentials to empty, src already set', function(img) {
+ img.crossOrigin = '';
+ }, 'load');
+
+ t('crossorigin use-credentials to anonymous, src already set', function(img) {
+ img.crossOrigin = 'anonymous';
+ }, 'load');
+
+ t('crossorigin use-credentials to invalid, src already set', function(img) {
+ img.crossOrigin = 'foobar';
+ }, 'load');
+
+ // When src is absent, changing the referrerpolicy attribute state MUST NOT
+ // generate events.
+
+ t('referrerpolicy absent to no-referrer-when-downgrade, src absent', function(img) {
+ img.referrerPolicy = 'no-referrer-when-downgrade';
+ }, 'timeout');
+
+ t('referrerpolicy absent to no-referrer, src absent', function(img) {
+ img.referrerPolicy = 'no-referrer';
+ }, 'timeout');
+
+ t('referrerpolicy empty to no-referrer-when-downgrade, src absent', function(img) {
+ img.referrerPolicy = 'no-referrer-when-downgrade';
+ }, 'timeout');
+
+ t('referrerpolicy empty to no-referrer, src absent', function(img) {
+ img.referrerPolicy = 'no-referrer';
+ }, 'timeout');
+
+ t('referrerpolicy no-referrer-when-downgrade to absent, src absent', function(img) {
+ img.removeAttribute('referrerpolicy');
+ }, 'timeout');
+
+ t('referrerpolicy no-referrer-when-downgrade to empty, src absent', function(img) {
+ img.referrerPolicy = '';
+ }, 'timeout');
+
+ t('referrerpolicy no-referrer-when-downgrade to no-referrer, src absent', function(img) {
+ img.referrerPolicy = 'no-referrer';
+ }, 'timeout');
+
+ t('referrerpolicy no-referrer-when-downgrade to invalid, src absent', function(img) {
+ img.referrerPolicy = 'foobar';
+ }, 'timeout');
+
+ t('referrerpolicy no-referrer to absent, src absent', function(img) {
+ img.removeAttribute('referrerpolicy');
+ }, 'timeout');
+
+ t('referrerpolicy no-referrer to empty, src absent', function(img) {
+ img.referrerPolicy = '';
+ }, 'timeout');
+
+ t('referrerpolicy no-referrer to no-referrer-when-downgrade, src absent', function(img) {
+ img.referrerPolicy = 'no-referrer-when-downgrade';
+ }, 'timeout');
+
+ t('referrerpolicy no-referrer to invalid, src absent', function(img) {
+ img.removeAttribute('referrerpolicy');
+ }, 'timeout');
+
+ // When src is set, changing the referrerpolicy attribute state MUST generate
+ // events.
+
+ t('referrerpolicy absent to no-referrer-when-downgrade, src already set', function(img) {
+ img.referrerPolicy = 'no-referrer-when-downgrade';
+ }, 'load');
+
+ t('referrerpolicy absent to no-referrer, src already set', function(img) {
+ img.referrerPolicy = 'no-referrer';
+ }, 'load');
+
+ t('referrerpolicy empty to no-referrer-when-downgrade, src already set', function(img) {
+ img.referrerPolicy = 'no-referrer-when-downgrade';
+ }, 'load');
+
+ t('referrerpolicy empty to no-referrer, src already set', function(img) {
+ img.referrerPolicy = 'no-referrer';
+ }, 'load');
+
+ t('referrerpolicy no-referrer-when-downgrade to absent, src already set', function(img) {
+ img.removeAttribute('referrerpolicy');
+ }, 'load');
+
+ t('referrerpolicy no-referrer-when-downgrade to empty, src already set', function(img) {
+ img.referrerPolicy = '';
+ }, 'load');
+
+ t('referrerpolicy no-referrer-when-downgrade to no-referrer, src already set', function(img) {
+ img.referrerPolicy = 'no-referrer';
+ }, 'load');
+
+ t('referrerpolicy no-referrer-when-downgrade to invalid, src already set', function(img) {
+ img.referrerPolicy = 'foobar';
+ }, 'load');
+
+ t('referrerpolicy no-referrer to absent, src already set', function(img) {
+ img.removeAttribute('referrerpolicy');
+ }, 'load');
+
+ t('referrerpolicy no-referrer to empty, src already set', function(img) {
+ img.referrerPolicy = '';
+ }, 'load');
+
+ t('referrerpolicy no-referrer to no-referrer-when-downgrade, src already set', function(img) {
+ img.referrerPolicy = 'no-referrer-when-downgrade';
+ }, 'load');
+
+ t('referrerpolicy no-referrer to invalid, src already set', function(img) {
+ img.removeAttribute('referrerpolicy');
+ }, 'load');
+
+
+ t('inserted into picture', function(img) {
+ img.nextSibling.appendChild(img);
+ }, 'load');
+
+ t('removed from picture', function(img) {
+ img.parentNode.removeChild(img);
+ }, 'load');
+
+ t('parent is picture, previous source inserted', function(img) {
+ img.parentNode.insertBefore(document.createElement('source'), img);
+ }, 'load');
+
+ t('parent is picture, previous source removed', function(img) {
+ img.parentNode.removeChild(img.previousSibling);
+ }, 'load');
+
+ t('parent is picture, previous source has srcset set', function(img) {
+ img.previousSibling.srcset = '';
+ }, 'load');
+
+ t('parent is picture, previous source has srcset changed', function(img) {
+ img.previousSibling.srcset = ' ';
+ }, 'load');
+
+ t('parent is picture, previous source has srcset removed', function(img) {
+ img.previousSibling.removeAttribute('srcset');
+ }, 'load');
+
+ t('parent is picture, previous source has sizes set', function(img) {
+ img.previousSibling.sizes = '';
+ }, 'load');
+
+ t('parent is picture, previous source has sizes changed', function(img) {
+ img.previousSibling.sizes = ' ';
+ }, 'load');
+
+ t('parent is picture, previous source has sizes removed', function(img) {
+ img.previousSibling.removeAttribute('sizes');
+ }, 'load');
+
+ t('parent is picture, previous source has media set', function(img) {
+ img.previousSibling.media = '';
+ }, 'load');
+
+ t('parent is picture, previous source has media changed', function(img) {
+ img.previousSibling.media = ' ';
+ }, 'load');
+
+ t('parent is picture, previous source has media removed', function(img) {
+ img.previousSibling.removeAttribute('media');
+ }, 'load');
+
+ t('parent is picture, previous source has type set', function(img) {
+ img.previousSibling.type = '';
+ }, 'load');
+
+ t('parent is picture, previous source has type changed', function(img) {
+ img.previousSibling.type = ' ';
+ }, 'load');
+
+ t('parent is picture, previous source has type removed', function(img) {
+ img.previousSibling.removeAttribute('type');
+ }, 'load');
+
+ t('srcset is set to same value', function(img) {
+ img.srcset = "../../../../images/green-2x2.png";
+ }, 'load');
+
+ t('sizes is set to same value', function(img) {
+ img.sizes = '';
+ }, 'load');
+
+ t('crossorigin state not changed: absent, removeAttribute', function(img) {
+ img.removeAttribute('crossorigin');
+ }, 'timeout');
+
+ t('crossorigin state not changed: empty to anonymous', function(img) {
+ img.crossOrigin = 'anonymous';
+ }, 'timeout');
+
+ t('crossorigin state not changed: anonymous to foobar', function(img) {
+ img.crossOrigin = 'foobar';
+ }, 'timeout');
+
+ t('crossorigin state not changed: use-credentials to USE-CREDENTIALS', function(img) {
+ img.crossOrigin = 'USE-CREDENTIALS';
+ }, 'timeout');
+
+ t('referrerpolicy state not changed: absent, removeAttribute', function(img) {
+ img.removeAttribute('referrerpolicy');
+ }, 'timeout');
+
+ t('referrerpolicy state not changed: empty to empty', function(img) {
+ img.referrerPolicy = '';
+ }, 'timeout');
+
+ t('referrerpolicy state not changed: empty to invalid', function(img) {
+ img.referrerPolicy = 'foobar';
+ }, 'timeout');
+
+ t('referrerpolicy state not changed: absent to invalid', function(img) {
+ img.referrerPolicy = 'foobar';
+ }, 'timeout');
+
+ t('referrerpolicy state not changed: no-referrer to NO-REFERRER', function(img) {
+ img.referrerPolicy = 'NO-REFERRER';
+ }, 'timeout');
+
+ t('referrerpolicy state not changed: invalid to other-invalid', function(img) {
+ img.referrerPolicy = 'foobar2';
+ }, 'timeout');
+
+ t('inserted into picture ancestor', function(img) {
+ img.nextSibling.firstChild.appendChild(img);
+ }, 'timeout');
+
+ t('removed from picture ancestor', function(img) {
+ img.parentNode.removeChild(img);
+ }, 'timeout');
+
+ t('ancestor picture has a source inserted', function(img) {
+ img.parentNode.parentNode.insertBefore(document.createElement('source'), img.parentNode);
+ }, 'timeout');
+
+ t('ancestor picture has a source removed', function(img) {
+ img.parentNode.parentNode.removeChild(img.parentNode.previousSibling);
+ }, 'timeout');
+
+ t('ancestor picture; previous sibling source inserted', function(img) {
+ img.parentNode.insertBefore(document.createElement('source'), img);
+ }, 'timeout');
+
+ t('ancestor picture; previous sibling source removed', function(img) {
+ img.parentNode.removeChild(img.previousSibling);
+ }, 'timeout');
+
+ t('parent is picture, following sibling source inserted', function(img) {
+ img.parentNode.appendChild(document.createElement('source'));
+ }, 'timeout');
+
+ t('parent is picture, following sibling source removed', function(img) {
+ img.parentNode.removeChild(img.nextSibling);
+ }, 'timeout');
+
+ t('parent is picture, following sibling source has srcset set', function(img) {
+ img.nextSibling.srcset = '';
+ }, 'timeout');
+
+ t('media on img set', function(img) {
+ img.setAttribute('media', '');
+ }, 'timeout');
+
+ t('type on img set', function(img) {
+ img.setAttribute('type', '');
+ }, 'timeout');
+
+ t('class on img set', function(img) {
+ img.className = '';
+ }, 'timeout');
+
+ t('alt on img set', function(img) {
+ img.alt = '';
+ }, 'timeout');
+
+ t('src on previous sibling source set', function(img) {
+ img.previousSibling.setAttribute('src', '');
+ }, 'timeout');
+
+ t('class on previous sibling source set', function(img) {
+ img.previousSibling.className = '';
+ }, 'timeout');
+
+ t('inserted/removed children of img', function(img) {
+ img.appendChild(document.createElement('source'));
+ setTimeout(this.step_func(function() {
+ img.removeChild(img.firstChild);
+ }), 0);
+ }, 'timeout');
+
+ t('picture is inserted; img has src', function(img) {
+ img.parentNode.nextSibling.appendChild(img.parentNode);
+ }, 'timeout');
+
+ t('picture is inserted; img has srcset', function(img) {
+ img.parentNode.nextSibling.appendChild(img.parentNode);
+ }, 'timeout');
+
+ t('picture is inserted; img has previous sibling source', function(img) {
+ img.parentNode.nextSibling.appendChild(img.parentNode);
+ }, 'timeout');
+
+ t('picture is inserted; img has following sibling source', function(img) {
+ img.parentNode.nextSibling.appendChild(img.parentNode);
+ }, 'timeout');
+
+ t('picture is removed; img has src', function(img) {
+ img.parentNode.parentNode.removeChild(img.parentNode);
+ }, 'timeout');
+
+ t('picture is removed; img has srcset', function(img) {
+ img.parentNode.parentNode.removeChild(img.parentNode);
+ }, 'timeout');
+
+ t('picture is removed; img has previous sibling source', function(img) {
+ img.parentNode.parentNode.removeChild(img.parentNode);
+ }, 'timeout');
+
+ t('picture is removed; img has following sibling source', function(img) {
+ img.parentNode.parentNode.removeChild(img.parentNode);
+ }, 'timeout');
+
+ t('parent is picture, following img inserted', function(img) {
+ img.parentNode.appendChild(document.createElement('img'));
+ }, 'timeout');
+
+ t('parent is picture, following img removed', function(img) {
+ img.parentNode.removeChild(img.nextSibling);
+ }, 'timeout');
+
+ t('parent is picture, following img has src set', function(img) {
+ img.nextSibling.src = '';
+ }, 'timeout');
+
+ t('parent is picture, following img has srcset set', function(img) {
+ img.nextSibling.srcset = '';
+ }, 'timeout');
+
+ t('parent is picture, following img has sizes set', function(img) {
+ img.nextSibling.sizes = '';
+ }, 'timeout');
+
+ done();
+};
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-img-element/sizes/sizes-auto.html b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-img-element/sizes/sizes-auto.html
new file mode 100644
index 00000000000..f14d0149e39
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-img-element/sizes/sizes-auto.html
@@ -0,0 +1,156 @@
+<!doctype html>
+<title>img parse a sizes attribute: sizes=auto</title>
+<link rel="help" href="https://html.spec.whatwg.org/multipage/images.html#parse-a-sizes-attribute">
+<script src="../../../../../resources/testharness.js"></script>
+<script src="../../../../../resources/testharnessreport.js"></script>
+<style>
+img { height: 10px; } /* Keep all images in the viewport, so lazy images load */
+#narrow-div { width: 10px; }
+#wide-div { width: 500px; }
+</style>
+<div id=log></div>
+<img srcset='/images/green-1x1.png?ref1 50w, /images/green-16x16.png?ref1 51w' sizes='1px' id=ref1>
+<img srcset='/images/green-1x1.png?ref2 50w, /images/green-16x16.png?ref2 51w' sizes='100vw' id=ref2>
+<div id='narrow-div'></div>
+<div id='wide-div'></div>
+<script>
+"use strict";
+
+// https://github.com/web-platform-tests/rfcs/pull/75
+let async_promise_test = (promise, description) => {
+ async_test(test => {
+ promise(test)
+ .then(() => {test.done();})
+ .catch(test.step_func(error => { throw error; }));
+ }, description);
+};
+
+function check(imgOrPicture) {
+ let img = imgOrPicture;
+ let source;
+ if (imgOrPicture.localName === 'picture') {
+ source = imgOrPicture.firstChild;
+ img = imgOrPicture.lastChild;
+ }
+ const ref = document.getElementById(img.dataset.ref);
+ async_promise_test(async (t) => {
+ let expect = ref.currentSrc;
+ if (expect) {
+ expect = expect.split('?')[0];
+ }
+ if (expect === '' || expect === null || expect === undefined) {
+ assert_unreached('ref currentSrc was ' + format_value(expect));
+ }
+ await new Promise((resolve, reject) => {
+ img.onload = resolve;
+ img.onerror = reject;
+ });
+ t.step(() => {
+ let got = img.currentSrc;
+ assert_greater_than(got.indexOf('?'), -1, 'expected a "?" in currentSrc');
+ got = got.split('?')[0];
+ assert_equals(got, expect);
+ })
+ }, imgOrPicture.outerHTML);
+}
+
+const tests = [
+ // Smoke tests
+ {sizes: '1px', 'data-ref': 'ref1'},
+ {sizes: '', 'data-ref': 'ref2'},
+ // Actual tests
+ {loading: 'lazy', sizes: 'auto', width: '10', 'data-ref': 'ref1'},
+ {loading: 'lazy', sizes: 'AUTO', width: '10', 'data-ref': 'ref1'},
+ {loading: 'lazy', width: '10', 'data-ref': 'ref2'}, // no `sizes: 'auto'` -> 100vw
+ {loading: 'lazy', style: 'width: 10px', 'data-ref': 'ref2'}, // no `sizes: 'auto'` -> 100vw
+ {loading: 'lazy', style: 'max-width: 10px', 'data-ref': 'ref2'}, // no `sizes: 'auto'` -> 100vw
+ {loading: 'lazy', style: 'width: 100%; max-width: 10px', 'data-ref': 'ref2'}, // no `sizes: 'auto'` -> 100vw
+ {loading: 'lazy', sizes: 'auto', width: '500', 'data-ref': 'ref2'},
+ {loading: 'lazy', sizes: 'auto', width: '10', style: 'visibility: hidden', 'data-ref': 'ref1'},
+ {loading: 'lazy', sizes: 'auto', width: '10', style: 'display: inline', hidden: '', 'data-ref': 'ref1'},
+ {loading: 'lazy', sizes: 'auto', width: '0', 'data-ref': 'ref1'},
+ {loading: 'lazy', sizes: 'auto', style: 'width: 0px', 'data-ref': 'ref1'},
+ {loading: 'lazy', sizes: 'auto', 'data-ref': 'ref2'}, // no width -> UA default of 300px
+ {loading: 'lazy', sizes: 'auto, 100vw', width: '10', 'data-ref': 'ref1'},
+ {loading: 'lazy', sizes: '100vw, auto', width: '10', 'data-ref': 'ref2'},
+ {loading: 'eager', sizes: 'auto', width: '10', 'data-ref': 'ref2'},
+ {loading: 'lazy', sizes: 'auto', width: '100%', parent: 'narrow-div', 'data-ref': 'ref1'},
+ {loading: 'lazy', sizes: 'auto', width: '100%', parent: 'wide-div', 'data-ref': 'ref2'},
+ {loading: 'lazy', sizes: 'auto', style: 'height: 10px; aspect-ratio: 10 / 10', 'data-ref': 'ref1'},
+ {loading: 'lazy', sizes: 'auto', style: 'height: 10px; aspect-ratio: 500 / 10', 'data-ref': 'ref2'},
+ {loading: 'lazy', sizes: 'auto', style: 'min-height: 10px; aspect-ratio: 10 / 10', 'data-ref': 'ref1'},
+ {loading: 'lazy', sizes: 'auto', style: 'min-height: 10px; aspect-ratio: 500 / 10', 'data-ref': 'ref2'},
+ {loading: 'lazy', sizes: 'auto', style: 'inline-size: 10px', 'data-ref': 'ref1'},
+ {loading: 'lazy', sizes: 'auto', style: 'min-inline-size: 10px', 'data-ref': 'ref2'}, // no width -> UA default of 300px
+ {loading: 'lazy', sizes: 'auto', style: 'block-size: 10px; aspect-ratio: 10 / 10', 'data-ref': 'ref1'},
+ {loading: 'lazy', sizes: 'auto', style: 'min-block-size: 10px; aspect-ratio: 10 / 10', 'data-ref': 'ref1'},
+ {loading: 'lazy', sizes: 'auto', style: 'block-size: 10px; writing-mode: vertical-rl', 'data-ref': 'ref1'},
+ {loading: 'lazy', sizes: 'auto', style: 'min-block-size: 10px; writing-mode: vertical-rl', 'data-ref': 'ref2'}, // no width -> UA default of 300px
+ {loading: 'lazy', sizes: 'auto', style: 'inline-size: 10px; aspect-ratio: 10/10; writing-mode: vertical-rl', 'data-ref': 'ref1'},
+ {loading: 'lazy', sizes: 'auto', style: 'min-inline-size: 10px; aspect-ratio: 10/10; writing-mode: vertical-rl', 'data-ref': 'ref1'},
+ {loading: 'lazy', sizes: 'auto', style: '--my-width: 10px; width: var(--my-width)', 'data-ref': 'ref1'},
+ {loading: 'lazy', sizes: 'auto', style: 'width: calc(5px + 5px)', 'data-ref': 'ref1'},
+ {loading: 'lazy', sizes: 'auto', style: 'position: absolute; left: 50%; right: 49%', 'data-ref': 'ref2'}, // replaced elements don't get the width resolved from 'left'/'right' per https://drafts.csswg.org/css2/#abs-replaced-width
+ // img allows auto-sizes only if sizes starts with auto
+ {loading: 'lazy', sizes: '(max-width: 0px) 10px, auto', style: 'width: 10px', 'data-ref': 'ref2'},
+ {loading: 'lazy', sizes: '(min-width: 0px) auto', style: 'width: 10px', 'data-ref': 'ref2'},
+ {loading: 'lazy', sizes: '(min-width: 0px) 100vw, auto', style: 'width: 10px', 'data-ref': 'ref2'},
+];
+
+function test_img(obj, i) {
+ const img = document.createElement('img');
+ let parent = document.body;
+ for (const attr in obj) {
+ if (attr === 'parent') {
+ parent = document.getElementById(obj.parent);
+ } else {
+ img.setAttribute(attr, obj[attr]);
+ }
+ }
+ img.srcset = `/images/green-1x1.png?img${i} 50w, /images/green-16x16.png?img${i} 51w`
+ parent.appendChild(img);
+ check(img);
+}
+
+function test_picture(obj, i) {
+ const picture = document.createElement('picture');
+ const source = document.createElement('source');
+ const img = document.createElement('img');
+ let parent = document.body;
+ for (const attr in obj) {
+ switch (attr) {
+ case 'parent':
+ parent = document.getElementById(obj.parent);
+ break;
+ case 'sizes':
+ // Authors have to specify sizes="auto" on the img to use auto-sizes.
+ if(obj[attr].toLowerCase().startsWith("auto")) {
+ img.setAttribute(attr, obj[attr]);
+ break;
+ }
+ case 'type':
+ case 'media':
+ source.setAttribute(attr, obj[attr]);
+ break;
+ default:
+ img.setAttribute(attr, obj[attr]);
+ break;
+ }
+ }
+ source.srcset = `/images/green-1x1.png?picture${i} 50w, /images/green-16x16.png?picture${i} 51w`;
+ picture.appendChild(source);
+ picture.appendChild(img);
+ parent.appendChild(picture);
+ check(picture);
+}
+
+onload = () => {
+ let i = 0;
+ for (const obj of tests) {
+ i++;
+ test_img(obj, i);
+ test_picture(obj, i);
+ }
+ done();
+}
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-img-element/support/relevant-mutations.js b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-img-element/support/relevant-mutations.js
new file mode 100644
index 00000000000..8f7647bf048
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-img-element/support/relevant-mutations.js
@@ -0,0 +1,19 @@
+setup({ explicit_done: true });
+
+function t(desc, func, expect) {
+ async_test(function() {
+ let img = document.querySelector('[data-desc="' + desc + '"]');
+ let oldComplete = img.complete;
+ img.onload = img.onerror = this.unreached_func('update the image data was run');
+ if (expect == 'timeout') {
+ setTimeout(this.step_func_done(), 1000);
+ } else {
+ img['on' + expect] = this.step_func_done();
+ setTimeout(this.unreached_func('update the image data didn\'t run'), 1000);
+ }
+ func.call(this, img);
+ if (expect == 'timeout') {
+ assert_equals(img.complete, oldComplete, `complete shouldn't have changed`);
+ }
+ }, desc);
+}
diff --git a/Tests/LibWeb/Text/input/wpt-import/images/green-1x1.png b/Tests/LibWeb/Text/input/wpt-import/images/green-1x1.png
new file mode 100644
index 00000000000..862d1dd10cc
Binary files /dev/null and b/Tests/LibWeb/Text/input/wpt-import/images/green-1x1.png differ
diff --git a/Tests/LibWeb/Text/input/wpt-import/images/green-2x2.png b/Tests/LibWeb/Text/input/wpt-import/images/green-2x2.png
new file mode 100644
index 00000000000..adc059449c3
Binary files /dev/null and b/Tests/LibWeb/Text/input/wpt-import/images/green-2x2.png differ