diff options
author | Kopanov Anton <57631929+NotnaKO@users.noreply.github.com> | 2024-08-24 11:22:39 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-24 08:22:39 +0000 |
commit | ad45fa0a196a5d8f9655c41afc6b5b42570f5340 (patch) | |
tree | 8a58b1b47c3ec46599cbd3dfa28a7535d0f48366 /tests/unit/script/htmlimageelement.rs | |
parent | e85491b5fc0ccbedfa312b82edf37d8e1cecc780 (diff) | |
download | servo-ad45fa0a196a5d8f9655c41afc6b5b42570f5340.tar.gz servo-ad45fa0a196a5d8f9655c41afc6b5b42570f5340.zip |
script: Fix panic in `htmlimageelement.rs` using `str::find()` to find character boundaries. (#32980)
* fix loop with chars().enumerate() by using find()
Signed-off-by: Kopanov Anton <anton.kopanov@ya.ru>
* Add documentation to parser and fix some small issues
- Rename the properties of `Descriptor` so that they are full words
- Use the Rust-parser to parse doubles
- Add documentation and restructure parser to be more readable
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
---------
Signed-off-by: Kopanov Anton <anton.kopanov@ya.ru>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Diffstat (limited to 'tests/unit/script/htmlimageelement.rs')
-rw-r--r-- | tests/unit/script/htmlimageelement.rs | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/tests/unit/script/htmlimageelement.rs b/tests/unit/script/htmlimageelement.rs index 1b0612b14a1..48fb0b691a6 100644 --- a/tests/unit/script/htmlimageelement.rs +++ b/tests/unit/script/htmlimageelement.rs @@ -13,30 +13,30 @@ fn no_value() { #[test] fn width_one_value() { let first_descriptor = Descriptor { - wid: Some(320), - den: None, + width: Some(320), + density: None, }; let first_imagesource = ImageSource { url: "small-image.jpg".to_string(), descriptor: first_descriptor, }; let sources = &[first_imagesource]; - assert_eq!(parse_a_srcset_attribute("small-image.jpg, 320w"), sources); + assert_eq!(parse_a_srcset_attribute("small-image.jpg 320w"), sources); } #[test] fn width_two_value() { let first_descriptor = Descriptor { - wid: Some(320), - den: None, + width: Some(320), + density: None, }; let first_imagesource = ImageSource { url: "small-image.jpg".to_string(), descriptor: first_descriptor, }; let second_descriptor = Descriptor { - wid: Some(480), - den: None, + width: Some(480), + density: None, }; let second_imagesource = ImageSource { url: "medium-image.jpg".to_string(), @@ -52,24 +52,24 @@ fn width_two_value() { #[test] fn width_three_value() { let first_descriptor = Descriptor { - wid: Some(320), - den: None, + width: Some(320), + density: None, }; let first_imagesource = ImageSource { url: "smallImage.jpg".to_string(), descriptor: first_descriptor, }; let second_descriptor = Descriptor { - wid: Some(480), - den: None, + width: Some(480), + density: None, }; let second_imagesource = ImageSource { url: "mediumImage.jpg".to_string(), descriptor: second_descriptor, }; let third_descriptor = Descriptor { - wid: Some(800), - den: None, + width: Some(800), + density: None, }; let third_imagesource = ImageSource { url: "largeImage.jpg".to_string(), @@ -89,8 +89,8 @@ fn width_three_value() { #[test] fn density_value() { let first_descriptor = Descriptor { - wid: None, - den: Some(1.0), + width: None, + density: Some(1.0), }; let first_imagesource = ImageSource { url: "small-image.jpg".to_string(), @@ -103,8 +103,8 @@ fn density_value() { #[test] fn without_descriptor() { let first_descriptor = Descriptor { - wid: None, - den: None, + width: None, + density: None, }; let first_imagesource = ImageSource { url: "small-image.jpg".to_string(), @@ -127,8 +127,8 @@ fn two_descriptor() { #[test] fn decimal_descriptor() { let first_descriptor = Descriptor { - wid: None, - den: Some(2.2), + width: None, + density: Some(2.2), }; let first_imagesource = ImageSource { url: "small-image.jpg".to_string(), @@ -141,16 +141,16 @@ fn decimal_descriptor() { #[test] fn different_descriptor() { let first_descriptor = Descriptor { - wid: Some(320), - den: None, + width: Some(320), + density: None, }; let first_imagesource = ImageSource { url: "small-image.jpg".to_string(), descriptor: first_descriptor, }; let second_descriptor = Descriptor { - wid: None, - den: Some(2.2), + width: None, + density: Some(2.2), }; let second_imagesource = ImageSource { url: "medium-image.jpg".to_string(), |