diff --git a/Cargo.lock b/Cargo.lock index 67a4409f166..84c47d93e99 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3528,7 +3528,7 @@ dependencies = [ [[package]] name = "servo-media" version = "0.1.0" -source = "git+https://github.com/servo/media#a3a2e8586074227f2e4b175c94f759df3690b195" +source = "git+https://github.com/servo/media#352072f33b6d118f89aa4ccf000ceaf360a5f663" dependencies = [ "servo-media-audio 0.1.0 (git+https://github.com/servo/media)", "servo-media-gstreamer 0.1.0 (git+https://github.com/servo/media)", @@ -3538,7 +3538,7 @@ dependencies = [ [[package]] name = "servo-media-audio" version = "0.1.0" -source = "git+https://github.com/servo/media#a3a2e8586074227f2e4b175c94f759df3690b195" +source = "git+https://github.com/servo/media#352072f33b6d118f89aa4ccf000ceaf360a5f663" dependencies = [ "boxfnonce 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "byte-slice-cast 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3555,7 +3555,7 @@ dependencies = [ [[package]] name = "servo-media-gstreamer" version = "0.1.0" -source = "git+https://github.com/servo/media#a3a2e8586074227f2e4b175c94f759df3690b195" +source = "git+https://github.com/servo/media#352072f33b6d118f89aa4ccf000ceaf360a5f663" dependencies = [ "byte-slice-cast 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "glib 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3563,6 +3563,7 @@ dependencies = [ "gstreamer-app 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "gstreamer-audio 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "gstreamer-player 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gstreamer-video 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "servo-media-audio 0.1.0 (git+https://github.com/servo/media)", @@ -3573,7 +3574,7 @@ dependencies = [ [[package]] name = "servo-media-player" version = "0.1.0" -source = "git+https://github.com/servo/media#a3a2e8586074227f2e4b175c94f759df3690b195" +source = "git+https://github.com/servo/media#352072f33b6d118f89aa4ccf000ceaf360a5f663" dependencies = [ "ipc-channel 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3660,7 +3661,7 @@ dependencies = [ [[package]] name = "servo_media_derive" version = "0.1.0" -source = "git+https://github.com/servo/media#a3a2e8586074227f2e4b175c94f759df3690b195" +source = "git+https://github.com/servo/media#352072f33b6d118f89aa4ccf000ceaf360a5f663" dependencies = [ "proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/components/atoms/static_atoms.txt b/components/atoms/static_atoms.txt index 8a618bbe878..937d0ea620e 100644 --- a/components/atoms/static_atoms.txt +++ b/components/atoms/static_atoms.txt @@ -101,6 +101,7 @@ transitionend unhandledrejection unload url +volumechange waiting webglcontextcreationerror week diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs index bbdea90dee9..832a30f94c4 100644 --- a/components/script/dom/htmlmediaelement.rs +++ b/components/script/dom/htmlmediaelement.rs @@ -15,7 +15,7 @@ use crate::dom::bindings::codegen::Bindings::MediaErrorBinding::MediaErrorMethod use crate::dom::bindings::codegen::Bindings::TextTrackBinding::{TextTrackKind, TextTrackMode}; use crate::dom::bindings::codegen::InheritTypes::{ElementTypeId, HTMLElementTypeId}; use crate::dom::bindings::codegen::InheritTypes::{HTMLMediaElementTypeId, NodeTypeId}; -use crate::dom::bindings::error::{Error, ErrorResult}; +use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::num::Finite; use crate::dom::bindings::refcounted::Trusted; @@ -187,6 +187,8 @@ pub struct HTMLMediaElement { playback_position: Cell, /// https://html.spec.whatwg.org/multipage/#default-playback-start-position default_playback_start_position: Cell, + /// https://html.spec.whatwg.org/multipage/#dom-media-volume + volume: Cell, /// https://html.spec.whatwg.org/multipage/#dom-media-seeking seeking: Cell, /// URL of the media resource, if any. @@ -245,6 +247,7 @@ impl HTMLMediaElement { duration: Cell::new(f64::NAN), playback_position: Cell::new(0.), default_playback_start_position: Cell::new(0.), + volume: Cell::new(1.0), seeking: Cell::new(false), resource_url: DomRefCell::new(None), played: Rc::new(DomRefCell::new(TimeRangesContainer::new())), @@ -1413,6 +1416,32 @@ impl HTMLMediaElementMethods for HTMLMediaElement { // Step 5 DomRoot::from_ref(&track) } + + // https://html.spec.whatwg.org/multipage/#dom-media-volume + fn GetVolume(&self) -> Fallible> { + Ok(Finite::wrap(self.volume.get())) + } + + // https://html.spec.whatwg.org/multipage/#dom-media-volume + fn SetVolume(&self, value: Finite) -> ErrorResult { + let minimum_volume = 0.0; + let maximum_volume = 1.0; + if *value < minimum_volume || *value > maximum_volume { + return Err(Error::IndexSize); + } + + if *value != self.volume.get() { + self.volume.set(*value); + + let window = window_from_node(self); + window + .task_manager() + .media_element_task_source() + .queue_simple_event(self.upcast(), atom!("volumechange"), &window); + } + + Ok(()) + } } impl VirtualMethods for HTMLMediaElement { diff --git a/components/script/dom/webidls/HTMLMediaElement.webidl b/components/script/dom/webidls/HTMLMediaElement.webidl index 27e9d79c78d..d93fe067d09 100644 --- a/components/script/dom/webidls/HTMLMediaElement.webidl +++ b/components/script/dom/webidls/HTMLMediaElement.webidl @@ -54,7 +54,7 @@ interface HTMLMediaElement : HTMLElement { // controls // [CEReactions] attribute boolean controls; - // attribute double volume; + [Throws] attribute double volume; // attribute boolean muted; // [CEReactions] attribute boolean defaultMuted; diff --git a/tests/wpt/metadata/html/dom/interfaces.https.html.ini b/tests/wpt/metadata/html/dom/interfaces.https.html.ini index 9d0f0ffa39d..6affb3327d9 100644 --- a/tests/wpt/metadata/html/dom/interfaces.https.html.ini +++ b/tests/wpt/metadata/html/dom/interfaces.https.html.ini @@ -1062,7 +1062,7 @@ expected: FAIL [HTMLMediaElement interface: document.createElement("video") must inherit property "volume" with the proper type] - expected: FAIL + expected: PASS [HTMLMediaElement interface: document.createElement("video") must inherit property "muted" with the proper type] expected: FAIL @@ -1134,7 +1134,7 @@ expected: FAIL [HTMLMediaElement interface: document.createElement("audio") must inherit property "volume" with the proper type] - expected: FAIL + expected: PASS [HTMLMediaElement interface: document.createElement("audio") must inherit property "muted" with the proper type] expected: FAIL @@ -1278,7 +1278,7 @@ expected: FAIL [HTMLMediaElement interface: new Audio() must inherit property "volume" with the proper type] - expected: FAIL + expected: PASS [HTMLMediaElement interface: new Audio() must inherit property "muted" with the proper type] expected: FAIL @@ -1425,7 +1425,7 @@ expected: FAIL [HTMLMediaElement interface: attribute volume] - expected: FAIL + expected: PASS [HTMLMediaElement interface: attribute muted] expected: FAIL @@ -6793,7 +6793,7 @@ expected: FAIL [HTMLMediaElement interface: document.createElement("video") must inherit property "volume" with the proper type] - expected: FAIL + expected: PASS [HTMLMediaElement interface: document.createElement("video") must inherit property "muted" with the proper type] expected: FAIL @@ -6838,7 +6838,7 @@ expected: FAIL [HTMLMediaElement interface: document.createElement("audio") must inherit property "volume" with the proper type] - expected: FAIL + expected: PASS [HTMLMediaElement interface: document.createElement("audio") must inherit property "muted" with the proper type] expected: FAIL @@ -6883,7 +6883,7 @@ expected: FAIL [HTMLMediaElement interface: new Audio() must inherit property "volume" with the proper type] - expected: FAIL + expected: PASS [HTMLMediaElement interface: new Audio() must inherit property "muted" with the proper type] expected: FAIL @@ -7006,7 +7006,7 @@ expected: FAIL [HTMLMediaElement interface: attribute volume] - expected: FAIL + expected: PASS [HTMLMediaElement interface: attribute muted] expected: FAIL diff --git a/tests/wpt/metadata/html/semantics/embedded-content/media-elements/audio_volume_check.html.ini b/tests/wpt/metadata/html/semantics/embedded-content/media-elements/audio_volume_check.html.ini index 3ae02237dc7..874b91c99d4 100644 --- a/tests/wpt/metadata/html/semantics/embedded-content/media-elements/audio_volume_check.html.ini +++ b/tests/wpt/metadata/html/semantics/embedded-content/media-elements/audio_volume_check.html.ini @@ -1,8 +1,8 @@ [audio_volume_check.html] type: testharness [Check if media.volume is set to new value less than 0.0 that expecting an IndexSizeError exception is to be thrown] - expected: FAIL + expected: PASS [Check if audio.volume is set to new value greater than 1.0 that expecting an IndexSizeError exception is to be thrown] - expected: FAIL + expected: PASS diff --git a/tests/wpt/metadata/html/semantics/embedded-content/media-elements/event_volumechange.html.ini b/tests/wpt/metadata/html/semantics/embedded-content/media-elements/event_volumechange.html.ini index b10b96a7d6a..1d953285797 100644 --- a/tests/wpt/metadata/html/semantics/embedded-content/media-elements/event_volumechange.html.ini +++ b/tests/wpt/metadata/html/semantics/embedded-content/media-elements/event_volumechange.html.ini @@ -2,7 +2,7 @@ type: testharness expected: TIMEOUT [setting audio.volume fires volumechange] - expected: FAIL + expected: PASS [setting audio.muted fires volumechange] expected: FAIL @@ -14,7 +14,7 @@ expected: TIMEOUT [setting video.volume fires volumechange] - expected: FAIL + expected: PASS [setting video.muted fires volumechange] expected: FAIL diff --git a/tests/wpt/metadata/html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-remove-from-document.html.ini b/tests/wpt/metadata/html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-remove-from-document.html.ini index 51811a2a184..99b5ccee8b1 100644 --- a/tests/wpt/metadata/html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-remove-from-document.html.ini +++ b/tests/wpt/metadata/html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-remove-from-document.html.ini @@ -1,6 +1,6 @@ [pause-remove-from-document.html] type: testharness - expected: TIMEOUT + expected: OK [paused state when removing from a document] - expected: TIMEOUT + expected: PASS diff --git a/tests/wpt/metadata/html/semantics/embedded-content/media-elements/video_volume_check.html.ini b/tests/wpt/metadata/html/semantics/embedded-content/media-elements/video_volume_check.html.ini index 300c6c5db90..f38b076906b 100644 --- a/tests/wpt/metadata/html/semantics/embedded-content/media-elements/video_volume_check.html.ini +++ b/tests/wpt/metadata/html/semantics/embedded-content/media-elements/video_volume_check.html.ini @@ -1,8 +1,8 @@ [video_volume_check.html] type: testharness [Check if media.volume is set to new value less than 0.0 that expecting an IndexSizeError exception is to be thrown] - expected: FAIL + expected: PASS [Check if video.volume is set to new value greater than 1.0 that expecting an IndexSizeError exception is to be thrown] - expected: FAIL + expected: PASS diff --git a/tests/wpt/metadata/html/semantics/embedded-content/media-elements/volume_nonfinite.html.ini b/tests/wpt/metadata/html/semantics/embedded-content/media-elements/volume_nonfinite.html.ini index 1f75f5ba4a9..3094b820fc6 100644 --- a/tests/wpt/metadata/html/semantics/embedded-content/media-elements/volume_nonfinite.html.ini +++ b/tests/wpt/metadata/html/semantics/embedded-content/media-elements/volume_nonfinite.html.ini @@ -1,20 +1,20 @@ [volume_nonfinite.html] type: testharness [Setting audio.volume to NaN should throw a TypeError] - expected: FAIL + expected: PASS [Setting audio.volume to Infinity should throw a TypeError] - expected: FAIL + expected: PASS [Setting audio.volume to -Infinity should throw a TypeError] - expected: FAIL + expected: PASS [Setting video.volume to NaN should throw a TypeError] - expected: FAIL + expected: PASS [Setting video.volume to Infinity should throw a TypeError] - expected: FAIL + expected: PASS [Setting video.volume to -Infinity should throw a TypeError] - expected: FAIL + expected: PASS