diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs
index af503ea2aa8..32818d400e3 100644
--- a/components/script/dom/htmlimageelement.rs
+++ b/components/script/dom/htmlimageelement.rs
@@ -2011,8 +2011,8 @@ pub fn parse_a_srcset_attribute(input: &str) -> Vec {
// > that position is past the end of input.
let mut characters = descriptors_string.chars();
let mut character = characters.next();
- if character.is_some() {
- current_index += 1;
+ if let Some(character) = character {
+ current_index += character.len_utf8();
}
loop {
@@ -2086,8 +2086,8 @@ pub fn parse_a_srcset_attribute(input: &str) -> Vec {
}
character = characters.next();
- if character.is_some() {
- current_index += 1;
+ if let Some(character) = character {
+ current_index += character.len_utf8();
}
}
diff --git a/tests/wpt/meta/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html.ini b/tests/wpt/meta/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html.ini
index 353b6d5c053..0766cbca817 100644
--- a/tests/wpt/meta/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html.ini
+++ b/tests/wpt/meta/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html.ini
@@ -1,2 +1,165 @@
[parse-a-srcset-attribute.html]
- expected: CRASH
+ ["data:,a,, , "]
+ expected: FAIL
+
+ [",,,data:,a"]
+ expected: FAIL
+
+ [" , ,,data:,a"]
+ expected: FAIL
+
+ ["data:,a 1.0w"]
+ expected: FAIL
+
+ ["data:,a 1e0w"]
+ expected: FAIL
+
+ ["data:,a 1www"]
+ expected: FAIL
+
+ ["data:,a +1w"]
+ expected: FAIL
+
+ ["data:,a 1\\x01w" (trailing U+0001)]
+ expected: FAIL
+
+ ["data:,a 1 w" (trailing U+00A0)]
+ expected: FAIL
+
+ ["data:,a 1 w" (trailing U+1680)]
+ expected: FAIL
+
+ ["data:,a 1 w" (trailing U+2000)]
+ expected: FAIL
+
+ ["data:,a 1 w" (trailing U+2001)]
+ expected: FAIL
+
+ ["data:,a 1 w" (trailing U+2002)]
+ expected: FAIL
+
+ ["data:,a 1 w" (trailing U+2003)]
+ expected: FAIL
+
+ ["data:,a 1 w" (trailing U+2004)]
+ expected: FAIL
+
+ ["data:,a 1 w" (trailing U+2005)]
+ expected: FAIL
+
+ ["data:,a 1 w" (trailing U+2006)]
+ expected: FAIL
+
+ ["data:,a 1 w" (trailing U+2007)]
+ expected: FAIL
+
+ ["data:,a 1 w" (trailing U+2008)]
+ expected: FAIL
+
+ ["data:,a 1 w" (trailing U+2009)]
+ expected: FAIL
+
+ ["data:,a 1 w" (trailing U+200A)]
+ expected: FAIL
+
+ ["data:,a 1w" (trailing U+200C)]
+ expected: FAIL
+
+ ["data:,a 1w" (trailing U+200D)]
+ expected: FAIL
+
+ ["data:,a 1 w" (trailing U+202F)]
+ expected: FAIL
+
+ ["data:,a 1 w" (trailing U+205F)]
+ expected: FAIL
+
+ ["data:,a 1 w" (trailing U+3000)]
+ expected: FAIL
+
+ ["data:,a 1w" (trailing U+FEFF)]
+ expected: FAIL
+
+ ["data:,a 0x"]
+ expected: FAIL
+
+ ["data:,a -0x"]
+ expected: FAIL
+
+ ["data:,a 1.x"]
+ expected: FAIL
+
+ ["data:,a +1x"]
+ expected: FAIL
+
+ ["data:,a 1w 1.0h"]
+ expected: FAIL
+
+ ["data:,a 1w 1e0h"]
+ expected: FAIL
+
+ ["data:,a 1w 1hhh"]
+ expected: FAIL
+
+ ["data:,a 1w +1h"]
+ expected: FAIL
+
+ ["data:,a 1w 1\\x01h" (trailing U+0001)]
+ expected: FAIL
+
+ ["data:,a 1w 1 h" (trailing U+00A0)]
+ expected: FAIL
+
+ ["data:,a 1w 1 h" (trailing U+1680)]
+ expected: FAIL
+
+ ["data:,a 1w 1 h" (trailing U+2000)]
+ expected: FAIL
+
+ ["data:,a 1w 1 h" (trailing U+2001)]
+ expected: FAIL
+
+ ["data:,a 1w 1 h" (trailing U+2002)]
+ expected: FAIL
+
+ ["data:,a 1w 1 h" (trailing U+2003)]
+ expected: FAIL
+
+ ["data:,a 1w 1 h" (trailing U+2004)]
+ expected: FAIL
+
+ ["data:,a 1w 1 h" (trailing U+2005)]
+ expected: FAIL
+
+ ["data:,a 1w 1 h" (trailing U+2006)]
+ expected: FAIL
+
+ ["data:,a 1w 1 h" (trailing U+2007)]
+ expected: FAIL
+
+ ["data:,a 1w 1 h" (trailing U+2008)]
+ expected: FAIL
+
+ ["data:,a 1w 1 h" (trailing U+2009)]
+ expected: FAIL
+
+ ["data:,a 1w 1 h" (trailing U+200A)]
+ expected: FAIL
+
+ ["data:,a 1w 1h" (trailing U+200C)]
+ expected: FAIL
+
+ ["data:,a 1w 1h" (trailing U+200D)]
+ expected: FAIL
+
+ ["data:,a 1w 1 h" (trailing U+202F)]
+ expected: FAIL
+
+ ["data:,a 1w 1 h" (trailing U+205F)]
+ expected: FAIL
+
+ ["data:,a 1w 1 h" (trailing U+3000)]
+ expected: FAIL
+
+ ["data:,a 1w 1h" (trailing U+FEFF)]
+ expected: FAIL