|
|
@ -132,6 +132,42 @@ fn test_walk_and_embed_assets_ensure_no_recursive_iframe() {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
|
|
fn test_walk_and_embed_assets_ensure_no_recursive_frame() {
|
|
|
|
|
|
|
|
let html = "<frameset><frame src=\"\"></frameset>";
|
|
|
|
|
|
|
|
let dom = html_to_dom(&html);
|
|
|
|
|
|
|
|
let url = "http://localhost";
|
|
|
|
|
|
|
|
let cache = &mut HashMap::new();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let opt_no_css: bool = false;
|
|
|
|
|
|
|
|
let opt_no_frames: bool = false;
|
|
|
|
|
|
|
|
let opt_no_js: bool = false;
|
|
|
|
|
|
|
|
let opt_no_images: bool = false;
|
|
|
|
|
|
|
|
let opt_silent = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let client = Client::new();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
walk_and_embed_assets(
|
|
|
|
|
|
|
|
cache,
|
|
|
|
|
|
|
|
&client,
|
|
|
|
|
|
|
|
&url,
|
|
|
|
|
|
|
|
&dom.document,
|
|
|
|
|
|
|
|
opt_no_css,
|
|
|
|
|
|
|
|
opt_no_js,
|
|
|
|
|
|
|
|
opt_no_images,
|
|
|
|
|
|
|
|
opt_silent,
|
|
|
|
|
|
|
|
opt_no_frames,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut buf: Vec<u8> = Vec::new();
|
|
|
|
|
|
|
|
serialize(&mut buf, &dom.document, SerializeOpts::default()).unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
|
|
|
|
buf.iter().map(|&c| c as char).collect::<String>(),
|
|
|
|
|
|
|
|
"<html><head></head><frameset><frame src=\"\"></frameset></html>"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn test_walk_and_embed_assets_no_css() {
|
|
|
|
fn test_walk_and_embed_assets_no_css() {
|
|
|
|
let html = "<link rel=\"stylesheet\" href=\"main.css\">\
|
|
|
|
let html = "<link rel=\"stylesheet\" href=\"main.css\">\
|
|
|
@ -227,6 +263,41 @@ fn test_walk_and_embed_assets_no_images() {
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn test_walk_and_embed_assets_no_frames() {
|
|
|
|
fn test_walk_and_embed_assets_no_frames() {
|
|
|
|
|
|
|
|
let html = "<frameset><frame src=\"http://trackbook.com\"></frameset>";
|
|
|
|
|
|
|
|
let dom = html_to_dom(&html);
|
|
|
|
|
|
|
|
let url = "http://localhost";
|
|
|
|
|
|
|
|
let cache = &mut HashMap::new();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let opt_no_css: bool = false;
|
|
|
|
|
|
|
|
let opt_no_frames: bool = true;
|
|
|
|
|
|
|
|
let opt_no_js: bool = false;
|
|
|
|
|
|
|
|
let opt_no_images: bool = false;
|
|
|
|
|
|
|
|
let opt_silent = true;
|
|
|
|
|
|
|
|
let client = Client::new();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
walk_and_embed_assets(
|
|
|
|
|
|
|
|
cache,
|
|
|
|
|
|
|
|
&client,
|
|
|
|
|
|
|
|
&url,
|
|
|
|
|
|
|
|
&dom.document,
|
|
|
|
|
|
|
|
opt_no_css,
|
|
|
|
|
|
|
|
opt_no_js,
|
|
|
|
|
|
|
|
opt_no_images,
|
|
|
|
|
|
|
|
opt_silent,
|
|
|
|
|
|
|
|
opt_no_frames,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut buf: Vec<u8> = Vec::new();
|
|
|
|
|
|
|
|
serialize(&mut buf, &dom.document, SerializeOpts::default()).unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
|
|
|
|
buf.iter().map(|&c| c as char).collect::<String>(),
|
|
|
|
|
|
|
|
"<html><head></head><frameset><frame src=\"\"></frameset></html>"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
|
|
fn test_walk_and_embed_assets_no_iframes() {
|
|
|
|
let html = "<iframe src=\"http://trackbook.com\"></iframe>";
|
|
|
|
let html = "<iframe src=\"http://trackbook.com\"></iframe>";
|
|
|
|
let dom = html_to_dom(&html);
|
|
|
|
let dom = html_to_dom(&html);
|
|
|
|
let url = "http://localhost";
|
|
|
|
let url = "http://localhost";
|
|
|
|