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 -->
This commit is contained in:
bors-servo 2019-04-06 03:33:08 -04:00 committed by GitHub
commit be1e0690eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 98 additions and 51 deletions

View file

@ -89,8 +89,9 @@ impl XRSessionMethods for XRSession {
}
/// https://immersive-web.github.io/webxr/#dom-xrsession-requestanimationframe
#[allow(unsafe_code)]
fn UpdateRenderState(&self, init: &XRRenderStateInit) -> Rc<Promise> {
let p = Promise::new(&self.global());
let p = unsafe { Promise::new_in_current_compartment(&self.global()) };
self.display.queue_renderstate(init, p.clone());
p
}
@ -111,8 +112,9 @@ impl XRSessionMethods for XRSession {
}
/// https://immersive-web.github.io/webxr/#dom-xrsession-requestreferencespace
#[allow(unsafe_code)]
fn RequestReferenceSpace(&self, options: &XRReferenceSpaceOptions) -> Rc<Promise> {
let p = Promise::new(&self.global());
let p = unsafe { Promise::new_in_current_compartment(&self.global()) };
// https://immersive-web.github.io/webxr/#create-a-reference-space