From a1ae53a230cf8643dc768669b52b386e62882253 Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Thu, 23 Apr 2015 10:45:57 -0400 Subject: [PATCH] Delay stylesheet load in test to increase confidence. --- components/compositing/pipeline.rs | 2 +- components/layout/layout_task.rs | 2 +- components/net_traits/lib.rs | 18 +-- components/script/document_loader.rs | 14 +- components/script/dom/document.rs | 6 +- components/script/dom/htmllinkelement.rs | 2 +- components/script/script_task.rs | 2 +- tests/wpt/metadata/MANIFEST.json | 6 +- .../relevant-mutations.html.ini | 131 +++++++----------- tests/wpt/mozilla/meta/MANIFEST.json | 6 - .../the-link-element/link-load-event.html} | 9 +- .../the-link-element}/style.css | 0 12 files changed, 82 insertions(+), 116 deletions(-) rename tests/wpt/{mozilla/tests/mozilla/stylesheet_load.html => web-platform-tests/html/semantics/document-metadata/the-link-element/link-load-event.html} (53%) rename tests/wpt/{mozilla/tests/mozilla/resources => web-platform-tests/html/semantics/document-metadata/the-link-element}/style.css (100%) diff --git a/components/compositing/pipeline.rs b/components/compositing/pipeline.rs index 82250d44b65..2402ed23f1f 100644 --- a/components/compositing/pipeline.rs +++ b/components/compositing/pipeline.rs @@ -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, diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index c29f421f80a..a7c89ded388 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -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(); diff --git a/components/net_traits/lib.rs b/components/net_traits/lib.rs index 533e4fc42fb..46fcc476843 100644 --- a/components/net_traits/lib.rs +++ b/components/net_traits/lib.rs @@ -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, - input_chan: Sender, - input_port: Receiver, + input_sender: Sender, + input_receiver: Receiver, guard: PendingLoadGuard, } @@ -155,13 +156,13 @@ impl Drop for PendingLoadGuard { impl PendingAsyncLoad { pub fn new(resource_task: ResourceTask, url: Url, pipeline: Option) -> 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 { 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 } } diff --git a/components/script/document_loader.rs b/components/script/document_loader.rs index bd144ed6547..6b8dfcea801 100644 --- a/components/script/document_loader.rs +++ b/components/script/document_loader.rs @@ -56,10 +56,7 @@ impl DocumentLoader { data: Option, initial_load: Option,) -> 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 { - let pending = self.prep_async_load(load); + let pending = self.prepare_async_load(load); pending.load() } diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 2c11b33b04c..e08e47f85fe 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -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; fn load_sync(self, load: LoadType) -> Result<(Metadata, Vec), 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 { diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs index fd2d3471a61..b8dc06f8080 100644 --- a/components/script/dom/htmllinkelement.rs +++ b/components/script/dom/htmllinkelement.rs @@ -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(); } diff --git a/components/script/script_task.rs b/components/script/script_task.rs index 34faad42ec4..775e45b29a8 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -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)); } } } diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json index 3a6c2845cd5..1ac47eda7ca 100644 --- a/tests/wpt/metadata/MANIFEST.json +++ b/tests/wpt/metadata/MANIFEST.json @@ -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 -} \ No newline at end of file +} diff --git a/tests/wpt/metadata/html/semantics/embedded-content/the-img-element/relevant-mutations.html.ini b/tests/wpt/metadata/html/semantics/embedded-content/the-img-element/relevant-mutations.html.ini index 97f48f3e0f8..7e20c7aa0eb 100644 --- a/tests/wpt/metadata/html/semantics/embedded-content/the-img-element/relevant-mutations.html.ini +++ b/tests/wpt/metadata/html/semantics/embedded-content/the-img-element/relevant-mutations.html.ini @@ -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 - diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 37b28df50ad..841aa8f1c5b 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -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", diff --git a/tests/wpt/mozilla/tests/mozilla/stylesheet_load.html b/tests/wpt/web-platform-tests/html/semantics/document-metadata/the-link-element/link-load-event.html similarity index 53% rename from tests/wpt/mozilla/tests/mozilla/stylesheet_load.html rename to tests/wpt/web-platform-tests/html/semantics/document-metadata/the-link-element/link-load-event.html index bf095725a5c..afe86a4210c 100644 --- a/tests/wpt/mozilla/tests/mozilla/stylesheet_load.html +++ b/tests/wpt/web-platform-tests/html/semantics/document-metadata/the-link-element/link-load-event.html @@ -1,11 +1,12 @@ - - + + + - +