aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlmediaelement.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2019-05-22 07:52:26 -0400
committerGitHub <noreply@github.com>2019-05-22 07:52:26 -0400
commit377ade0aeda488edf36519a42e85115b7a597bf0 (patch)
treeacd18dd25cd2c4ab0bd49ae6425e73a08137b0d6 /components/script/dom/htmlmediaelement.rs
parent1cbb04c647ae4dc6d97054f53d0b839b444bbca4 (diff)
parentade697b782bd00b3168f39ab1a32b3be074e89ed (diff)
downloadservo-377ade0aeda488edf36519a42e85115b7a597bf0.tar.gz
servo-377ade0aeda488edf36519a42e85115b7a597bf0.zip
Auto merge of #23188 - jackxbritton:issue-22287, r=KiChjang,ferjm
Implement HTMLMediaElement.crossorigin attribute logic. <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [x] These changes fix #22287 - [X] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23188) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/htmlmediaelement.rs')
-rw-r--r--components/script/dom/htmlmediaelement.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs
index 66fb85b6732..c816494fb70 100644
--- a/components/script/dom/htmlmediaelement.rs
+++ b/components/script/dom/htmlmediaelement.rs
@@ -30,6 +30,9 @@ use crate::dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom};
use crate::dom::bindings::str::{DOMString, USVString};
use crate::dom::blob::Blob;
use crate::dom::document::Document;
+use crate::dom::element::{
+ cors_setting_for_element, reflect_cross_origin_attribute, set_cross_origin_attribute,
+};
use crate::dom::element::{AttributeMutation, Element};
use crate::dom::event::Event;
use crate::dom::eventtarget::EventTarget;
@@ -64,7 +67,7 @@ use ipc_channel::ipc;
use ipc_channel::router::ROUTER;
use net_traits::image::base::Image;
use net_traits::image_cache::ImageResponse;
-use net_traits::request::{CredentialsMode, Destination, Referrer, RequestBuilder};
+use net_traits::request::{CredentialsMode, Destination, Referrer, RequestBuilder, RequestMode};
use net_traits::{CoreResourceMsg, FetchChannels, FetchMetadata, FetchResponseListener, Metadata};
use net_traits::{NetworkError, ResourceFetchTiming, ResourceTimingType};
use script_layout_interface::HTMLMediaData;
@@ -707,7 +710,6 @@ impl HTMLMediaElement {
return;
}
- // FIXME(nox): Handle CORS setting from crossorigin attribute.
let document = document_from_node(self);
let destination = match self.media_type_id() {
HTMLMediaElementTypeId::HTMLAudioElement => Destination::Audio,
@@ -728,6 +730,11 @@ impl HTMLMediaElement {
.headers(headers)
.destination(destination)
.credentials_mode(CredentialsMode::Include)
+ // https://html.spec.whatwg.org/multipage/#create-a-potential-cors-request
+ .mode(match cors_setting_for_element(self.upcast::<Element>()) {
+ Some(_) => RequestMode::CorsMode,
+ None => RequestMode::NoCors,
+ })
.use_url_credentials(true)
.origin(document.origin().immutable().clone())
.pipeline_id(Some(self.global().pipeline_id()))
@@ -1614,6 +1621,15 @@ impl HTMLMediaElementMethods for HTMLMediaElement {
// https://html.spec.whatwg.org/multipage/#dom-media-src
make_url_setter!(SetSrc, "src");
+ // https://html.spec.whatwg.org/multipage/#dom-media-crossOrigin
+ fn GetCrossOrigin(&self) -> Option<DOMString> {
+ reflect_cross_origin_attribute(self.upcast::<Element>())
+ }
+ // https://html.spec.whatwg.org/multipage/#dom-media-crossOrigin
+ fn SetCrossOrigin(&self, value: Option<DOMString>) {
+ set_cross_origin_attribute(self.upcast::<Element>(), value);
+ }
+
// https://html.spec.whatwg.org/multipage/#dom-media-muted
fn Muted(&self) -> bool {
self.muted.get()