Reftest for video poster frame

This commit is contained in:
Fernando Jiménez Moreno 2018-12-26 15:39:48 +01:00
parent 5c5b5aae0f
commit 9d5499bbfb
10 changed files with 88 additions and 1 deletions

View file

@ -57,6 +57,7 @@ use net_traits::request::{CredentialsMode, Destination, RequestInit};
use net_traits::{CoreResourceMsg, FetchChannels, FetchMetadata, FetchResponseListener, Metadata};
use net_traits::{NetworkError, ResourceFetchTiming, ResourceTimingType};
use script_layout_interface::HTMLMediaData;
use servo_config::prefs::PREFS;
use servo_media::player::frame::{Frame, FrameRenderer};
use servo_media::player::{PlaybackState, Player, PlayerError, PlayerEvent, StreamType};
use servo_media::ServoMedia;
@ -1098,6 +1099,14 @@ impl HTMLMediaElement {
.unwrap()
.render_poster_frame(image);
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
if let Some(testing_on) = PREFS.get("media.testing.enabled").as_boolean() {
if !testing_on {
return;
}
let window = window_from_node(self);
let task_source = window.task_manager().media_element_task_source();
task_source.queue_simple_event(self.upcast(), atom!("postershown"), &window);
}
}
}

View file

@ -6,6 +6,7 @@ use crate::dom::attr::Attr;
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::HTMLVideoElementBinding;
use crate::dom::bindings::codegen::Bindings::HTMLVideoElementBinding::HTMLVideoElementMethods;
use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::refcounted::Trusted;
use crate::dom::bindings::reflector::DomObject;
@ -113,6 +114,11 @@ impl HTMLVideoElement {
// Step 3.
let poster_url = match ServoUrl::parse(poster_url) {
Ok(url) => url,
Err(url::ParseError::RelativeUrlWithoutBase) => {
let window = window_from_node(self);
let url = window.Location().get_url();
url.join(&poster_url).unwrap()
},
Err(_) => return,
};
@ -219,6 +225,10 @@ impl HTMLVideoElementMethods for HTMLVideoElement {
// https://html.spec.whatwg.org/multipage/#dom-video-poster
make_setter!(SetPoster, "poster");
// For testing purposes only. This is not an event from
// https://html.spec.whatwg.org/multipage/#dom-video-poster
event_handler!(postershown, GetOnpostershown, SetOnpostershown);
}
impl VirtualMethods for HTMLVideoElement {

View file

@ -37,7 +37,7 @@ impl Location {
)
}
fn get_url(&self) -> ServoUrl {
pub fn get_url(&self) -> ServoUrl {
self.window.get_url()
}

View file

@ -13,3 +13,8 @@ interface HTMLVideoElement : HTMLMediaElement {
readonly attribute unsigned long videoHeight;
[CEReactions] attribute DOMString poster;
};
partial interface HTMLVideoElement {
[Pref="media.testing.enabled"]
attribute EventHandler onpostershown;
};