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/bluetooth.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/bluetooth.rs')
-rw-r--r-- | components/script/dom/bluetooth.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/components/script/dom/bluetooth.rs b/components/script/dom/bluetooth.rs index 4b541d4b60a..c218fbce27a 100644 --- a/components/script/dom/bluetooth.rs +++ b/components/script/dom/bluetooth.rs @@ -278,6 +278,7 @@ pub fn response_async<T: AsyncBluetoothListener + DomObject + 'static>( } // https://webbluetoothcg.github.io/web-bluetooth/#getgattchildren +#[allow(unsafe_code)] pub fn get_gatt_children<T, F>( attribute: &T, single: bool, @@ -291,7 +292,7 @@ where T: AsyncBluetoothListener + DomObject + 'static, F: FnOnce(StringOrUnsignedLong) -> Fallible<UUID>, { - let p = Promise::new(&attribute.global()); + let p = unsafe { Promise::new_in_current_compartment(&attribute.global()) }; let result_uuid = if let Some(u) = uuid { // Step 1. @@ -530,8 +531,9 @@ impl From<BluetoothError> for Error { impl BluetoothMethods for Bluetooth { // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-requestdevice + #[allow(unsafe_code)] fn RequestDevice(&self, option: &RequestDeviceOptions) -> Rc<Promise> { - let p = Promise::new(&self.global()); + let p = unsafe { Promise::new_in_current_compartment(&self.global()) }; // Step 1. if (option.filters.is_some() && option.acceptAllDevices) || (option.filters.is_none() && !option.acceptAllDevices) @@ -548,8 +550,9 @@ impl BluetoothMethods for Bluetooth { } // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-getavailability + #[allow(unsafe_code)] fn GetAvailability(&self) -> Rc<Promise> { - let p = Promise::new(&self.global()); + let p = unsafe { Promise::new_in_current_compartment(&self.global()) }; // Step 1. We did not override the method // Step 2 - 3. in handle_response let sender = response_async(&p, self); |