Skip to content

Commit

Permalink
Auto merge of #23188 - jackxbritton:issue-22287, r=<try>
Browse files Browse the repository at this point in the history
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
- [ ] These changes fix #22287  (GitHub issue number if applicable)

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- 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 -->
  • Loading branch information
bors-servo committed Apr 11, 2019
2 parents dd2deea + 2818ff0 commit 650bfb1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 55 deletions.
26 changes: 24 additions & 2 deletions components/script/dom/htmlmediaelement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,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;
Expand Down Expand Up @@ -64,6 +67,8 @@ use ipc_channel::router::ROUTER;
use mime::{self, Mime};
use net_traits::image::base::Image;
use net_traits::image_cache::ImageResponse;
use net_traits::request::CorsSettings;
use net_traits::request::RequestMode;
use net_traits::request::{CredentialsMode, Destination, RequestInit};
use net_traits::{CoreResourceMsg, FetchChannels, FetchMetadata, FetchResponseListener, Metadata};
use net_traits::{NetworkError, ResourceFetchTiming, ResourceTimingType};
Expand Down Expand Up @@ -694,7 +699,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,
Expand All @@ -710,16 +714,25 @@ impl HTMLMediaElement {
Some(url) => url.clone(),
None => self.blob_url.borrow().as_ref().unwrap().clone(),
};
let element = self.upcast::<Element>();
let cors_setting = cors_setting_for_element(element);
let request = RequestInit {
url: url.clone(),
headers,
destination,
credentials_mode: CredentialsMode::Include,
use_url_credentials: true,
origin: document.origin().immutable().clone(),
pipeline_id: Some(self.global().pipeline_id()),
referrer_url: Some(document.url()),
referrer_policy: document.get_referrer_policy(),
mode: match cors_setting {
Some(_) => RequestMode::CorsMode,
None => RequestMode::NoCors,
},
credentials_mode: match cors_setting {
Some(CorsSettings::Anonymous) => CredentialsMode::CredentialsSameOrigin,
_ => CredentialsMode::Include,
},
..RequestInit::default()
};

Expand Down Expand Up @@ -1558,6 +1571,15 @@ impl HTMLMediaElementMethods for HTMLMediaElement {
// https://html.spec.whatwg.org/multipage/#dom-media-autoplay
make_bool_setter!(SetAutoplay, "autoplay");

// 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-defaultmuted
make_bool_getter!(DefaultMuted, "muted");
// https://html.spec.whatwg.org/multipage/#dom-media-defaultmuted
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/webidls/HTMLMediaElement.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface HTMLMediaElement : HTMLElement {
[CEReactions] attribute USVString src;
attribute MediaProvider? srcObject;
readonly attribute USVString currentSrc;
// [CEReactions] attribute DOMString crossOrigin;
[CEReactions] attribute DOMString? crossOrigin;
const unsigned short NETWORK_EMPTY = 0;
const unsigned short NETWORK_IDLE = 1;
const unsigned short NETWORK_LOADING = 2;
Expand Down
21 changes: 0 additions & 21 deletions tests/wpt/metadata/html/dom/interfaces.https.html.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1016,9 +1016,6 @@
[HTMLMediaElement interface: document.createElement("video") must inherit property "srcObject" with the proper type]
expected: FAIL

[HTMLMediaElement interface: document.createElement("video") must inherit property "crossOrigin" with the proper type]
expected: FAIL

[HTMLMediaElement interface: document.createElement("video") must inherit property "buffered" with the proper type]
expected: FAIL

Expand Down Expand Up @@ -1085,9 +1082,6 @@
[HTMLMediaElement interface: document.createElement("audio") must inherit property "srcObject" with the proper type]
expected: FAIL

[HTMLMediaElement interface: document.createElement("audio") must inherit property "crossOrigin" with the proper type]
expected: FAIL

[HTMLMediaElement interface: document.createElement("audio") must inherit property "buffered" with the proper type]
expected: FAIL

Expand Down Expand Up @@ -1169,9 +1163,6 @@
[HTMLMediaElement interface: new Audio() must inherit property "currentSrc" with the proper type]
expected: FAIL

[HTMLMediaElement interface: new Audio() must inherit property "crossOrigin" with the proper type]
expected: FAIL

[HTMLMediaElement interface: new Audio() must inherit property "NETWORK_EMPTY" with the proper type]
expected: FAIL

Expand Down Expand Up @@ -6768,9 +6759,6 @@
[HTMLMediaElement interface: document.createElement("video") must inherit property "srcObject" with the proper type]
expected: FAIL

[HTMLMediaElement interface: document.createElement("video") must inherit property "crossOrigin" with the proper type]
expected: FAIL

[HTMLMediaElement interface: document.createElement("video") must inherit property "getStartDate()" with the proper type]
expected: FAIL

Expand All @@ -6786,9 +6774,6 @@
[HTMLMediaElement interface: document.createElement("audio") must inherit property "srcObject" with the proper type]
expected: FAIL

[HTMLMediaElement interface: document.createElement("audio") must inherit property "crossOrigin" with the proper type]
expected: FAIL

[HTMLMediaElement interface: document.createElement("audio") must inherit property "getStartDate()" with the proper type]
expected: FAIL

Expand All @@ -6804,9 +6789,6 @@
[HTMLMediaElement interface: new Audio() must inherit property "srcObject" with the proper type]
expected: FAIL

[HTMLMediaElement interface: new Audio() must inherit property "crossOrigin" with the proper type]
expected: FAIL

[HTMLMediaElement interface: new Audio() must inherit property "getStartDate()" with the proper type]
expected: FAIL

Expand All @@ -6819,9 +6801,6 @@
[HTMLMediaElement interface: new Audio() must inherit property "controls" with the proper type]
expected: FAIL

[HTMLMediaElement interface: attribute crossOrigin]
expected: FAIL

[HTMLMediaElement interface: operation getStartDate()]
expected: FAIL

Expand Down

This file was deleted.

0 comments on commit 650bfb1

Please sign in to comment.