Delay stylesheet load in test to increase confidence.

This commit is contained in:
Josh Matthews 2015-04-23 10:45:57 -04:00
parent f3cdba6b8b
commit a1ae53a230
12 changed files with 82 additions and 116 deletions

View file

@ -108,7 +108,7 @@ impl Pipeline {
script_port,
constellation_chan.clone(),
failure.clone(),
resource_task.clone(),
resource_task,
storage_task.clone(),
image_cache_task.clone(),
devtools_chan,

View file

@ -610,7 +610,7 @@ impl LayoutTask {
Some(environment_encoding),
Origin::Author);
//TODO: mark critical subresources as blocking load as well
//TODO: mark critical subresources as blocking load as well (#5974)
let ScriptControlChan(ref chan) = self.script_chan;
chan.send(ConstellationControlMsg::StylesheetLoadComplete(self.id, url, responder)).unwrap();

View file

@ -126,13 +126,14 @@ pub enum ControlMsg {
}
/// Initialized but unsent request. Encapsulates everything necessary to instruct
/// the resource task to make a new request.
/// the resource task to make a new request. The `load` method *must* be called before
/// destruction or the task will panic.
pub struct PendingAsyncLoad {
resource_task: ResourceTask,
url: Url,
pipeline: Option<PipelineId>,
input_chan: Sender<LoadResponse>,
input_port: Receiver<LoadResponse>,
input_sender: Sender<LoadResponse>,
input_receiver: Receiver<LoadResponse>,
guard: PendingLoadGuard,
}
@ -155,13 +156,13 @@ impl Drop for PendingLoadGuard {
impl PendingAsyncLoad {
pub fn new(resource_task: ResourceTask, url: Url, pipeline: Option<PipelineId>)
-> PendingAsyncLoad {
let (tx, rx) = channel();
let (sender, receiver) = channel();
PendingAsyncLoad {
resource_task: resource_task,
url: url,
pipeline: pipeline,
input_chan: tx,
input_port: rx,
input_sender: sender,
input_receiver: receiver,
guard: PendingLoadGuard { loaded: false, },
}
}
@ -170,8 +171,9 @@ impl PendingAsyncLoad {
pub fn load(mut self) -> Receiver<LoadResponse> {
self.guard.neuter();
let load_data = LoadData::new(self.url, self.pipeline);
self.resource_task.send(ControlMsg::Load(load_data, LoadConsumer::Channel(self.input_chan))).unwrap();
self.input_port
let consumer = LoadConsumer::Channel(self.input_sender);
self.resource_task.send(ControlMsg::Load(load_data, consumer)).unwrap();
self.input_receiver
}
}

View file

@ -56,10 +56,7 @@ impl DocumentLoader {
data: Option<NotifierData>,
initial_load: Option<Url>,)
-> DocumentLoader {
let mut initial_loads = vec!();
if let Some(load) = initial_load {
initial_loads.push(LoadType::PageSource(load));
}
let initial_loads = initial_load.into_iter().map(LoadType::PageSource).collect();
DocumentLoader {
resource_task: resource_task,
@ -70,15 +67,16 @@ impl DocumentLoader {
/// Create a new pending network request, which can be initiated at some point in
/// the future.
pub fn prep_async_load(&mut self, load: LoadType) -> PendingAsyncLoad {
self.blocking_loads.push(load.clone());
pub fn prepare_async_load(&mut self, load: LoadType) -> PendingAsyncLoad {
let url = load.url().clone();
self.blocking_loads.push(load);
let pipeline = self.notifier_data.as_ref().map(|data| data.pipeline);
PendingAsyncLoad::new(self.resource_task.clone(), load.url().clone(), pipeline)
PendingAsyncLoad::new(self.resource_task.clone(), url, pipeline)
}
/// Create and initiate a new network request.
pub fn load_async(&mut self, load: LoadType) -> Receiver<LoadResponse> {
let pending = self.prep_async_load(load);
let pending = self.prepare_async_load(load);
pending.load()
}

View file

@ -260,7 +260,7 @@ pub trait DocumentHelpers<'a> {
fn cancel_animation_frame(self, ident: i32);
/// http://w3c.github.io/animation-timing/#dfn-invoke-callbacks-algorithm
fn invoke_animation_callbacks(self);
fn prep_async_load(self, load: LoadType) -> PendingAsyncLoad;
fn prepare_async_load(self, load: LoadType) -> PendingAsyncLoad;
fn load_async(self, load: LoadType) -> Receiver<LoadResponse>;
fn load_sync(self, load: LoadType) -> Result<(Metadata, Vec<u8>), String>;
fn finish_load(self, load: LoadType);
@ -885,9 +885,9 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
}
}
fn prep_async_load(self, load: LoadType) -> PendingAsyncLoad {
fn prepare_async_load(self, load: LoadType) -> PendingAsyncLoad {
let mut loader = self.loader.borrow_mut();
loader.prep_async_load(load)
loader.prepare_async_load(load)
}
fn load_async(self, load: LoadType) -> Receiver<LoadResponse> {

View file

@ -159,7 +159,7 @@ impl<'a> PrivateHTMLLinkElementHelpers for JSRef<'a, HTMLLinkElement> {
let link_element = Trusted::new(window.get_cx(), self, window.script_chan().clone());
let load_dispatcher = StylesheetLoadDispatcher::new(link_element);
let pending = doc.r().prep_async_load(LoadType::Stylesheet(url.clone()));
let pending = doc.r().prepare_async_load(LoadType::Stylesheet(url.clone()));
let LayoutChan(ref layout_chan) = window.layout_chan();
layout_chan.send(Msg::LoadStylesheet(url, media, pending, box load_dispatcher)).unwrap();
}

View file

@ -732,8 +732,8 @@ impl ScriptTask {
ConstellationControlMsg::TickAllAnimations(pipeline_id) =>
self.handle_tick_all_animations(pipeline_id),
ConstellationControlMsg::StylesheetLoadComplete(id, url, responder) => {
self.handle_resource_loaded(id, LoadType::Stylesheet(url));
responder.respond();
self.handle_resource_loaded(id, LoadType::Stylesheet(url));
}
}
}