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));
}
}
}

View file

@ -12553,6 +12553,10 @@
"path": "html/semantics/document-metadata/the-base-element/base_multiple.html",
"url": "/html/semantics/document-metadata/the-base-element/base_multiple.html"
},
{
"path": "html/semantics/document-metadata/the-link-element/link-load-event.html",
"url": "/html/semantics/document-metadata/the-link-element/link-load-event.html"
},
{
"path": "html/semantics/document-metadata/the-link-element/link-rellist.html",
"url": "/html/semantics/document-metadata/the-link-element/link-rellist.html"
@ -25924,4 +25928,4 @@
"rev": "fef3eb9bbb033d1d7150f4c70ecc1a5f59bcf115",
"url_base": "/",
"version": 2
}
}

View file

@ -2,7 +2,55 @@
type: testharness
expected: TIMEOUT
[src removed]
expected: FAIL
expected: TIMEOUT
[inserted into picture]
expected: TIMEOUT
[removed from picture]
expected: TIMEOUT
[parent is picture, previous source inserted]
expected: TIMEOUT
[parent is picture, previous source removed]
expected: TIMEOUT
[parent is picture, previous source has srcset set]
expected: TIMEOUT
[parent is picture, previous source has srcset changed]
expected: TIMEOUT
[parent is picture, previous source has srcset removed]
expected: TIMEOUT
[parent is picture, previous source has sizes set]
expected: TIMEOUT
[parent is picture, previous source has sizes changed]
expected: TIMEOUT
[parent is picture, previous source has sizes removed]
expected: TIMEOUT
[parent is picture, previous source has media set]
expected: TIMEOUT
[parent is picture, previous source has media changed]
expected: TIMEOUT
[parent is picture, previous source has media removed]
expected: TIMEOUT
[parent is picture, previous source has type set]
expected: TIMEOUT
[parent is picture, previous source has type changed]
expected: TIMEOUT
[parent is picture, previous source has type removed]
expected: TIMEOUT
[srcset set]
expected: TIMEOUT
@ -52,84 +100,3 @@
[crossorigin use-credentials to anonymous]
expected: TIMEOUT
[crossorigin state not changed: absent, removeAttribute]
expected: FAIL
[crossorigin state not changed: empty to anonymous]
expected: FAIL
[crossorigin state not changed: anonymous to foobar]
expected: FAIL
[crossorigin state not changed: use-credentials to USE-CREDENTIALS]
expected: FAIL
[inserted into picture ancestor]
expected: FAIL
[removed from picture ancestor]
expected: FAIL
[ancestor picture has a source inserted]
expected: FAIL
[ancestor picture has a source removed]
expected: FAIL
[ancestor picture; previous sibling source inserted]
expected: FAIL
[ancestor picture; previous sibling source removed]
expected: FAIL
[parent is picture, following sibling source inserted]
expected: FAIL
[parent is picture, following sibling source removed]
expected: FAIL
[parent is picture, following sibling source has srcset set]
expected: FAIL
[media on img set]
expected: FAIL
[type on img set]
expected: FAIL
[class on img set]
expected: FAIL
[alt on img set]
expected: FAIL
[src on previous sibling source set]
expected: FAIL
[class on previous sibling source set]
expected: FAIL
[inserted/removed children of img]
expected: FAIL
[picture is inserted]
expected: FAIL
[picture is removed]
expected: FAIL
[parent is picture, following img inserted]
expected: FAIL
[parent is picture, following img removed]
expected: FAIL
[parent is picture, following img has src set]
expected: FAIL
[parent is picture, following img has srcset set]
expected: FAIL
[parent is picture, following img has sizes set]
expected: FAIL

View file

@ -521,12 +521,6 @@
"url": "/_mozilla/mozilla/storage.html"
}
],
"mozilla/stylesheet_load.html": [
{
"path": "mozilla/stylesheet_load.html",
"url": "/_mozilla/mozilla/stylesheet_load.html"
}
],
"mozilla/textcontent.html": [
{
"path": "mozilla/textcontent.html",

View file

@ -1,11 +1,12 @@
<html>
<head>
<!DOCTYPE html>
<link rel="author" title="Josh Matthews" href="mailto:josh@joshmatthews.net">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-link-element">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link href="resources/style.css" rel="stylesheet" id="style_test"></link>
<link href="style.css?pipe=trickle(d3)" rel="stylesheet" id="style_test"></link>
<script>
var saw_link_onload = false;
var t = async_test();
var t = async_test("Check if the stylesheet's load event blocks the document load event");
document.getElementById('style_test').onload = t.step_func(function() {
saw_link_onload = true;
});