diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2019-04-06 03:33:08 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-06 03:33:08 -0400 |
commit | be1e0690eb890ef785cee76e3a180f9265d820b8 (patch) | |
tree | 3448838c31cd6873b3a2383a1586e0c205aa9743 /components/script/dom/rtcpeerconnection.rs | |
parent | 967efc7fbc0fdfe55eeb9c1f6ac9f3df933f72d9 (diff) | |
parent | 60ba3d25730815817abe60f5fdbed1fa4ff2a553 (diff) | |
download | servo-be1e0690eb890ef785cee76e3a180f9265d820b8.tar.gz servo-be1e0690eb890ef785cee76e3a180f9265d820b8.zip |
Auto merge of #23158 - BartGitHub:promise-constructor, r=jdm
Promise constructor
In this PR, measures are taken that prevent the ```Promise::new``` constructor from being used outside a compartment.
---
<!-- 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 #22982 (GitHub issue number if applicable)
<!-- Either: -->
- [x] These changes do not require tests because no new functionality is added.
<!-- 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/23158)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/rtcpeerconnection.rs')
-rw-r--r-- | components/script/dom/rtcpeerconnection.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/components/script/dom/rtcpeerconnection.rs b/components/script/dom/rtcpeerconnection.rs index e4948e08d8e..a0a1cfbb6e9 100644 --- a/components/script/dom/rtcpeerconnection.rs +++ b/components/script/dom/rtcpeerconnection.rs @@ -429,8 +429,9 @@ impl RTCPeerConnectionMethods for RTCPeerConnection { ); /// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-addicecandidate + #[allow(unsafe_code)] fn AddIceCandidate(&self, candidate: &RTCIceCandidateInit) -> Rc<Promise> { - let p = Promise::new(&self.global()); + let p = unsafe { Promise::new_in_current_compartment(&self.global()) }; if candidate.sdpMid.is_none() && candidate.sdpMLineIndex.is_none() { p.reject_error(Error::Type(format!( "one of sdpMid and sdpMLineIndex must be set" @@ -464,8 +465,9 @@ impl RTCPeerConnectionMethods for RTCPeerConnection { } /// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-createoffer + #[allow(unsafe_code)] fn CreateOffer(&self, _options: &RTCOfferOptions) -> Rc<Promise> { - let p = Promise::new(&self.global()); + let p = unsafe { Promise::new_in_current_compartment(&self.global()) }; if self.closed.get() { p.reject_error(Error::InvalidState); return p; @@ -476,8 +478,9 @@ impl RTCPeerConnectionMethods for RTCPeerConnection { } /// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-createoffer + #[allow(unsafe_code)] fn CreateAnswer(&self, _options: &RTCAnswerOptions) -> Rc<Promise> { - let p = Promise::new(&self.global()); + let p = unsafe { Promise::new_in_current_compartment(&self.global()) }; if self.closed.get() { p.reject_error(Error::InvalidState); return p; @@ -498,9 +501,10 @@ impl RTCPeerConnectionMethods for RTCPeerConnection { } /// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-setlocaldescription + #[allow(unsafe_code)] fn SetLocalDescription(&self, desc: &RTCSessionDescriptionInit) -> Rc<Promise> { // XXXManishearth validate the current state - let p = Promise::new(&self.global()); + let p = unsafe { Promise::new_in_current_compartment(&self.global()) }; let this = Trusted::new(self); let desc: SessionDescription = desc.into(); let trusted_promise = TrustedPromise::new(p.clone()); @@ -531,9 +535,10 @@ impl RTCPeerConnectionMethods for RTCPeerConnection { } /// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-setremotedescription + #[allow(unsafe_code)] fn SetRemoteDescription(&self, desc: &RTCSessionDescriptionInit) -> Rc<Promise> { // XXXManishearth validate the current state - let p = Promise::new(&self.global()); + let p = unsafe { Promise::new_in_current_compartment(&self.global()) }; let this = Trusted::new(self); let desc: SessionDescription = desc.into(); let trusted_promise = TrustedPromise::new(p.clone()); |