|
|
|
@ -12,15 +12,16 @@ mod passing {
|
|
|
|
|
use std::collections::HashMap;
|
|
|
|
|
use url::Url;
|
|
|
|
|
|
|
|
|
|
use crate::html;
|
|
|
|
|
use crate::opts::Options;
|
|
|
|
|
use monolith::html;
|
|
|
|
|
use monolith::opts::Options;
|
|
|
|
|
use monolith::url::EMPTY_IMAGE_DATA_URL;
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn basic() {
|
|
|
|
|
let cache = &mut HashMap::new();
|
|
|
|
|
|
|
|
|
|
let html: &str = "<div><P></P></div>";
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), str!());
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), "".to_string());
|
|
|
|
|
let url: Url = Url::parse("http://localhost").unwrap();
|
|
|
|
|
|
|
|
|
|
let mut options = Options::default();
|
|
|
|
@ -42,7 +43,7 @@ mod passing {
|
|
|
|
|
#[test]
|
|
|
|
|
fn ensure_no_recursive_iframe() {
|
|
|
|
|
let html = "<div><P></P><iframe src=\"\"></iframe></div>";
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), str!());
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), "".to_string());
|
|
|
|
|
let url: Url = Url::parse("http://localhost").unwrap();
|
|
|
|
|
let cache = &mut HashMap::new();
|
|
|
|
|
|
|
|
|
@ -65,7 +66,7 @@ mod passing {
|
|
|
|
|
#[test]
|
|
|
|
|
fn ensure_no_recursive_frame() {
|
|
|
|
|
let html = "<frameset><frame src=\"\"></frameset>";
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), str!());
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), "".to_string());
|
|
|
|
|
let url: Url = Url::parse("http://localhost").unwrap();
|
|
|
|
|
let cache = &mut HashMap::new();
|
|
|
|
|
|
|
|
|
@ -93,7 +94,7 @@ mod passing {
|
|
|
|
|
<style>html{background-color: #000;}</style>\
|
|
|
|
|
<div style=\"display: none;\"></div>\
|
|
|
|
|
";
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), str!());
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), "".to_string());
|
|
|
|
|
let url: Url = Url::parse("http://localhost").unwrap();
|
|
|
|
|
let cache = &mut HashMap::new();
|
|
|
|
|
|
|
|
|
@ -129,7 +130,7 @@ mod passing {
|
|
|
|
|
fn no_images() {
|
|
|
|
|
let html = "<link rel=\"icon\" href=\"favicon.ico\">\
|
|
|
|
|
<div><img src=\"http://localhost/assets/mono_lisa.png\" /></div>";
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), str!());
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), "".to_string());
|
|
|
|
|
let url: Url = Url::parse("http://localhost").unwrap();
|
|
|
|
|
let cache = &mut HashMap::new();
|
|
|
|
|
|
|
|
|
@ -157,7 +158,7 @@ mod passing {
|
|
|
|
|
</div>\
|
|
|
|
|
</body>\
|
|
|
|
|
</html>",
|
|
|
|
|
empty_image = empty_image!()
|
|
|
|
|
empty_image = EMPTY_IMAGE_DATA_URL
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
@ -166,7 +167,7 @@ mod passing {
|
|
|
|
|
fn no_body_background_images() {
|
|
|
|
|
let html =
|
|
|
|
|
"<body background=\"no/such/image.png\" background=\"no/such/image2.png\"></body>";
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), str!());
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), "".to_string());
|
|
|
|
|
let url: Url = Url::parse("http://localhost").unwrap();
|
|
|
|
|
let cache = &mut HashMap::new();
|
|
|
|
|
|
|
|
|
@ -190,7 +191,7 @@ mod passing {
|
|
|
|
|
#[test]
|
|
|
|
|
fn no_frames() {
|
|
|
|
|
let html = "<frameset><frame src=\"http://trackbook.com\"></frameset>";
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), str!());
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), "".to_string());
|
|
|
|
|
let url: Url = Url::parse("http://localhost").unwrap();
|
|
|
|
|
let cache = &mut HashMap::new();
|
|
|
|
|
|
|
|
|
@ -222,7 +223,7 @@ mod passing {
|
|
|
|
|
#[test]
|
|
|
|
|
fn no_iframes() {
|
|
|
|
|
let html = "<iframe src=\"http://trackbook.com\"></iframe>";
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), str!());
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), "".to_string());
|
|
|
|
|
let url: Url = Url::parse("http://localhost").unwrap();
|
|
|
|
|
let cache = &mut HashMap::new();
|
|
|
|
|
|
|
|
|
@ -258,7 +259,7 @@ mod passing {
|
|
|
|
|
<script>alert(1)</script>\
|
|
|
|
|
</div>\
|
|
|
|
|
";
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), str!());
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), "".to_string());
|
|
|
|
|
let url: Url = Url::parse("http://localhost").unwrap();
|
|
|
|
|
let cache = &mut HashMap::new();
|
|
|
|
|
|
|
|
|
@ -293,7 +294,7 @@ mod passing {
|
|
|
|
|
fn keeps_integrity_for_unfamiliar_links() {
|
|
|
|
|
let html = "<title>Has integrity</title>\
|
|
|
|
|
<link integrity=\"sha384-12345\" rel=\"something\" href=\"https://some-site.com/some-file.ext\" />";
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), str!());
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), "".to_string());
|
|
|
|
|
let url: Url = Url::parse("http://localhost").unwrap();
|
|
|
|
|
let cache = &mut HashMap::new();
|
|
|
|
|
|
|
|
|
@ -328,7 +329,7 @@ mod passing {
|
|
|
|
|
<link integrity=\"\" rel=\"stylesheet\" href=\"data:;\"/>\
|
|
|
|
|
<script integrity=\"\" src=\"some.js\"></script>\
|
|
|
|
|
";
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), str!());
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), "".to_string());
|
|
|
|
|
let url: Url = Url::parse("http://localhost").unwrap();
|
|
|
|
|
let cache = &mut HashMap::new();
|
|
|
|
|
|
|
|
|
@ -366,7 +367,7 @@ mod passing {
|
|
|
|
|
<link integrity=\"sha384-123\" rel=\"something\" href=\"data:;\"/>\
|
|
|
|
|
<script integrity=\"sha384-456\" src=\"some.js\"></script>\
|
|
|
|
|
";
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), str!());
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), "".to_string());
|
|
|
|
|
let url: Url = Url::parse("http://localhost").unwrap();
|
|
|
|
|
let cache = &mut HashMap::new();
|
|
|
|
|
|
|
|
|
@ -410,7 +411,7 @@ mod passing {
|
|
|
|
|
</body>\
|
|
|
|
|
</html>\
|
|
|
|
|
";
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), str!());
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), "".to_string());
|
|
|
|
|
let url: Url = Url::parse("http://localhost").unwrap();
|
|
|
|
|
let cache = &mut HashMap::new();
|
|
|
|
|
|
|
|
|
@ -452,7 +453,7 @@ mod passing {
|
|
|
|
|
</noscript>\
|
|
|
|
|
</body>\
|
|
|
|
|
</html>";
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), str!());
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), "".to_string());
|
|
|
|
|
let url: Url = Url::parse("http://localhost").unwrap();
|
|
|
|
|
let cache = &mut HashMap::new();
|
|
|
|
|
|
|
|
|
@ -480,7 +481,7 @@ mod passing {
|
|
|
|
|
</noscript>\
|
|
|
|
|
</body>\
|
|
|
|
|
</html>",
|
|
|
|
|
empty_image!(),
|
|
|
|
|
EMPTY_IMAGE_DATA_URL,
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
@ -488,7 +489,7 @@ mod passing {
|
|
|
|
|
#[test]
|
|
|
|
|
fn preserves_script_type_json() {
|
|
|
|
|
let html = "<script id=\"data\" type=\"application/json\">{\"mono\":\"lith\"}</script>";
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), str!());
|
|
|
|
|
let dom = html::html_to_dom(&html.as_bytes().to_vec(), "".to_string());
|
|
|
|
|
let url: Url = Url::parse("http://localhost").unwrap();
|
|
|
|
|
let cache = &mut HashMap::new();
|
|
|
|
|
|