mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
create about_loader, handle about:blank
This commit is contained in:
parent
b8b51b6dd8
commit
523445c865
10 changed files with 64 additions and 27 deletions
41
components/net/about_loader.rs
Normal file
41
components/net/about_loader.rs
Normal file
|
@ -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<LoadResponse>) {
|
||||
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)
|
||||
}
|
|
@ -18,7 +18,7 @@ pub fn factory(load_data: LoadData, start_chan: Sender<LoadResponse>) {
|
|||
// 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<LoadResponse>) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -12,7 +12,7 @@ use servo_util::task::spawn_named;
|
|||
use url::Url;
|
||||
|
||||
pub fn factory(load_data: LoadData, start_chan: Sender<LoadResponse>) {
|
||||
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<LoadResponse>) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<LoadResponse>) {
|
||||
fn load(&self, load_data: LoadData, start_chan: Sender<LoadResponse>) {
|
||||
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))
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
[open-url-about-blank-window.htm]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[XMLHttpRequest: open() resolving URLs (about:blank iframe)]
|
||||
expected: FAIL
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
[exceptions.html]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[exception.hasOwnProperty("message")]
|
||||
expected: FAIL
|
||||
[Object.getOwnPropertyDescriptor(exception, "message")]
|
||||
expected: FAIL
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
[indexed-browsing-contexts-03.html]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[Indexed child browsing contexts]
|
||||
expected: FAIL
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue