Implement the error path for source children of media elements

This removes some test timeout.
This commit is contained in:
Anthony Ramine 2017-09-25 00:28:59 +02:00
parent 49dd04cd8b
commit 5245931dc2
8 changed files with 54 additions and 24 deletions

View file

@ -3,10 +3,14 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::HTMLSourceElementBinding;
use dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::NodeMethods;
use dom::bindings::inheritance::Castable;
use dom::bindings::js::Root;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::htmlmediaelement::HTMLMediaElement;
use dom::node::Node;
use dom::virtualmethods::VirtualMethods;
use dom_struct::dom_struct;
use html5ever::{LocalName, Prefix};
@ -34,3 +38,18 @@ impl HTMLSourceElement {
HTMLSourceElementBinding::Wrap)
}
}
impl VirtualMethods for HTMLSourceElement {
fn super_type(&self) -> Option<&VirtualMethods> {
Some(self.upcast::<HTMLElement>() as &VirtualMethods)
}
/// https://html.spec.whatwg.org/multipage/#the-source-element:nodes-are-inserted
fn bind_to_tree(&self, tree_in_doc: bool) {
self.super_type().unwrap().bind_to_tree(tree_in_doc);
let parent = self.upcast::<Node>().GetParentNode().unwrap();
if let Some(media) = parent.downcast::<HTMLMediaElement>() {
media.handle_source_child_insertion();
}
}
}