diff --git a/components/net/about_loader.rs b/components/net/about_loader.rs new file mode 100644 index 00000000000..af855d26071 --- /dev/null +++ b/components/net/about_loader.rs @@ -0,0 +1,41 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +use resource_task::{LoadResponse, Metadata, Done, LoadData, start_sending}; +use file_loader; + +use std::os; +use url::Url; +use StatusOk = http::status::Ok; + + +pub fn factory(mut load_data: LoadData, start_chan: Sender) { + match load_data.url.non_relative_scheme_data().unwrap() { + "blank" => { + let chan = start_sending(start_chan, Metadata { + final_url: load_data.url, + content_type: Some(("text".to_string(), "html".to_string())), + charset: Some("utf-8".to_string()), + headers: None, + status: StatusOk, + }); + chan.send(Done(Ok(()))); + return + } + "crash" => fail!("Loading the about:crash URL."), + "failure" => { + // FIXME: Find a way to load this without relying on the `../src` directory. + let mut path = os::self_exe_path().expect("can't get exe path"); + path.pop(); + path.push_many(["src", "test", "html", "failure.html"]); + load_data.url = Url::from_file_path(&path).unwrap(); + } + _ => { + start_sending(start_chan, Metadata::default(load_data.url)) + .send(Done(Err("Unknown about: URL.".to_string()))); + return + } + }; + file_loader::factory(load_data, start_chan) +} diff --git a/components/net/data_loader.rs b/components/net/data_loader.rs index 0a33aa392c5..43d59fcf33a 100644 --- a/components/net/data_loader.rs +++ b/components/net/data_loader.rs @@ -18,7 +18,7 @@ pub fn factory(load_data: LoadData, start_chan: Sender) { // Hypothesis: data URLs are too small for parallel base64 etc. to be worth it. // Should be tested at some point. // Left in separate function to allow easy moving to a task, if desired. - load(url, start_chan) + load(load_data, start_chan) } fn load(load_data: LoadData, start_chan: Sender) { diff --git a/components/net/file_loader.rs b/components/net/file_loader.rs index c08f6f90ee8..c9a95ccd985 100644 --- a/components/net/file_loader.rs +++ b/components/net/file_loader.rs @@ -2,7 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use resource_task::{ProgressMsg, Metadata, Payload, Done, start_sending}; +use resource_task::{ProgressMsg, Metadata, Payload, Done, LoadData, start_sending}; +use resource_task::{LoadResponse}; use std::io; use std::io::File; diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs index 92b9692fda0..7af4bf2ca00 100644 --- a/components/net/http_loader.rs +++ b/components/net/http_loader.rs @@ -12,7 +12,7 @@ use servo_util::task::spawn_named; use url::Url; pub fn factory(load_data: LoadData, start_chan: Sender) { - spawn_named("http_loader", proc() load(url, start_chan)) + spawn_named("http_loader", proc() load(load_data, start_chan)) } fn send_error(url: Url, err: String, start_chan: Sender) { diff --git a/components/net/lib.rs b/components/net/lib.rs index bb1c5d47b1a..c4275944eff 100644 --- a/components/net/lib.rs +++ b/components/net/lib.rs @@ -28,6 +28,7 @@ pub mod image { pub mod holder; } +pub mod about_loader; pub mod file_loader; pub mod http_loader; pub mod data_loader; diff --git a/components/net/resource_task.rs b/components/net/resource_task.rs index 281a727f50f..cdc44fe2cec 100644 --- a/components/net/resource_task.rs +++ b/components/net/resource_task.rs @@ -4,13 +4,13 @@ //! A task that takes a URL and streams back the binary data. +use about_loader; +use data_loader; use file_loader; use http_loader; -use data_loader; use std::comm::{channel, Receiver, Sender}; use std::task::TaskBuilder; -use std::os; use http::headers::content_type::MediaType; use ResponseHeaderCollection = http::headers::response::HeaderCollection; use RequestHeaderCollection = http::headers::request::HeaderCollection; @@ -201,29 +201,12 @@ impl ResourceManager { } } - fn load(&self, mut load_data: LoadData, start_chan: Sender) { + fn load(&self, load_data: LoadData, start_chan: Sender) { let loader = match load_data.url.scheme.as_slice() { "file" => file_loader::factory, "http" | "https" => http_loader::factory, "data" => data_loader::factory, - "about" => { - match load_data.url.non_relative_scheme_data().unwrap() { - "crash" => fail!("Loading the about:crash URL."), - "failure" => { - // FIXME: Find a way to load this without relying on the `../src` directory. - let mut path = os::self_exe_path().expect("can't get exe path"); - path.pop(); - path.push_many(["src", "test", "html", "failure.html"]); - load_data.url = Url::from_file_path(&path).unwrap(); - file_loader::factory - } - _ => { - start_sending(start_chan, Metadata::default(load_data.url)) - .send(Done(Err("Unknown about: URL.".to_string()))); - return - } - } - }, + "about" => about_loader::factory, _ => { debug!("resource_task: no loader for scheme {:s}", load_data.url.scheme); start_sending(start_chan, Metadata::default(load_data.url)) diff --git a/tests/wpt/metadata/XMLHttpRequest/open-url-about-blank-window.htm.ini b/tests/wpt/metadata/XMLHttpRequest/open-url-about-blank-window.htm.ini index da6e5e64ff5..db1fd4fc85f 100644 --- a/tests/wpt/metadata/XMLHttpRequest/open-url-about-blank-window.htm.ini +++ b/tests/wpt/metadata/XMLHttpRequest/open-url-about-blank-window.htm.ini @@ -1,3 +1,4 @@ [open-url-about-blank-window.htm] type: testharness - expected: TIMEOUT + [XMLHttpRequest: open() resolving URLs (about:blank iframe)] + expected: FAIL diff --git a/tests/wpt/metadata/dom/errors/exceptions.html.ini b/tests/wpt/metadata/dom/errors/exceptions.html.ini index 7a1fe4d6a48..6ac1acd3b04 100644 --- a/tests/wpt/metadata/dom/errors/exceptions.html.ini +++ b/tests/wpt/metadata/dom/errors/exceptions.html.ini @@ -1,3 +1,7 @@ [exceptions.html] type: testharness expected: TIMEOUT + [exception.hasOwnProperty("message")] + expected: FAIL + [Object.getOwnPropertyDescriptor(exception, "message")] + expected: FAIL diff --git a/tests/wpt/metadata/dom/nodes/Node-appendChild.html.ini b/tests/wpt/metadata/dom/nodes/Node-appendChild.html.ini index 4b30c987166..303b8caca89 100644 --- a/tests/wpt/metadata/dom/nodes/Node-appendChild.html.ini +++ b/tests/wpt/metadata/dom/nodes/Node-appendChild.html.ini @@ -1,3 +1,8 @@ [Node-appendChild.html] type: testharness - expected: TIMEOUT + [Appending a document] + expected: FAIL + [Adopting an orphan] + expected: FAIL + [Adopting a non-orphan] + expected: FAIL diff --git a/tests/wpt/metadata/html/browsers/the-window-object/accessing-other-browsing-contexts/indexed-browsing-contexts-03.html.ini b/tests/wpt/metadata/html/browsers/the-window-object/accessing-other-browsing-contexts/indexed-browsing-contexts-03.html.ini index 10dc810f8b4..c20a211da91 100644 --- a/tests/wpt/metadata/html/browsers/the-window-object/accessing-other-browsing-contexts/indexed-browsing-contexts-03.html.ini +++ b/tests/wpt/metadata/html/browsers/the-window-object/accessing-other-browsing-contexts/indexed-browsing-contexts-03.html.ini @@ -1,3 +1,4 @@ [indexed-browsing-contexts-03.html] type: testharness - expected: TIMEOUT + [Indexed child browsing contexts] + expected: FAIL