From 93d7ddd6d7222ccf35c6d4c387a226cecb83dddb Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Tue, 11 Feb 2014 12:03:46 -0800 Subject: [PATCH 1/5] Add a simple iframe test page --- src/test/html/simple_iframe.html | 7 +++++++ src/test/html/simple_iframe_inner.html | 5 +++++ 2 files changed, 12 insertions(+) create mode 100644 src/test/html/simple_iframe.html create mode 100644 src/test/html/simple_iframe_inner.html diff --git a/src/test/html/simple_iframe.html b/src/test/html/simple_iframe.html new file mode 100644 index 00000000000..e02aab29af5 --- /dev/null +++ b/src/test/html/simple_iframe.html @@ -0,0 +1,7 @@ + + + + + diff --git a/src/test/html/simple_iframe_inner.html b/src/test/html/simple_iframe_inner.html new file mode 100644 index 00000000000..221c287c6f3 --- /dev/null +++ b/src/test/html/simple_iframe_inner.html @@ -0,0 +1,5 @@ + + +Just a simple little iframe. + + From d1f98e0c755ac349ba993a2d1fea876f4c52b80d Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Tue, 11 Feb 2014 12:13:43 -0800 Subject: [PATCH 2/5] Convert data-url.html to a reftest --- src/test/ref/basic.list | 1 + .../{html/data-url.html => ref/data_img_a.html} | 0 src/test/ref/data_img_b.html | 9 +++++++++ src/test/ref/img_size_a.html | 6 +++--- src/test/ref/img_size_b.html | 6 +++--- src/test/ref/{img_size.png => rust_logo.png} | Bin 6 files changed, 16 insertions(+), 6 deletions(-) rename src/test/{html/data-url.html => ref/data_img_a.html} (100%) create mode 100644 src/test/ref/data_img_b.html rename src/test/ref/{img_size.png => rust_logo.png} (100%) diff --git a/src/test/ref/basic.list b/src/test/ref/basic.list index 16ff2c93568..290a00741ca 100644 --- a/src/test/ref/basic.list +++ b/src/test/ref/basic.list @@ -28,3 +28,4 @@ == anon_block_inherit_a.html anon_block_inherit_b.html == position_relative_a.html position_relative_b.html == attr_exists_selector.html attr_exists_selector_ref.html +== data_img_a.html data_img_b.html diff --git a/src/test/html/data-url.html b/src/test/ref/data_img_a.html similarity index 100% rename from src/test/html/data-url.html rename to src/test/ref/data_img_a.html diff --git a/src/test/ref/data_img_b.html b/src/test/ref/data_img_b.html new file mode 100644 index 00000000000..265d57ec76b --- /dev/null +++ b/src/test/ref/data_img_b.html @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/test/ref/img_size_a.html b/src/test/ref/img_size_a.html index bcfa30137d0..a96abad3736 100644 --- a/src/test/ref/img_size_a.html +++ b/src/test/ref/img_size_a.html @@ -6,13 +6,13 @@
- +
- +
- +
diff --git a/src/test/ref/img_size_b.html b/src/test/ref/img_size_b.html index d0cf3da554d..ee21881dfdb 100644 --- a/src/test/ref/img_size_b.html +++ b/src/test/ref/img_size_b.html @@ -6,13 +6,13 @@
- +
- +
- +
diff --git a/src/test/ref/img_size.png b/src/test/ref/rust_logo.png similarity index 100% rename from src/test/ref/img_size.png rename to src/test/ref/rust_logo.png From d72379829800db3a6248963f0cb2c731138af061 Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Wed, 8 Jan 2014 15:02:29 -0800 Subject: [PATCH 3/5] Eliminate string match allocation in url.rs --- src/components/util/url.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/util/url.rs b/src/components/util/url.rs index 708b8d57aa2..19f5eaaece3 100644 --- a/src/components/util/url.rs +++ b/src/components/util/url.rs @@ -56,10 +56,10 @@ pub fn parse_url(str_url: &str, base_url: Option) -> Url { } }, Ok((scheme, page)) => { - match scheme { - ~"about" => { - match page { - ~"failure" => { + match scheme.as_slice() { + "about" => { + match page.as_slice() { + "failure" => { let mut path = os::getcwd(); path.push("../src/test/html/failure.html"); // FIXME (#1094): not the right way to transform a path @@ -69,7 +69,7 @@ pub fn parse_url(str_url: &str, base_url: Option) -> Url { _ => str_url } }, - ~"data" => { + "data" => { // Drop whitespace within data: URLs, e.g. newlines within a base64 // src="..." block. Whitespace intended as content should be // %-encoded or base64'd. From 8a7cc86aa9759d7b49f7ba524e2f0d42c96bc59f Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Tue, 11 Feb 2014 14:25:09 -0800 Subject: [PATCH 4/5] Provide an error message for URL parse failure --- src/components/util/url.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/util/url.rs b/src/components/util/url.rs index 19f5eaaece3..5010c374769 100644 --- a/src/components/util/url.rs +++ b/src/components/util/url.rs @@ -81,7 +81,7 @@ pub fn parse_url(str_url: &str, base_url: Option) -> Url { }; // FIXME: Need to handle errors - url::from_str(str_url).unwrap() + url::from_str(str_url).ok().expect("URL parsing failed") } #[cfg(test)] From 0a8ada86c52d9f850f635d1f963c504db6850de6 Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Tue, 11 Feb 2014 14:53:19 -0800 Subject: [PATCH 5/5] Accept data: URLs on the command line without URL encoding This facilitates quick testing, e.g. ./servo 'data:,
hi
' --- src/components/main/servo.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/main/servo.rs b/src/components/main/servo.rs index 86f1602754c..b21c292255b 100755 --- a/src/components/main/servo.rs +++ b/src/components/main/servo.rs @@ -62,6 +62,8 @@ pub use servo_util::url::parse_url; #[cfg(not(test))] use std::os; +#[cfg(not(test))] +use extra::url::Url; #[cfg(not(test), target_os="android")] use std::str; #[cfg(not(test))] @@ -166,7 +168,16 @@ fn run(opts: Opts) { // Send the URL command to the constellation. for filename in opts.urls.iter() { - constellation_chan.send(InitLoadUrlMsg(parse_url(*filename, None))) + let url = if filename.starts_with("data:") { + // As a hack for easier command-line testing, + // assume that data URLs are not URL-encoded. + Url::new(~"data", None, ~"", None, + filename.slice_from(5).to_owned(), ~[], None) + } else { + parse_url(*filename, None) + }; + + constellation_chan.send(InitLoadUrlMsg(url)); } // Send the constallation Chan as the result