moz_readability/mod.rs: add testcase for issue #13

This patch adds a testcase for issue #13, where an img node without
a class attribute is automatically assumed to be lazy and its src is
replaced.
This commit is contained in:
KOVACS Tamas 2021-05-10 01:30:05 +02:00
parent f93017ab73
commit d50f08b875

View file

@ -3160,6 +3160,7 @@ characters. For that reason, this <p> tag could not be a byline because it's too
<source media="(min-width:465px)" srcset="img_white_flower.jpg"> <source media="(min-width:465px)" srcset="img_white_flower.jpg">
<img src="img_orange_flowers.jpg" alt="Flowers" style="width:auto;"> <img src="img_orange_flowers.jpg" alt="Flowers" style="width:auto;">
</picture> </picture>
<img id="no-lazy-class" src="https://image.url/" data-attrs="{&quot;src&quot;:&quot;https://other.url/1.png&quot;,&quot;alt&quot;:&quot;&quot;}"/>
</body> </body>
</html> </html>
"#; "#;
@ -3189,6 +3190,13 @@ characters. For that reason, this <p> tag could not be a byline because it's too
lazy_loaded_attrs.get("data-src"), lazy_loaded_attrs.get("data-src"),
lazy_loaded_attrs.get("src") lazy_loaded_attrs.get("src")
); );
let no_lazy_class = doc.root_node.select_first("#no-lazy-class").unwrap();
let no_lazy_class_attrs = no_lazy_class.attributes.borrow();
assert_eq!(
no_lazy_class_attrs.get("src").unwrap(),
"https://image.url/"
);
} }
#[test] #[test]