aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/audiocontext.rs18
-rw-r--r--components/script/dom/baseaudiocontext.rs17
-rw-r--r--components/script/dom/bindings/codegen/Bindings.conf85
-rw-r--r--components/script/dom/bluetooth.rs16
-rw-r--r--components/script/dom/bluetoothdevice.rs10
-rw-r--r--components/script/dom/bluetoothremotegattcharacteristic.rs34
-rw-r--r--components/script/dom/bluetoothremotegattdescriptor.rs18
-rw-r--r--components/script/dom/bluetoothremotegattserver.rs10
-rw-r--r--components/script/dom/customelementregistry.rs22
-rw-r--r--components/script/dom/htmlmediaelement.rs10
-rw-r--r--components/script/dom/mediadevices.rs14
-rw-r--r--components/script/dom/navigationpreloadmanager.rs34
-rw-r--r--components/script/dom/navigator.rs10
-rw-r--r--components/script/dom/offlineaudiocontext.rs10
-rw-r--r--components/script/dom/rtcpeerconnection.rs50
-rw-r--r--components/script/dom/serviceworkercontainer.rs15
-rw-r--r--components/script/dom/testbinding.rs14
-rw-r--r--components/script/dom/testworklet.rs11
-rw-r--r--components/script/dom/vrdisplay.rs18
-rw-r--r--components/script/dom/worklet.rs15
-rw-r--r--components/script/dom/xr.rs22
-rw-r--r--components/script/dom/xrsession.rs22
22 files changed, 216 insertions, 259 deletions
diff --git a/components/script/dom/audiocontext.rs b/components/script/dom/audiocontext.rs
index 3147f9bfb0a..dca6e62de31 100644
--- a/components/script/dom/audiocontext.rs
+++ b/components/script/dom/audiocontext.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-use crate::compartments::{AlreadyInCompartment, InCompartment};
+use crate::compartments::InCompartment;
use crate::dom::baseaudiocontext::{BaseAudioContext, BaseAudioContextOptions};
use crate::dom::bindings::codegen::Bindings::AudioContextBinding;
use crate::dom::bindings::codegen::Bindings::AudioContextBinding::{
@@ -108,13 +108,9 @@ impl AudioContextMethods for AudioContext {
}
// https://webaudio.github.io/web-audio-api/#dom-audiocontext-suspend
- fn Suspend(&self) -> Rc<Promise> {
+ fn Suspend(&self, comp: InCompartment) -> Rc<Promise> {
// Step 1.
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let promise = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ let promise = Promise::new_in_current_compartment(&self.global(), comp);
// Step 2.
if self.context.control_thread_state() == ProcessingState::Closed {
@@ -173,13 +169,9 @@ impl AudioContextMethods for AudioContext {
}
// https://webaudio.github.io/web-audio-api/#dom-audiocontext-close
- fn Close(&self) -> Rc<Promise> {
+ fn Close(&self, comp: InCompartment) -> Rc<Promise> {
// Step 1.
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let promise = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ let promise = Promise::new_in_current_compartment(&self.global(), comp);
// Step 2.
if self.context.control_thread_state() == ProcessingState::Closed {
diff --git a/components/script/dom/baseaudiocontext.rs b/components/script/dom/baseaudiocontext.rs
index 28096a9c287..29af7839382 100644
--- a/components/script/dom/baseaudiocontext.rs
+++ b/components/script/dom/baseaudiocontext.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-use crate::compartments::{AlreadyInCompartment, InCompartment};
+use crate::compartments::InCompartment;
use crate::dom::analysernode::AnalyserNode;
use crate::dom::audiobuffer::AudioBuffer;
use crate::dom::audiobuffersourcenode::AudioBufferSourceNode;
@@ -274,13 +274,9 @@ impl BaseAudioContextMethods for BaseAudioContext {
}
/// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-resume
- fn Resume(&self) -> Rc<Promise> {
+ fn Resume(&self, comp: InCompartment) -> Rc<Promise> {
// Step 1.
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let promise = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ let promise = Promise::new_in_current_compartment(&self.global(), comp);
// Step 2.
if self.audio_context_impl.state() == ProcessingState::Closed {
@@ -424,13 +420,10 @@ impl BaseAudioContextMethods for BaseAudioContext {
audio_data: CustomAutoRooterGuard<ArrayBuffer>,
decode_success_callback: Option<Rc<DecodeSuccessCallback>>,
decode_error_callback: Option<Rc<DecodeErrorCallback>>,
+ comp: InCompartment,
) -> Rc<Promise> {
// Step 1.
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let promise = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ let promise = Promise::new_in_current_compartment(&self.global(), comp);
let global = self.global();
let window = global.as_window();
diff --git a/components/script/dom/bindings/codegen/Bindings.conf b/components/script/dom/bindings/codegen/Bindings.conf
index c8eba92d7b0..e3de60005bc 100644
--- a/components/script/dom/bindings/codegen/Bindings.conf
+++ b/components/script/dom/bindings/codegen/Bindings.conf
@@ -31,7 +31,9 @@ DOMInterfaces = {
},
#FIXME(jdm): This should be 'register': False, but then we don't generate enum types
-'TestBinding': {},
+'TestBinding': {
+ 'inCompartments': ['PromiseAttribute', 'PromiseNativeHandler'],
+},
'URL': {
'weakReferenceable': True,
@@ -50,8 +52,85 @@ DOMInterfaces = {
'inCompartments': ['Fetch'],
},
-'TestBinding': {
- 'inCompartments': ['PromiseAttribute'],
+'CustomElementRegistry': {
+ 'inCompartments': ['WhenDefined'],
+},
+
+'AudioContext': {
+ 'inCompartments': ['Suspend', 'Close'],
+},
+
+'NavigationPreloadManager': {
+ 'inCompartments': ['Enable', 'Disable', 'SetHeaderValue', 'GetState'],
+},
+
+'HTMLMediaElement': {
+ 'inCompartments': ['Play'],
+},
+
+'BluetoothRemoteGATTDescriptor': {
+ 'inCompartments': ['ReadValue', 'WriteValue'],
+},
+
+'OfflineAudioContext': {
+ 'inCompartments': ['StartRendering'],
+},
+
+'BluetoothRemoteGATTServer': {
+ 'inCompartments': ['Connect'],
+},
+
+'ServiceWorkerContainer': {
+ 'inCompartments': ['Register'],
+},
+
+'Navigator': {
+ 'inCompartments': ['GetVRDisplays'],
+},
+
+'MediaDevices': {
+ 'inCompartments': ['GetUserMedia'],
},
+'XRSession': {
+ 'inCompartments': ['UpdateRenderState', 'RequestReferenceSpace'],
+},
+
+'Bluetooth': {
+ 'inCompartments': ['RequestDevice', 'GetAvailability'],
+},
+
+'BaseAudioContext': {
+ 'inCompartments': ['Resume', 'DecodeAudioData'],
+},
+
+'RTCPeerConnection': {
+ 'inCompartments': ['AddIceCandidate', 'CreateOffer', 'CreateAnswer', 'SetLocalDescription', 'SetRemoteDescription'],
+},
+
+'BluetoothRemoteGATTCharacteristic': {
+ 'inCompartments': ['ReadValue', 'WriteValue', 'StartNotifications', 'StopNotifications'],
+},
+
+'VRDisplay': {
+ 'inCompartments': ['RequestPresent', 'ExitPresent'],
+},
+
+'Worklet': {
+ 'inCompartments': ['AddModule'],
+},
+
+'TestWorklet': {
+ 'inCompartments': ['AddModule'],
+},
+
+'BluetoothDevice': {
+ 'inCompartments': ['WatchAdvertisements'],
+},
+
+'XR': {
+ 'inCompartments': ['SupportsSessionMode', 'RequestSession'],
+}
+
+
}
diff --git a/components/script/dom/bluetooth.rs b/components/script/dom/bluetooth.rs
index ae7e387a9c3..7484e476416 100644
--- a/components/script/dom/bluetooth.rs
+++ b/components/script/dom/bluetooth.rs
@@ -535,12 +535,8 @@ impl From<BluetoothError> for Error {
impl BluetoothMethods for Bluetooth {
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-requestdevice
- fn RequestDevice(&self, option: &RequestDeviceOptions) -> Rc<Promise> {
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let p = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ fn RequestDevice(&self, option: &RequestDeviceOptions, comp: InCompartment) -> Rc<Promise> {
+ let p = Promise::new_in_current_compartment(&self.global(), comp);
// Step 1.
if (option.filters.is_some() && option.acceptAllDevices) ||
(option.filters.is_none() && !option.acceptAllDevices)
@@ -557,12 +553,8 @@ impl BluetoothMethods for Bluetooth {
}
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-getavailability
- fn GetAvailability(&self) -> Rc<Promise> {
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let p = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ fn GetAvailability(&self, comp: InCompartment) -> Rc<Promise> {
+ let p = Promise::new_in_current_compartment(&self.global(), comp);
// Step 1. We did not override the method
// Step 2 - 3. in handle_response
let sender = response_async(&p, self);
diff --git a/components/script/dom/bluetoothdevice.rs b/components/script/dom/bluetoothdevice.rs
index 8ca7643737c..09da75426c1 100644
--- a/components/script/dom/bluetoothdevice.rs
+++ b/components/script/dom/bluetoothdevice.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-use crate::compartments::{AlreadyInCompartment, InCompartment};
+use crate::compartments::InCompartment;
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::BluetoothDeviceBinding;
use crate::dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods;
@@ -278,12 +278,8 @@ impl BluetoothDeviceMethods for BluetoothDevice {
}
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-watchadvertisements
- fn WatchAdvertisements(&self) -> Rc<Promise> {
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let p = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ fn WatchAdvertisements(&self, comp: InCompartment) -> Rc<Promise> {
+ let p = Promise::new_in_current_compartment(&self.global(), comp);
let sender = response_async(&p, self);
// TODO: Step 1.
// Note: Steps 2 - 3 are implemented in components/bluetooth/lib.rs in watch_advertisements function
diff --git a/components/script/dom/bluetoothremotegattcharacteristic.rs b/components/script/dom/bluetoothremotegattcharacteristic.rs
index 440e0523492..cdbec2d92bd 100644
--- a/components/script/dom/bluetoothremotegattcharacteristic.rs
+++ b/components/script/dom/bluetoothremotegattcharacteristic.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-use crate::compartments::{AlreadyInCompartment, InCompartment};
+use crate::compartments::InCompartment;
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding::BluetoothCharacteristicPropertiesMethods;
use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding;
@@ -135,12 +135,8 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
}
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-readvalue
- fn ReadValue(&self) -> Rc<Promise> {
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let p = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ fn ReadValue(&self, comp: InCompartment) -> Rc<Promise> {
+ let p = Promise::new_in_current_compartment(&self.global(), comp);
// Step 1.
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Reads) {
@@ -172,12 +168,8 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
}
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-writevalue
- fn WriteValue(&self, value: ArrayBufferViewOrArrayBuffer) -> Rc<Promise> {
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let p = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ fn WriteValue(&self, value: ArrayBufferViewOrArrayBuffer, comp: InCompartment) -> Rc<Promise> {
+ let p = Promise::new_in_current_compartment(&self.global(), comp);
// Step 1.
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Writes) {
@@ -227,12 +219,8 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
}
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-startnotifications
- fn StartNotifications(&self) -> Rc<Promise> {
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let p = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ fn StartNotifications(&self, comp: InCompartment) -> Rc<Promise> {
+ let p = Promise::new_in_current_compartment(&self.global(), comp);
// Step 1.
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Reads) {
@@ -268,12 +256,8 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
}
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-stopnotifications
- fn StopNotifications(&self) -> Rc<Promise> {
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let p = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ fn StopNotifications(&self, comp: InCompartment) -> Rc<Promise> {
+ let p = Promise::new_in_current_compartment(&self.global(), comp);
let sender = response_async(&p, self);
// TODO: Step 3 - 4: Implement `active notification context set` for BluetoothRemoteGATTCharacteristic,
diff --git a/components/script/dom/bluetoothremotegattdescriptor.rs b/components/script/dom/bluetoothremotegattdescriptor.rs
index b4483db0410..4538f61fe4c 100644
--- a/components/script/dom/bluetoothremotegattdescriptor.rs
+++ b/components/script/dom/bluetoothremotegattdescriptor.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-use crate::compartments::{AlreadyInCompartment, InCompartment};
+use crate::compartments::InCompartment;
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding::BluetoothRemoteGATTCharacteristicMethods;
use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTDescriptorBinding;
@@ -94,12 +94,8 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
}
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-readvalue
- fn ReadValue(&self) -> Rc<Promise> {
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let p = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ fn ReadValue(&self, comp: InCompartment) -> Rc<Promise> {
+ let p = Promise::new_in_current_compartment(&self.global(), comp);
// Step 1.
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Reads) {
@@ -130,12 +126,8 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
}
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-writevalue
- fn WriteValue(&self, value: ArrayBufferViewOrArrayBuffer) -> Rc<Promise> {
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let p = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ fn WriteValue(&self, value: ArrayBufferViewOrArrayBuffer, comp: InCompartment) -> Rc<Promise> {
+ let p = Promise::new_in_current_compartment(&self.global(), comp);
// Step 1.
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Writes) {
diff --git a/components/script/dom/bluetoothremotegattserver.rs b/components/script/dom/bluetoothremotegattserver.rs
index 19f1ba154ca..52fc0bbf44d 100644
--- a/components/script/dom/bluetoothremotegattserver.rs
+++ b/components/script/dom/bluetoothremotegattserver.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-use crate::compartments::{AlreadyInCompartment, InCompartment};
+use crate::compartments::InCompartment;
use crate::dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods;
use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding;
use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods;
@@ -71,13 +71,9 @@ impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer {
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-connect
#[allow(unsafe_code)]
- fn Connect(&self) -> Rc<Promise> {
+ fn Connect(&self, comp: InCompartment) -> Rc<Promise> {
// Step 1.
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let p = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ let p = Promise::new_in_current_compartment(&self.global(), comp);
let sender = response_async(&p, self);
// TODO: Step 3: Check if the UA is currently using the Bluetooth system.
diff --git a/components/script/dom/customelementregistry.rs b/components/script/dom/customelementregistry.rs
index 32cbe140b2c..20ce633be5a 100644
--- a/components/script/dom/customelementregistry.rs
+++ b/components/script/dom/customelementregistry.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-use crate::compartments::{AlreadyInCompartment, InCompartment};
+use crate::compartments::InCompartment;
use crate::dom::bindings::callback::{CallbackContainer, ExceptionHandling};
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::CustomElementRegistryBinding;
@@ -415,28 +415,20 @@ impl CustomElementRegistryMethods for CustomElementRegistry {
}
/// <https://html.spec.whatwg.org/multipage/#dom-customelementregistry-whendefined>
- fn WhenDefined(&self, name: DOMString) -> Rc<Promise> {
+ fn WhenDefined(&self, name: DOMString, comp: InCompartment) -> Rc<Promise> {
let global_scope = self.window.upcast::<GlobalScope>();
let name = LocalName::from(&*name);
// Step 1
if !is_valid_custom_element_name(&name) {
- let in_compartment_proof = AlreadyInCompartment::assert(&global_scope);
- let promise = Promise::new_in_current_compartment(
- &global_scope,
- InCompartment::Already(&in_compartment_proof),
- );
+ let promise = Promise::new_in_current_compartment(&global_scope, comp);
promise.reject_native(&DOMException::new(&global_scope, DOMErrorName::SyntaxError));
return promise;
}
// Step 2
if self.definitions.borrow().contains_key(&name) {
- let in_compartment_proof = AlreadyInCompartment::assert(&global_scope);
- let promise = Promise::new_in_current_compartment(
- &global_scope,
- InCompartment::Already(&in_compartment_proof),
- );
+ let promise = Promise::new_in_current_compartment(&global_scope, comp);
promise.resolve_native(&UndefinedValue());
return promise;
}
@@ -446,11 +438,7 @@ impl CustomElementRegistryMethods for CustomElementRegistry {
// Steps 4, 5
let promise = map.get(&name).cloned().unwrap_or_else(|| {
- let in_compartment_proof = AlreadyInCompartment::assert(&global_scope);
- let promise = Promise::new_in_current_compartment(
- &global_scope,
- InCompartment::Already(&in_compartment_proof),
- );
+ let promise = Promise::new_in_current_compartment(&global_scope, comp);
map.insert(name, promise.clone());
promise
});
diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs
index c816494fb70..3a183054075 100644
--- a/components/script/dom/htmlmediaelement.rs
+++ b/components/script/dom/htmlmediaelement.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-use crate::compartments::{AlreadyInCompartment, InCompartment};
+use crate::compartments::InCompartment;
use crate::document_loader::{LoadBlocker, LoadType};
use crate::dom::attr::Attr;
use crate::dom::audiotrack::AudioTrack;
@@ -1706,12 +1706,8 @@ impl HTMLMediaElementMethods for HTMLMediaElement {
}
// https://html.spec.whatwg.org/multipage/#dom-media-play
- fn Play(&self) -> Rc<Promise> {
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let promise = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ fn Play(&self, comp: InCompartment) -> Rc<Promise> {
+ let promise = Promise::new_in_current_compartment(&self.global(), comp);
// Step 1.
// FIXME(nox): Reject promise if not allowed to play.
diff --git a/components/script/dom/mediadevices.rs b/components/script/dom/mediadevices.rs
index bcc575a2ef6..0276a3d0c61 100644
--- a/components/script/dom/mediadevices.rs
+++ b/components/script/dom/mediadevices.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-use crate::compartments::{AlreadyInCompartment, InCompartment};
+use crate::compartments::InCompartment;
use crate::dom::bindings::codegen::Bindings::MediaDevicesBinding::MediaStreamConstraints;
use crate::dom::bindings::codegen::Bindings::MediaDevicesBinding::{self, MediaDevicesMethods};
use crate::dom::bindings::codegen::UnionTypes::BooleanOrMediaTrackConstraints;
@@ -46,12 +46,12 @@ impl MediaDevices {
impl MediaDevicesMethods for MediaDevices {
/// https://w3c.github.io/mediacapture-main/#dom-mediadevices-getusermedia
#[allow(unsafe_code)]
- fn GetUserMedia(&self, constraints: &MediaStreamConstraints) -> Rc<Promise> {
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let p = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ fn GetUserMedia(
+ &self,
+ constraints: &MediaStreamConstraints,
+ comp: InCompartment,
+ ) -> Rc<Promise> {
+ let p = Promise::new_in_current_compartment(&self.global(), comp);
let media = ServoMedia::get().unwrap();
let stream = MediaStream::new(&self.global());
if let Some(constraints) = convert_constraints(&constraints.audio) {
diff --git a/components/script/dom/navigationpreloadmanager.rs b/components/script/dom/navigationpreloadmanager.rs
index e0d1d6e6c59..94a9f0056c6 100644
--- a/components/script/dom/navigationpreloadmanager.rs
+++ b/components/script/dom/navigationpreloadmanager.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-use crate::compartments::{AlreadyInCompartment, InCompartment};
+use crate::compartments::InCompartment;
use crate::dom::bindings::codegen::Bindings::NavigationPreloadManagerBinding::NavigationPreloadState;
use crate::dom::bindings::codegen::Bindings::NavigationPreloadManagerBinding::{
NavigationPreloadManagerMethods, Wrap,
@@ -44,12 +44,8 @@ impl NavigationPreloadManager {
impl NavigationPreloadManagerMethods for NavigationPreloadManager {
// https://w3c.github.io/ServiceWorker/#navigation-preload-manager-enable
- fn Enable(&self) -> Rc<Promise> {
- let in_compartment_proof = AlreadyInCompartment::assert(&*self.global());
- let promise = Promise::new_in_current_compartment(
- &*self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ fn Enable(&self, comp: InCompartment) -> Rc<Promise> {
+ let promise = Promise::new_in_current_compartment(&*self.global(), comp);
// 2.
if self.serviceworker_registration.active().is_none() {
@@ -70,12 +66,8 @@ impl NavigationPreloadManagerMethods for NavigationPreloadManager {
}
// https://w3c.github.io/ServiceWorker/#navigation-preload-manager-disable
- fn Disable(&self) -> Rc<Promise> {
- let in_compartment_proof = AlreadyInCompartment::assert(&*self.global());
- let promise = Promise::new_in_current_compartment(
- &*self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ fn Disable(&self, comp: InCompartment) -> Rc<Promise> {
+ let promise = Promise::new_in_current_compartment(&*self.global(), comp);
// 2.
if self.serviceworker_registration.active().is_none() {
@@ -96,12 +88,8 @@ impl NavigationPreloadManagerMethods for NavigationPreloadManager {
}
// https://w3c.github.io/ServiceWorker/#navigation-preload-manager-setheadervalue
- fn SetHeaderValue(&self, value: ByteString) -> Rc<Promise> {
- let in_compartment_proof = AlreadyInCompartment::assert(&*self.global());
- let promise = Promise::new_in_current_compartment(
- &*self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ fn SetHeaderValue(&self, value: ByteString, comp: InCompartment) -> Rc<Promise> {
+ let promise = Promise::new_in_current_compartment(&*self.global(), comp);
// 2.
if self.serviceworker_registration.active().is_none() {
@@ -122,12 +110,8 @@ impl NavigationPreloadManagerMethods for NavigationPreloadManager {
}
// https://w3c.github.io/ServiceWorker/#navigation-preload-manager-getstate
- fn GetState(&self) -> Rc<Promise> {
- let in_compartment_proof = AlreadyInCompartment::assert(&*self.global());
- let promise = Promise::new_in_current_compartment(
- &*self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ fn GetState(&self, comp: InCompartment) -> Rc<Promise> {
+ let promise = Promise::new_in_current_compartment(&*self.global(), comp);
// 2.
let mut state = NavigationPreloadState::empty();
diff --git a/components/script/dom/navigator.rs b/components/script/dom/navigator.rs
index 9d1a0de8e2e..d4666ba2aa6 100644
--- a/components/script/dom/navigator.rs
+++ b/components/script/dom/navigator.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-use crate::compartments::{AlreadyInCompartment, InCompartment};
+use crate::compartments::InCompartment;
use crate::dom::bindings::codegen::Bindings::NavigatorBinding;
use crate::dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods;
use crate::dom::bindings::error::Error;
@@ -151,12 +151,8 @@ impl NavigatorMethods for Navigator {
}
// https://w3c.github.io/webvr/spec/1.1/#navigator-getvrdisplays-attribute
- fn GetVRDisplays(&self) -> Rc<Promise> {
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let promise = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ fn GetVRDisplays(&self, comp: InCompartment) -> Rc<Promise> {
+ let promise = Promise::new_in_current_compartment(&self.global(), comp);
let displays = self.Xr().get_displays();
match displays {
Ok(displays) => promise.resolve_native(&displays),
diff --git a/components/script/dom/offlineaudiocontext.rs b/components/script/dom/offlineaudiocontext.rs
index a4d6c54c9ca..db7985a84f1 100644
--- a/components/script/dom/offlineaudiocontext.rs
+++ b/components/script/dom/offlineaudiocontext.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-use crate::compartments::{AlreadyInCompartment, InCompartment};
+use crate::compartments::InCompartment;
use crate::dom::audiobuffer::{AudioBuffer, MAX_SAMPLE_RATE, MIN_SAMPLE_RATE};
use crate::dom::audionode::MAX_CHANNEL_COUNT;
use crate::dom::baseaudiocontext::{BaseAudioContext, BaseAudioContextOptions};
@@ -114,12 +114,8 @@ impl OfflineAudioContextMethods for OfflineAudioContext {
}
// https://webaudio.github.io/web-audio-api/#dom-offlineaudiocontext-startrendering
- fn StartRendering(&self) -> Rc<Promise> {
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let promise = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ fn StartRendering(&self, comp: InCompartment) -> Rc<Promise> {
+ let promise = Promise::new_in_current_compartment(&self.global(), comp);
if self.rendering_started.get() {
promise.reject_error(Error::InvalidState);
return promise;
diff --git a/components/script/dom/rtcpeerconnection.rs b/components/script/dom/rtcpeerconnection.rs
index 9ec1940bbb3..2997698e309 100644
--- a/components/script/dom/rtcpeerconnection.rs
+++ b/components/script/dom/rtcpeerconnection.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-use crate::compartments::{AlreadyInCompartment, InCompartment};
+use crate::compartments::InCompartment;
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::RTCIceCandidateBinding::RTCIceCandidateInit;
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding;
@@ -453,12 +453,8 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
);
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-addicecandidate
- fn AddIceCandidate(&self, candidate: &RTCIceCandidateInit) -> Rc<Promise> {
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let p = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ fn AddIceCandidate(&self, candidate: &RTCIceCandidateInit, comp: InCompartment) -> Rc<Promise> {
+ let p = Promise::new_in_current_compartment(&self.global(), comp);
if candidate.sdpMid.is_none() && candidate.sdpMLineIndex.is_none() {
p.reject_error(Error::Type(format!(
"one of sdpMid and sdpMLineIndex must be set"
@@ -492,12 +488,8 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
}
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-createoffer
- fn CreateOffer(&self, _options: &RTCOfferOptions) -> Rc<Promise> {
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let p = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ fn CreateOffer(&self, _options: &RTCOfferOptions, comp: InCompartment) -> Rc<Promise> {
+ let p = Promise::new_in_current_compartment(&self.global(), comp);
if self.closed.get() {
p.reject_error(Error::InvalidState);
return p;
@@ -508,12 +500,8 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
}
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-createoffer
- fn CreateAnswer(&self, _options: &RTCAnswerOptions) -> Rc<Promise> {
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let p = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ fn CreateAnswer(&self, _options: &RTCAnswerOptions, comp: InCompartment) -> Rc<Promise> {
+ let p = Promise::new_in_current_compartment(&self.global(), comp);
if self.closed.get() {
p.reject_error(Error::InvalidState);
return p;
@@ -534,13 +522,13 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
}
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-setlocaldescription
- fn SetLocalDescription(&self, desc: &RTCSessionDescriptionInit) -> Rc<Promise> {
+ fn SetLocalDescription(
+ &self,
+ desc: &RTCSessionDescriptionInit,
+ comp: InCompartment,
+ ) -> Rc<Promise> {
// XXXManishearth validate the current state
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let p = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ let p = Promise::new_in_current_compartment(&self.global(), comp);
let this = Trusted::new(self);
let desc: SessionDescription = desc.into();
let trusted_promise = TrustedPromise::new(p.clone());
@@ -571,13 +559,13 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
}
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-setremotedescription
- fn SetRemoteDescription(&self, desc: &RTCSessionDescriptionInit) -> Rc<Promise> {
+ fn SetRemoteDescription(
+ &self,
+ desc: &RTCSessionDescriptionInit,
+ comp: InCompartment,
+ ) -> Rc<Promise> {
// XXXManishearth validate the current state
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let p = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ let p = Promise::new_in_current_compartment(&self.global(), comp);
let this = Trusted::new(self);
let desc: SessionDescription = desc.into();
let trusted_promise = TrustedPromise::new(p.clone());
diff --git a/components/script/dom/serviceworkercontainer.rs b/components/script/dom/serviceworkercontainer.rs
index 094278198d4..ed1b79a5c8a 100644
--- a/components/script/dom/serviceworkercontainer.rs
+++ b/components/script/dom/serviceworkercontainer.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-use crate::compartments::{AlreadyInCompartment, InCompartment};
+use crate::compartments::InCompartment;
use crate::dom::bindings::codegen::Bindings::ServiceWorkerContainerBinding::RegistrationOptions;
use crate::dom::bindings::codegen::Bindings::ServiceWorkerContainerBinding::{
ServiceWorkerContainerMethods, Wrap,
@@ -55,13 +55,14 @@ impl ServiceWorkerContainerMethods for ServiceWorkerContainer {
#[allow(unrooted_must_root)] // Job is unrooted
/// https://w3c.github.io/ServiceWorker/#navigator-service-worker-register and - A
/// https://w3c.github.io/ServiceWorker/#start-register-algorithm - B
- fn Register(&self, script_url: USVString, options: &RegistrationOptions) -> Rc<Promise> {
+ fn Register(
+ &self,
+ script_url: USVString,
+ options: &RegistrationOptions,
+ comp: InCompartment,
+ ) -> Rc<Promise> {
// A: Step 1
- let in_compartment_proof = AlreadyInCompartment::assert(&*self.global());
- let promise = Promise::new_in_current_compartment(
- &*self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ let promise = Promise::new_in_current_compartment(&*self.global(), comp);
let USVString(ref script_url) = script_url;
let api_base_url = self.global().api_base_url();
// A: Step 3-5
diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs
index d048c07415c..67622303be8 100644
--- a/components/script/dom/testbinding.rs
+++ b/components/script/dom/testbinding.rs
@@ -4,7 +4,7 @@
// check-tidy: no specs after this line
-use crate::compartments::{AlreadyInCompartment, InCompartment};
+use crate::compartments::InCompartment;
use crate::dom::bindings::callback::ExceptionHandling;
use crate::dom::bindings::codegen::Bindings::EventListenerBinding::EventListener;
use crate::dom::bindings::codegen::Bindings::FunctionBinding::Function;
@@ -1014,6 +1014,7 @@ impl TestBindingMethods for TestBinding {
&self,
resolve: Option<Rc<SimpleCallback>>,
reject: Option<Rc<SimpleCallback>>,
+ comp: InCompartment,
) -> Rc<Promise> {
let global = self.global();
let handler = PromiseNativeHandler::new(
@@ -1021,11 +1022,7 @@ impl TestBindingMethods for TestBinding {
resolve.map(SimpleHandler::new),
reject.map(SimpleHandler::new),
);
- let in_compartment_proof = AlreadyInCompartment::assert(&global);
- let p = Promise::new_in_current_compartment(
- &global,
- InCompartment::Already(&in_compartment_proof),
- );
+ let p = Promise::new_in_current_compartment(&global, comp);
p.append_native_handler(&handler);
return p;
@@ -1049,10 +1046,7 @@ impl TestBindingMethods for TestBinding {
}
fn PromiseAttribute(&self, comp: InCompartment) -> Rc<Promise> {
- Promise::new_in_current_compartment(
- &self.global(),
- comp
- )
+ Promise::new_in_current_compartment(&self.global(), comp)
}
fn AcceptPromise(&self, _promise: &Promise) {}
diff --git a/components/script/dom/testworklet.rs b/components/script/dom/testworklet.rs
index 849ee8272ff..c3d214a306b 100644
--- a/components/script/dom/testworklet.rs
+++ b/components/script/dom/testworklet.rs
@@ -3,7 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// check-tidy: no specs after this line
-
+use crate::compartments::InCompartment;
use crate::dom::bindings::codegen::Bindings::TestWorkletBinding::TestWorkletMethods;
use crate::dom::bindings::codegen::Bindings::TestWorkletBinding::Wrap;
use crate::dom::bindings::codegen::Bindings::WorkletBinding::WorkletBinding::WorkletMethods;
@@ -51,8 +51,13 @@ impl TestWorklet {
}
impl TestWorkletMethods for TestWorklet {
- fn AddModule(&self, moduleURL: USVString, options: &WorkletOptions) -> Rc<Promise> {
- self.worklet.AddModule(moduleURL, options)
+ fn AddModule(
+ &self,
+ moduleURL: USVString,
+ options: &WorkletOptions,
+ comp: InCompartment,
+ ) -> Rc<Promise> {
+ self.worklet.AddModule(moduleURL, options, comp)
}
fn Lookup(&self, key: DOMString) -> Option<DOMString> {
diff --git a/components/script/dom/vrdisplay.rs b/components/script/dom/vrdisplay.rs
index 77817bae2fc..0fd9cfee560 100644
--- a/components/script/dom/vrdisplay.rs
+++ b/components/script/dom/vrdisplay.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-use crate::compartments::{AlreadyInCompartment, InCompartment};
+use crate::compartments::InCompartment;
use crate::dom::bindings::callback::ExceptionHandling;
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods;
@@ -352,12 +352,8 @@ impl VRDisplayMethods for VRDisplay {
}
// https://w3c.github.io/webvr/#dom-vrdisplay-requestpresent
- fn RequestPresent(&self, layers: Vec<VRLayer>) -> Rc<Promise> {
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let promise = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ fn RequestPresent(&self, layers: Vec<VRLayer>, comp: InCompartment) -> Rc<Promise> {
+ let promise = Promise::new_in_current_compartment(&self.global(), comp);
// TODO: WebVR spec: this method must be called in response to a user gesture
// WebVR spec: If canPresent is false the promise MUST be rejected
@@ -420,12 +416,8 @@ impl VRDisplayMethods for VRDisplay {
}
// https://w3c.github.io/webvr/#dom-vrdisplay-exitpresent
- fn ExitPresent(&self) -> Rc<Promise> {
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let promise = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ fn ExitPresent(&self, comp: InCompartment) -> Rc<Promise> {
+ let promise = Promise::new_in_current_compartment(&self.global(), comp);
// WebVR spec: If the VRDisplay is not presenting the promise MUST be rejected.
if !self.presenting.get() {
diff --git a/components/script/dom/worklet.rs b/components/script/dom/worklet.rs
index 569af7fd184..398710ee558 100644
--- a/components/script/dom/worklet.rs
+++ b/components/script/dom/worklet.rs
@@ -10,7 +10,7 @@
//! thread pool implementation, which only performs GC or code loading on
//! a backup thread, not on the primary worklet thread.
-use crate::compartments::{AlreadyInCompartment, InCompartment};
+use crate::compartments::InCompartment;
use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestCredentials;
use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
use crate::dom::bindings::codegen::Bindings::WorkletBinding::WorkletMethods;
@@ -111,14 +111,15 @@ impl Worklet {
impl WorkletMethods for Worklet {
/// <https://drafts.css-houdini.org/worklets/#dom-worklet-addmodule>
- fn AddModule(&self, module_url: USVString, options: &WorkletOptions) -> Rc<Promise> {
+ fn AddModule(
+ &self,
+ module_url: USVString,
+ options: &WorkletOptions,
+ comp: InCompartment,
+ ) -> Rc<Promise> {
// Step 1.
let global = self.window.upcast();
- let in_compartment_proof = AlreadyInCompartment::assert(&global);
- let promise = Promise::new_in_current_compartment(
- &global,
- InCompartment::Already(&in_compartment_proof),
- );
+ let promise = Promise::new_in_current_compartment(&global, comp);
// Step 3.
let module_url_record = match self.window.Document().base_url().join(&module_url.0) {
diff --git a/components/script/dom/xr.rs b/components/script/dom/xr.rs
index 3ff67b0042c..61f65a97901 100644
--- a/components/script/dom/xr.rs
+++ b/components/script/dom/xr.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-use crate::compartments::{AlreadyInCompartment, InCompartment};
+use crate::compartments::InCompartment;
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::VRDisplayBinding::VRDisplayMethods;
use crate::dom::bindings::codegen::Bindings::XRBinding;
@@ -84,13 +84,9 @@ impl Drop for XR {
impl XRMethods for XR {
/// https://immersive-web.github.io/webxr/#dom-xr-supportssessionmode
- fn SupportsSessionMode(&self, mode: XRSessionMode) -> Rc<Promise> {
+ fn SupportsSessionMode(&self, mode: XRSessionMode, comp: InCompartment) -> Rc<Promise> {
// XXXManishearth this should select an XR device first
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let promise = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ let promise = Promise::new_in_current_compartment(&self.global(), comp);
if mode == XRSessionMode::Immersive_vr {
promise.resolve_native(&());
} else {
@@ -102,12 +98,12 @@ impl XRMethods for XR {
}
/// https://immersive-web.github.io/webxr/#dom-xr-requestsession
- fn RequestSession(&self, options: &XRSessionCreationOptions) -> Rc<Promise> {
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let promise = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ fn RequestSession(
+ &self,
+ options: &XRSessionCreationOptions,
+ comp: InCompartment,
+ ) -> Rc<Promise> {
+ let promise = Promise::new_in_current_compartment(&self.global(), comp);
if options.mode != XRSessionMode::Immersive_vr {
promise.reject_error(Error::NotSupported);
return promise;
diff --git a/components/script/dom/xrsession.rs b/components/script/dom/xrsession.rs
index 5aab6341ca4..080cb50c073 100644
--- a/components/script/dom/xrsession.rs
+++ b/components/script/dom/xrsession.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-use crate::compartments::{AlreadyInCompartment, InCompartment};
+use crate::compartments::InCompartment;
use crate::dom::bindings::codegen::Bindings::VRDisplayBinding::VRDisplayMethods;
use crate::dom::bindings::codegen::Bindings::XRBinding::XRSessionMode;
use crate::dom::bindings::codegen::Bindings::XRRenderStateBinding::XRRenderStateInit;
@@ -94,12 +94,8 @@ impl XRSessionMethods for XRSession {
}
/// https://immersive-web.github.io/webxr/#dom-xrsession-requestanimationframe
- fn UpdateRenderState(&self, init: &XRRenderStateInit) -> Rc<Promise> {
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let p = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ fn UpdateRenderState(&self, init: &XRRenderStateInit, comp: InCompartment) -> Rc<Promise> {
+ let p = Promise::new_in_current_compartment(&self.global(), comp);
self.display.queue_renderstate(init, p.clone());
p
}
@@ -120,12 +116,12 @@ impl XRSessionMethods for XRSession {
}
/// https://immersive-web.github.io/webxr/#dom-xrsession-requestreferencespace
- fn RequestReferenceSpace(&self, options: &XRReferenceSpaceOptions) -> Rc<Promise> {
- let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
- let p = Promise::new_in_current_compartment(
- &self.global(),
- InCompartment::Already(&in_compartment_proof),
- );
+ fn RequestReferenceSpace(
+ &self,
+ options: &XRReferenceSpaceOptions,
+ comp: InCompartment,
+ ) -> Rc<Promise> {
+ let p = Promise::new_in_current_compartment(&self.global(), comp);
// https://immersive-web.github.io/webxr/#create-a-reference-space