mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Auto merge of #23459 - Eijebong:compartments, r=jdm
Add an inCompartments config option for bindings Fixes #23257 <!-- 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/23459) <!-- Reviewable:end -->
This commit is contained in:
commit
03f223663f
28 changed files with 274 additions and 272 deletions
|
@ -3,7 +3,7 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use js::jsapi::{GetCurrentRealmOrNull, JSAutoRealm};
|
use js::jsapi::{GetCurrentRealmOrNull, JSAutoRealm, JSContext};
|
||||||
|
|
||||||
pub struct AlreadyInCompartment(());
|
pub struct AlreadyInCompartment(());
|
||||||
|
|
||||||
|
@ -15,6 +15,13 @@ impl AlreadyInCompartment {
|
||||||
}
|
}
|
||||||
AlreadyInCompartment(())
|
AlreadyInCompartment(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn assert_for_cx(cx: *mut JSContext) -> AlreadyInCompartment {
|
||||||
|
unsafe {
|
||||||
|
assert!(!GetCurrentRealmOrNull(cx).is_null());
|
||||||
|
}
|
||||||
|
AlreadyInCompartment(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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::baseaudiocontext::{BaseAudioContext, BaseAudioContextOptions};
|
||||||
use crate::dom::bindings::codegen::Bindings::AudioContextBinding;
|
use crate::dom::bindings::codegen::Bindings::AudioContextBinding;
|
||||||
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
|
// https://webaudio.github.io/web-audio-api/#dom-audiocontext-suspend
|
||||||
fn Suspend(&self) -> Rc<Promise> {
|
fn Suspend(&self, comp: InCompartment) -> Rc<Promise> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let promise = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
if self.context.control_thread_state() == ProcessingState::Closed {
|
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
|
// https://webaudio.github.io/web-audio-api/#dom-audiocontext-close
|
||||||
fn Close(&self) -> Rc<Promise> {
|
fn Close(&self, comp: InCompartment) -> Rc<Promise> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let promise = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
if self.context.control_thread_state() == ProcessingState::Closed {
|
if self.context.control_thread_state() == ProcessingState::Closed {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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::analysernode::AnalyserNode;
|
||||||
use crate::dom::audiobuffer::AudioBuffer;
|
use crate::dom::audiobuffer::AudioBuffer;
|
||||||
use crate::dom::audiobuffersourcenode::AudioBufferSourceNode;
|
use crate::dom::audiobuffersourcenode::AudioBufferSourceNode;
|
||||||
|
@ -274,13 +274,9 @@ impl BaseAudioContextMethods for BaseAudioContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-resume
|
/// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-resume
|
||||||
fn Resume(&self) -> Rc<Promise> {
|
fn Resume(&self, comp: InCompartment) -> Rc<Promise> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let promise = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
if self.audio_context_impl.state() == ProcessingState::Closed {
|
if self.audio_context_impl.state() == ProcessingState::Closed {
|
||||||
|
@ -424,13 +420,10 @@ impl BaseAudioContextMethods for BaseAudioContext {
|
||||||
audio_data: CustomAutoRooterGuard<ArrayBuffer>,
|
audio_data: CustomAutoRooterGuard<ArrayBuffer>,
|
||||||
decode_success_callback: Option<Rc<DecodeSuccessCallback>>,
|
decode_success_callback: Option<Rc<DecodeSuccessCallback>>,
|
||||||
decode_error_callback: Option<Rc<DecodeErrorCallback>>,
|
decode_error_callback: Option<Rc<DecodeErrorCallback>>,
|
||||||
|
comp: InCompartment,
|
||||||
) -> Rc<Promise> {
|
) -> Rc<Promise> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let promise = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
let global = self.global();
|
let global = self.global();
|
||||||
let window = global.as_window();
|
let window = global.as_window();
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,9 @@ DOMInterfaces = {
|
||||||
},
|
},
|
||||||
|
|
||||||
#FIXME(jdm): This should be 'register': False, but then we don't generate enum types
|
#FIXME(jdm): This should be 'register': False, but then we don't generate enum types
|
||||||
'TestBinding': {},
|
'TestBinding': {
|
||||||
|
'inCompartments': ['PromiseAttribute', 'PromiseNativeHandler'],
|
||||||
|
},
|
||||||
|
|
||||||
'URL': {
|
'URL': {
|
||||||
'weakReferenceable': True,
|
'weakReferenceable': True,
|
||||||
|
@ -40,6 +42,95 @@ DOMInterfaces = {
|
||||||
'WindowProxy' : {
|
'WindowProxy' : {
|
||||||
'path': 'crate::dom::windowproxy::WindowProxy',
|
'path': 'crate::dom::windowproxy::WindowProxy',
|
||||||
'register': False,
|
'register': False,
|
||||||
|
},
|
||||||
|
|
||||||
|
'Window': {
|
||||||
|
'inCompartments': ['Fetch'],
|
||||||
|
},
|
||||||
|
|
||||||
|
'WorkerGlobalScope': {
|
||||||
|
'inCompartments': ['Fetch'],
|
||||||
|
},
|
||||||
|
|
||||||
|
'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'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3316,6 +3316,8 @@ class CGCallGenerator(CGThing):
|
||||||
|
|
||||||
if "cx" not in argsPre and needsCx:
|
if "cx" not in argsPre and needsCx:
|
||||||
args.prepend(CGGeneric("cx"))
|
args.prepend(CGGeneric("cx"))
|
||||||
|
if nativeMethodName in descriptor.inCompartmentMethods:
|
||||||
|
args.append(CGGeneric("InCompartment::in_compartment(&AlreadyInCompartment::assert_for_cx(cx))"))
|
||||||
|
|
||||||
# Build up our actual call
|
# Build up our actual call
|
||||||
self.cgRoot = CGList([], "\n")
|
self.cgRoot = CGList([], "\n")
|
||||||
|
@ -5625,13 +5627,16 @@ class CGInterfaceTrait(CGThing):
|
||||||
def __init__(self, descriptor):
|
def __init__(self, descriptor):
|
||||||
CGThing.__init__(self)
|
CGThing.__init__(self)
|
||||||
|
|
||||||
def attribute_arguments(needCx, argument=None):
|
def attribute_arguments(needCx, argument=None, inCompartment=False):
|
||||||
if needCx:
|
if needCx:
|
||||||
yield "cx", "*mut JSContext"
|
yield "cx", "*mut JSContext"
|
||||||
|
|
||||||
if argument:
|
if argument:
|
||||||
yield "value", argument_type(descriptor, argument)
|
yield "value", argument_type(descriptor, argument)
|
||||||
|
|
||||||
|
if inCompartment:
|
||||||
|
yield "_comp", "InCompartment"
|
||||||
|
|
||||||
def members():
|
def members():
|
||||||
for m in descriptor.interface.members:
|
for m in descriptor.interface.members:
|
||||||
if (m.isMethod() and not m.isStatic() and
|
if (m.isMethod() and not m.isStatic() and
|
||||||
|
@ -5640,14 +5645,18 @@ class CGInterfaceTrait(CGThing):
|
||||||
name = CGSpecializedMethod.makeNativeName(descriptor, m)
|
name = CGSpecializedMethod.makeNativeName(descriptor, m)
|
||||||
infallible = 'infallible' in descriptor.getExtendedAttributes(m)
|
infallible = 'infallible' in descriptor.getExtendedAttributes(m)
|
||||||
for idx, (rettype, arguments) in enumerate(m.signatures()):
|
for idx, (rettype, arguments) in enumerate(m.signatures()):
|
||||||
arguments = method_arguments(descriptor, rettype, arguments)
|
arguments = method_arguments(descriptor, rettype, arguments,
|
||||||
|
inCompartment=name in descriptor.inCompartmentMethods)
|
||||||
rettype = return_type(descriptor, rettype, infallible)
|
rettype = return_type(descriptor, rettype, infallible)
|
||||||
yield name + ('_' * idx), arguments, rettype
|
yield name + ('_' * idx), arguments, rettype
|
||||||
elif m.isAttr() and not m.isStatic():
|
elif m.isAttr() and not m.isStatic():
|
||||||
name = CGSpecializedGetter.makeNativeName(descriptor, m)
|
name = CGSpecializedGetter.makeNativeName(descriptor, m)
|
||||||
infallible = 'infallible' in descriptor.getExtendedAttributes(m, getter=True)
|
infallible = 'infallible' in descriptor.getExtendedAttributes(m, getter=True)
|
||||||
yield (name,
|
yield (name,
|
||||||
attribute_arguments(typeNeedsCx(m.type, True)),
|
attribute_arguments(
|
||||||
|
typeNeedsCx(m.type, True),
|
||||||
|
inCompartment=name in descriptor.inCompartmentMethods
|
||||||
|
),
|
||||||
return_type(descriptor, m.type, infallible))
|
return_type(descriptor, m.type, infallible))
|
||||||
|
|
||||||
if not m.readonly:
|
if not m.readonly:
|
||||||
|
@ -5657,7 +5666,13 @@ class CGInterfaceTrait(CGThing):
|
||||||
rettype = "()"
|
rettype = "()"
|
||||||
else:
|
else:
|
||||||
rettype = "ErrorResult"
|
rettype = "ErrorResult"
|
||||||
yield name, attribute_arguments(typeNeedsCx(m.type, False), m.type), rettype
|
yield (name,
|
||||||
|
attribute_arguments(
|
||||||
|
typeNeedsCx(m.type, False),
|
||||||
|
m.type,
|
||||||
|
inCompartment=name in descriptor.inCompartmentMethods
|
||||||
|
),
|
||||||
|
rettype)
|
||||||
|
|
||||||
if descriptor.proxy:
|
if descriptor.proxy:
|
||||||
for name, operation in descriptor.operations.iteritems():
|
for name, operation in descriptor.operations.iteritems():
|
||||||
|
@ -5671,7 +5686,8 @@ class CGInterfaceTrait(CGThing):
|
||||||
if operation.isGetter():
|
if operation.isGetter():
|
||||||
if not rettype.nullable():
|
if not rettype.nullable():
|
||||||
rettype = IDLNullableType(rettype.location, rettype)
|
rettype = IDLNullableType(rettype.location, rettype)
|
||||||
arguments = method_arguments(descriptor, rettype, arguments)
|
arguments = method_arguments(descriptor, rettype, arguments,
|
||||||
|
inCompartment=name in descriptor.inCompartmentMethods)
|
||||||
|
|
||||||
# If this interface 'supports named properties', then we
|
# If this interface 'supports named properties', then we
|
||||||
# should be able to access 'supported property names'
|
# should be able to access 'supported property names'
|
||||||
|
@ -5681,7 +5697,8 @@ class CGInterfaceTrait(CGThing):
|
||||||
if operation.isNamed():
|
if operation.isNamed():
|
||||||
yield "SupportedPropertyNames", [], "Vec<DOMString>"
|
yield "SupportedPropertyNames", [], "Vec<DOMString>"
|
||||||
else:
|
else:
|
||||||
arguments = method_arguments(descriptor, rettype, arguments)
|
arguments = method_arguments(descriptor, rettype, arguments,
|
||||||
|
inCompartment=name in descriptor.inCompartmentMethods)
|
||||||
rettype = return_type(descriptor, rettype, infallible)
|
rettype = return_type(descriptor, rettype, infallible)
|
||||||
yield name, arguments, rettype
|
yield name, arguments, rettype
|
||||||
|
|
||||||
|
@ -5975,6 +5992,8 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
||||||
'crate::dom::windowproxy::WindowProxy',
|
'crate::dom::windowproxy::WindowProxy',
|
||||||
'crate::dom::globalscope::GlobalScope',
|
'crate::dom::globalscope::GlobalScope',
|
||||||
'crate::mem::malloc_size_of_including_raw_self',
|
'crate::mem::malloc_size_of_including_raw_self',
|
||||||
|
'crate::compartments::InCompartment',
|
||||||
|
'crate::compartments::AlreadyInCompartment',
|
||||||
'libc',
|
'libc',
|
||||||
'servo_config::pref',
|
'servo_config::pref',
|
||||||
'servo_config::prefs',
|
'servo_config::prefs',
|
||||||
|
@ -6676,7 +6695,7 @@ def argument_type(descriptorProvider, ty, optional=False, defaultValue=None, var
|
||||||
return declType.define()
|
return declType.define()
|
||||||
|
|
||||||
|
|
||||||
def method_arguments(descriptorProvider, returnType, arguments, passJSBits=True, trailing=None):
|
def method_arguments(descriptorProvider, returnType, arguments, passJSBits=True, trailing=None, inCompartment=False):
|
||||||
if needCx(returnType, arguments, passJSBits):
|
if needCx(returnType, arguments, passJSBits):
|
||||||
yield "cx", "*mut JSContext"
|
yield "cx", "*mut JSContext"
|
||||||
|
|
||||||
|
@ -6688,6 +6707,9 @@ def method_arguments(descriptorProvider, returnType, arguments, passJSBits=True,
|
||||||
if trailing:
|
if trailing:
|
||||||
yield trailing
|
yield trailing
|
||||||
|
|
||||||
|
if inCompartment:
|
||||||
|
yield "_comp", "InCompartment"
|
||||||
|
|
||||||
|
|
||||||
def return_type(descriptorProvider, rettype, infallible):
|
def return_type(descriptorProvider, rettype, infallible):
|
||||||
result = getRetvalDeclarationForType(rettype, descriptorProvider)
|
result = getRetvalDeclarationForType(rettype, descriptorProvider)
|
||||||
|
|
|
@ -223,6 +223,7 @@ class Descriptor(DescriptorProvider):
|
||||||
self.concreteType = typeName
|
self.concreteType = typeName
|
||||||
self.register = desc.get('register', True)
|
self.register = desc.get('register', True)
|
||||||
self.path = desc.get('path', pathDefault)
|
self.path = desc.get('path', pathDefault)
|
||||||
|
self.inCompartmentMethods = [name for name in desc.get('inCompartments', [])]
|
||||||
self.bindingPath = 'crate::dom::bindings::codegen::Bindings::%s' % ('::'.join([ifaceName + 'Binding'] * 2))
|
self.bindingPath = 'crate::dom::bindings::codegen::Bindings::%s' % ('::'.join([ifaceName + 'Binding'] * 2))
|
||||||
self.outerObjectHook = desc.get('outerObjectHook', 'None')
|
self.outerObjectHook = desc.get('outerObjectHook', 'None')
|
||||||
self.proxy = False
|
self.proxy = False
|
||||||
|
|
|
@ -535,12 +535,8 @@ impl From<BluetoothError> for Error {
|
||||||
|
|
||||||
impl BluetoothMethods for Bluetooth {
|
impl BluetoothMethods for Bluetooth {
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-requestdevice
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-requestdevice
|
||||||
fn RequestDevice(&self, option: &RequestDeviceOptions) -> Rc<Promise> {
|
fn RequestDevice(&self, option: &RequestDeviceOptions, comp: InCompartment) -> Rc<Promise> {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let p = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if (option.filters.is_some() && option.acceptAllDevices) ||
|
if (option.filters.is_some() && option.acceptAllDevices) ||
|
||||||
(option.filters.is_none() && !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
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-getavailability
|
||||||
fn GetAvailability(&self) -> Rc<Promise> {
|
fn GetAvailability(&self, comp: InCompartment) -> Rc<Promise> {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let p = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
// Step 1. We did not override the method
|
// Step 1. We did not override the method
|
||||||
// Step 2 - 3. in handle_response
|
// Step 2 - 3. in handle_response
|
||||||
let sender = response_async(&p, self);
|
let sender = response_async(&p, self);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::BluetoothDeviceBinding;
|
use crate::dom::bindings::codegen::Bindings::BluetoothDeviceBinding;
|
||||||
use crate::dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods;
|
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
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-watchadvertisements
|
||||||
fn WatchAdvertisements(&self) -> Rc<Promise> {
|
fn WatchAdvertisements(&self, comp: InCompartment) -> Rc<Promise> {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let p = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
let sender = response_async(&p, self);
|
let sender = response_async(&p, self);
|
||||||
// TODO: Step 1.
|
// TODO: Step 1.
|
||||||
// Note: Steps 2 - 3 are implemented in components/bluetooth/lib.rs in watch_advertisements function
|
// Note: Steps 2 - 3 are implemented in components/bluetooth/lib.rs in watch_advertisements function
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding::BluetoothCharacteristicPropertiesMethods;
|
use crate::dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding::BluetoothCharacteristicPropertiesMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding;
|
use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding;
|
||||||
|
@ -135,12 +135,8 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-readvalue
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-readvalue
|
||||||
fn ReadValue(&self) -> Rc<Promise> {
|
fn ReadValue(&self, comp: InCompartment) -> Rc<Promise> {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let p = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Reads) {
|
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
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-writevalue
|
||||||
fn WriteValue(&self, value: ArrayBufferViewOrArrayBuffer) -> Rc<Promise> {
|
fn WriteValue(&self, value: ArrayBufferViewOrArrayBuffer, comp: InCompartment) -> Rc<Promise> {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let p = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Writes) {
|
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
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-startnotifications
|
||||||
fn StartNotifications(&self) -> Rc<Promise> {
|
fn StartNotifications(&self, comp: InCompartment) -> Rc<Promise> {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let p = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Reads) {
|
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
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-stopnotifications
|
||||||
fn StopNotifications(&self) -> Rc<Promise> {
|
fn StopNotifications(&self, comp: InCompartment) -> Rc<Promise> {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let p = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
let sender = response_async(&p, self);
|
let sender = response_async(&p, self);
|
||||||
|
|
||||||
// TODO: Step 3 - 4: Implement `active notification context set` for BluetoothRemoteGATTCharacteristic,
|
// TODO: Step 3 - 4: Implement `active notification context set` for BluetoothRemoteGATTCharacteristic,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding::BluetoothRemoteGATTCharacteristicMethods;
|
use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding::BluetoothRemoteGATTCharacteristicMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTDescriptorBinding;
|
use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTDescriptorBinding;
|
||||||
|
@ -94,12 +94,8 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-readvalue
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-readvalue
|
||||||
fn ReadValue(&self) -> Rc<Promise> {
|
fn ReadValue(&self, comp: InCompartment) -> Rc<Promise> {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let p = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Reads) {
|
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
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-writevalue
|
||||||
fn WriteValue(&self, value: ArrayBufferViewOrArrayBuffer) -> Rc<Promise> {
|
fn WriteValue(&self, value: ArrayBufferViewOrArrayBuffer, comp: InCompartment) -> Rc<Promise> {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let p = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Writes) {
|
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Writes) {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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::BluetoothDeviceBinding::BluetoothDeviceMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding;
|
use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding;
|
||||||
use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods;
|
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
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-connect
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
fn Connect(&self) -> Rc<Promise> {
|
fn Connect(&self, comp: InCompartment) -> Rc<Promise> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let p = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
let sender = response_async(&p, self);
|
let sender = response_async(&p, self);
|
||||||
|
|
||||||
// TODO: Step 3: Check if the UA is currently using the Bluetooth system.
|
// TODO: Step 3: Check if the UA is currently using the Bluetooth system.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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::callback::{CallbackContainer, ExceptionHandling};
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::CustomElementRegistryBinding;
|
use crate::dom::bindings::codegen::Bindings::CustomElementRegistryBinding;
|
||||||
|
@ -415,28 +415,20 @@ impl CustomElementRegistryMethods for CustomElementRegistry {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#dom-customelementregistry-whendefined>
|
/// <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 global_scope = self.window.upcast::<GlobalScope>();
|
||||||
let name = LocalName::from(&*name);
|
let name = LocalName::from(&*name);
|
||||||
|
|
||||||
// Step 1
|
// Step 1
|
||||||
if !is_valid_custom_element_name(&name) {
|
if !is_valid_custom_element_name(&name) {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&global_scope);
|
let promise = Promise::new_in_current_compartment(&global_scope, comp);
|
||||||
let promise = Promise::new_in_current_compartment(
|
|
||||||
&global_scope,
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
promise.reject_native(&DOMException::new(&global_scope, DOMErrorName::SyntaxError));
|
promise.reject_native(&DOMException::new(&global_scope, DOMErrorName::SyntaxError));
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2
|
// Step 2
|
||||||
if self.definitions.borrow().contains_key(&name) {
|
if self.definitions.borrow().contains_key(&name) {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&global_scope);
|
let promise = Promise::new_in_current_compartment(&global_scope, comp);
|
||||||
let promise = Promise::new_in_current_compartment(
|
|
||||||
&global_scope,
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
promise.resolve_native(&UndefinedValue());
|
promise.resolve_native(&UndefinedValue());
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
@ -446,11 +438,7 @@ impl CustomElementRegistryMethods for CustomElementRegistry {
|
||||||
|
|
||||||
// Steps 4, 5
|
// Steps 4, 5
|
||||||
let promise = map.get(&name).cloned().unwrap_or_else(|| {
|
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, comp);
|
||||||
let promise = Promise::new_in_current_compartment(
|
|
||||||
&global_scope,
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
map.insert(name, promise.clone());
|
map.insert(name, promise.clone());
|
||||||
promise
|
promise
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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::document_loader::{LoadBlocker, LoadType};
|
||||||
use crate::dom::attr::Attr;
|
use crate::dom::attr::Attr;
|
||||||
use crate::dom::audiotrack::AudioTrack;
|
use crate::dom::audiotrack::AudioTrack;
|
||||||
|
@ -1711,12 +1711,8 @@ impl HTMLMediaElementMethods for HTMLMediaElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-media-play
|
// https://html.spec.whatwg.org/multipage/#dom-media-play
|
||||||
fn Play(&self) -> Rc<Promise> {
|
fn Play(&self, comp: InCompartment) -> Rc<Promise> {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let promise = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
// Step 1.
|
// Step 1.
|
||||||
// FIXME(nox): Reject promise if not allowed to play.
|
// FIXME(nox): Reject promise if not allowed to play.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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::MediaStreamConstraints;
|
||||||
use crate::dom::bindings::codegen::Bindings::MediaDevicesBinding::{self, MediaDevicesMethods};
|
use crate::dom::bindings::codegen::Bindings::MediaDevicesBinding::{self, MediaDevicesMethods};
|
||||||
use crate::dom::bindings::codegen::UnionTypes::BooleanOrMediaTrackConstraints;
|
use crate::dom::bindings::codegen::UnionTypes::BooleanOrMediaTrackConstraints;
|
||||||
|
@ -46,12 +46,12 @@ impl MediaDevices {
|
||||||
impl MediaDevicesMethods for MediaDevices {
|
impl MediaDevicesMethods for MediaDevices {
|
||||||
/// https://w3c.github.io/mediacapture-main/#dom-mediadevices-getusermedia
|
/// https://w3c.github.io/mediacapture-main/#dom-mediadevices-getusermedia
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
fn GetUserMedia(&self, constraints: &MediaStreamConstraints) -> Rc<Promise> {
|
fn GetUserMedia(
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
&self,
|
||||||
let p = Promise::new_in_current_compartment(
|
constraints: &MediaStreamConstraints,
|
||||||
&self.global(),
|
comp: InCompartment,
|
||||||
InCompartment::Already(&in_compartment_proof),
|
) -> Rc<Promise> {
|
||||||
);
|
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let media = ServoMedia::get().unwrap();
|
let media = ServoMedia::get().unwrap();
|
||||||
let stream = MediaStream::new(&self.global());
|
let stream = MediaStream::new(&self.global());
|
||||||
if let Some(constraints) = convert_constraints(&constraints.audio) {
|
if let Some(constraints) = convert_constraints(&constraints.audio) {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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::NavigationPreloadState;
|
||||||
use crate::dom::bindings::codegen::Bindings::NavigationPreloadManagerBinding::{
|
use crate::dom::bindings::codegen::Bindings::NavigationPreloadManagerBinding::{
|
||||||
NavigationPreloadManagerMethods, Wrap,
|
NavigationPreloadManagerMethods, Wrap,
|
||||||
|
@ -44,12 +44,8 @@ impl NavigationPreloadManager {
|
||||||
|
|
||||||
impl NavigationPreloadManagerMethods for NavigationPreloadManager {
|
impl NavigationPreloadManagerMethods for NavigationPreloadManager {
|
||||||
// https://w3c.github.io/ServiceWorker/#navigation-preload-manager-enable
|
// https://w3c.github.io/ServiceWorker/#navigation-preload-manager-enable
|
||||||
fn Enable(&self) -> Rc<Promise> {
|
fn Enable(&self, comp: InCompartment) -> Rc<Promise> {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&*self.global());
|
let promise = Promise::new_in_current_compartment(&*self.global(), comp);
|
||||||
let promise = Promise::new_in_current_compartment(
|
|
||||||
&*self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
|
|
||||||
// 2.
|
// 2.
|
||||||
if self.serviceworker_registration.active().is_none() {
|
if self.serviceworker_registration.active().is_none() {
|
||||||
|
@ -70,12 +66,8 @@ impl NavigationPreloadManagerMethods for NavigationPreloadManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/ServiceWorker/#navigation-preload-manager-disable
|
// https://w3c.github.io/ServiceWorker/#navigation-preload-manager-disable
|
||||||
fn Disable(&self) -> Rc<Promise> {
|
fn Disable(&self, comp: InCompartment) -> Rc<Promise> {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&*self.global());
|
let promise = Promise::new_in_current_compartment(&*self.global(), comp);
|
||||||
let promise = Promise::new_in_current_compartment(
|
|
||||||
&*self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
|
|
||||||
// 2.
|
// 2.
|
||||||
if self.serviceworker_registration.active().is_none() {
|
if self.serviceworker_registration.active().is_none() {
|
||||||
|
@ -96,12 +88,8 @@ impl NavigationPreloadManagerMethods for NavigationPreloadManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/ServiceWorker/#navigation-preload-manager-setheadervalue
|
// https://w3c.github.io/ServiceWorker/#navigation-preload-manager-setheadervalue
|
||||||
fn SetHeaderValue(&self, value: ByteString) -> Rc<Promise> {
|
fn SetHeaderValue(&self, value: ByteString, comp: InCompartment) -> Rc<Promise> {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&*self.global());
|
let promise = Promise::new_in_current_compartment(&*self.global(), comp);
|
||||||
let promise = Promise::new_in_current_compartment(
|
|
||||||
&*self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
|
|
||||||
// 2.
|
// 2.
|
||||||
if self.serviceworker_registration.active().is_none() {
|
if self.serviceworker_registration.active().is_none() {
|
||||||
|
@ -122,12 +110,8 @@ impl NavigationPreloadManagerMethods for NavigationPreloadManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/ServiceWorker/#navigation-preload-manager-getstate
|
// https://w3c.github.io/ServiceWorker/#navigation-preload-manager-getstate
|
||||||
fn GetState(&self) -> Rc<Promise> {
|
fn GetState(&self, comp: InCompartment) -> Rc<Promise> {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&*self.global());
|
let promise = Promise::new_in_current_compartment(&*self.global(), comp);
|
||||||
let promise = Promise::new_in_current_compartment(
|
|
||||||
&*self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
// 2.
|
// 2.
|
||||||
let mut state = NavigationPreloadState::empty();
|
let mut state = NavigationPreloadState::empty();
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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;
|
||||||
use crate::dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods;
|
use crate::dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods;
|
||||||
use crate::dom::bindings::error::Error;
|
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
|
// https://w3c.github.io/webvr/spec/1.1/#navigator-getvrdisplays-attribute
|
||||||
fn GetVRDisplays(&self) -> Rc<Promise> {
|
fn GetVRDisplays(&self, comp: InCompartment) -> Rc<Promise> {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let promise = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
let displays = self.Xr().get_displays();
|
let displays = self.Xr().get_displays();
|
||||||
match displays {
|
match displays {
|
||||||
Ok(displays) => promise.resolve_native(&displays),
|
Ok(displays) => promise.resolve_native(&displays),
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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::audiobuffer::{AudioBuffer, MAX_SAMPLE_RATE, MIN_SAMPLE_RATE};
|
||||||
use crate::dom::audionode::MAX_CHANNEL_COUNT;
|
use crate::dom::audionode::MAX_CHANNEL_COUNT;
|
||||||
use crate::dom::baseaudiocontext::{BaseAudioContext, BaseAudioContextOptions};
|
use crate::dom::baseaudiocontext::{BaseAudioContext, BaseAudioContextOptions};
|
||||||
|
@ -114,12 +114,8 @@ impl OfflineAudioContextMethods for OfflineAudioContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://webaudio.github.io/web-audio-api/#dom-offlineaudiocontext-startrendering
|
// https://webaudio.github.io/web-audio-api/#dom-offlineaudiocontext-startrendering
|
||||||
fn StartRendering(&self) -> Rc<Promise> {
|
fn StartRendering(&self, comp: InCompartment) -> Rc<Promise> {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let promise = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
if self.rendering_started.get() {
|
if self.rendering_started.get() {
|
||||||
promise.reject_error(Error::InvalidState);
|
promise.reject_error(Error::InvalidState);
|
||||||
return promise;
|
return promise;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::RTCIceCandidateBinding::RTCIceCandidateInit;
|
use crate::dom::bindings::codegen::Bindings::RTCIceCandidateBinding::RTCIceCandidateInit;
|
||||||
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding;
|
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding;
|
||||||
|
@ -453,12 +453,8 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
|
||||||
);
|
);
|
||||||
|
|
||||||
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-addicecandidate
|
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-addicecandidate
|
||||||
fn AddIceCandidate(&self, candidate: &RTCIceCandidateInit) -> Rc<Promise> {
|
fn AddIceCandidate(&self, candidate: &RTCIceCandidateInit, comp: InCompartment) -> Rc<Promise> {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let p = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
if candidate.sdpMid.is_none() && candidate.sdpMLineIndex.is_none() {
|
if candidate.sdpMid.is_none() && candidate.sdpMLineIndex.is_none() {
|
||||||
p.reject_error(Error::Type(format!(
|
p.reject_error(Error::Type(format!(
|
||||||
"one of sdpMid and sdpMLineIndex must be set"
|
"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
|
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-createoffer
|
||||||
fn CreateOffer(&self, _options: &RTCOfferOptions) -> Rc<Promise> {
|
fn CreateOffer(&self, _options: &RTCOfferOptions, comp: InCompartment) -> Rc<Promise> {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let p = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
if self.closed.get() {
|
if self.closed.get() {
|
||||||
p.reject_error(Error::InvalidState);
|
p.reject_error(Error::InvalidState);
|
||||||
return p;
|
return p;
|
||||||
|
@ -508,12 +500,8 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-createoffer
|
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-createoffer
|
||||||
fn CreateAnswer(&self, _options: &RTCAnswerOptions) -> Rc<Promise> {
|
fn CreateAnswer(&self, _options: &RTCAnswerOptions, comp: InCompartment) -> Rc<Promise> {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let p = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
if self.closed.get() {
|
if self.closed.get() {
|
||||||
p.reject_error(Error::InvalidState);
|
p.reject_error(Error::InvalidState);
|
||||||
return p;
|
return p;
|
||||||
|
@ -534,13 +522,13 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-setlocaldescription
|
/// 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
|
// XXXManishearth validate the current state
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let p = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
let this = Trusted::new(self);
|
let this = Trusted::new(self);
|
||||||
let desc: SessionDescription = desc.into();
|
let desc: SessionDescription = desc.into();
|
||||||
let trusted_promise = TrustedPromise::new(p.clone());
|
let trusted_promise = TrustedPromise::new(p.clone());
|
||||||
|
@ -571,13 +559,13 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-setremotedescription
|
/// 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
|
// XXXManishearth validate the current state
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let p = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
let this = Trusted::new(self);
|
let this = Trusted::new(self);
|
||||||
let desc: SessionDescription = desc.into();
|
let desc: SessionDescription = desc.into();
|
||||||
let trusted_promise = TrustedPromise::new(p.clone());
|
let trusted_promise = TrustedPromise::new(p.clone());
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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::RegistrationOptions;
|
||||||
use crate::dom::bindings::codegen::Bindings::ServiceWorkerContainerBinding::{
|
use crate::dom::bindings::codegen::Bindings::ServiceWorkerContainerBinding::{
|
||||||
ServiceWorkerContainerMethods, Wrap,
|
ServiceWorkerContainerMethods, Wrap,
|
||||||
|
@ -55,13 +55,14 @@ impl ServiceWorkerContainerMethods for ServiceWorkerContainer {
|
||||||
#[allow(unrooted_must_root)] // Job is unrooted
|
#[allow(unrooted_must_root)] // Job is unrooted
|
||||||
/// https://w3c.github.io/ServiceWorker/#navigator-service-worker-register and - A
|
/// https://w3c.github.io/ServiceWorker/#navigator-service-worker-register and - A
|
||||||
/// https://w3c.github.io/ServiceWorker/#start-register-algorithm - B
|
/// 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
|
// A: Step 1
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&*self.global());
|
let promise = Promise::new_in_current_compartment(&*self.global(), comp);
|
||||||
let promise = Promise::new_in_current_compartment(
|
|
||||||
&*self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
let USVString(ref script_url) = script_url;
|
let USVString(ref script_url) = script_url;
|
||||||
let api_base_url = self.global().api_base_url();
|
let api_base_url = self.global().api_base_url();
|
||||||
// A: Step 3-5
|
// A: Step 3-5
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
// check-tidy: no specs after this line
|
// 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::callback::ExceptionHandling;
|
||||||
use crate::dom::bindings::codegen::Bindings::EventListenerBinding::EventListener;
|
use crate::dom::bindings::codegen::Bindings::EventListenerBinding::EventListener;
|
||||||
use crate::dom::bindings::codegen::Bindings::FunctionBinding::Function;
|
use crate::dom::bindings::codegen::Bindings::FunctionBinding::Function;
|
||||||
|
@ -1014,6 +1014,7 @@ impl TestBindingMethods for TestBinding {
|
||||||
&self,
|
&self,
|
||||||
resolve: Option<Rc<SimpleCallback>>,
|
resolve: Option<Rc<SimpleCallback>>,
|
||||||
reject: Option<Rc<SimpleCallback>>,
|
reject: Option<Rc<SimpleCallback>>,
|
||||||
|
comp: InCompartment,
|
||||||
) -> Rc<Promise> {
|
) -> Rc<Promise> {
|
||||||
let global = self.global();
|
let global = self.global();
|
||||||
let handler = PromiseNativeHandler::new(
|
let handler = PromiseNativeHandler::new(
|
||||||
|
@ -1021,11 +1022,7 @@ impl TestBindingMethods for TestBinding {
|
||||||
resolve.map(SimpleHandler::new),
|
resolve.map(SimpleHandler::new),
|
||||||
reject.map(SimpleHandler::new),
|
reject.map(SimpleHandler::new),
|
||||||
);
|
);
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&global);
|
let p = Promise::new_in_current_compartment(&global, comp);
|
||||||
let p = Promise::new_in_current_compartment(
|
|
||||||
&global,
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
p.append_native_handler(&handler);
|
p.append_native_handler(&handler);
|
||||||
return p;
|
return p;
|
||||||
|
|
||||||
|
@ -1048,12 +1045,8 @@ impl TestBindingMethods for TestBinding {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn PromiseAttribute(&self) -> Rc<Promise> {
|
fn PromiseAttribute(&self, comp: InCompartment) -> Rc<Promise> {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
Promise::new_in_current_compartment(&self.global(), comp)
|
||||||
Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn AcceptPromise(&self, _promise: &Promise) {}
|
fn AcceptPromise(&self, _promise: &Promise) {}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
// check-tidy: no specs after this line
|
// 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::TestWorkletMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::TestWorkletBinding::Wrap;
|
use crate::dom::bindings::codegen::Bindings::TestWorkletBinding::Wrap;
|
||||||
use crate::dom::bindings::codegen::Bindings::WorkletBinding::WorkletBinding::WorkletMethods;
|
use crate::dom::bindings::codegen::Bindings::WorkletBinding::WorkletBinding::WorkletMethods;
|
||||||
|
@ -51,8 +51,13 @@ impl TestWorklet {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestWorkletMethods for TestWorklet {
|
impl TestWorkletMethods for TestWorklet {
|
||||||
fn AddModule(&self, moduleURL: USVString, options: &WorkletOptions) -> Rc<Promise> {
|
fn AddModule(
|
||||||
self.worklet.AddModule(moduleURL, options)
|
&self,
|
||||||
|
moduleURL: USVString,
|
||||||
|
options: &WorkletOptions,
|
||||||
|
comp: InCompartment,
|
||||||
|
) -> Rc<Promise> {
|
||||||
|
self.worklet.AddModule(moduleURL, options, comp)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Lookup(&self, key: DOMString) -> Option<DOMString> {
|
fn Lookup(&self, key: DOMString) -> Option<DOMString> {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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::callback::ExceptionHandling;
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods;
|
use crate::dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods;
|
||||||
|
@ -352,12 +352,8 @@ impl VRDisplayMethods for VRDisplay {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/webvr/#dom-vrdisplay-requestpresent
|
// https://w3c.github.io/webvr/#dom-vrdisplay-requestpresent
|
||||||
fn RequestPresent(&self, layers: Vec<VRLayer>) -> Rc<Promise> {
|
fn RequestPresent(&self, layers: Vec<VRLayer>, comp: InCompartment) -> Rc<Promise> {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let promise = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
// TODO: WebVR spec: this method must be called in response to a user gesture
|
// 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
|
// 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
|
// https://w3c.github.io/webvr/#dom-vrdisplay-exitpresent
|
||||||
fn ExitPresent(&self) -> Rc<Promise> {
|
fn ExitPresent(&self, comp: InCompartment) -> Rc<Promise> {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let promise = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
|
|
||||||
// WebVR spec: If the VRDisplay is not presenting the promise MUST be rejected.
|
// WebVR spec: If the VRDisplay is not presenting the promise MUST be rejected.
|
||||||
if !self.presenting.get() {
|
if !self.presenting.get() {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
use crate::compartments::InCompartment;
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::DocumentBinding::{
|
use crate::dom::bindings::codegen::Bindings::DocumentBinding::{
|
||||||
DocumentMethods, DocumentReadyState,
|
DocumentMethods, DocumentReadyState,
|
||||||
|
@ -1144,8 +1145,9 @@ impl WindowMethods for Window {
|
||||||
&self,
|
&self,
|
||||||
input: RequestOrUSVString,
|
input: RequestOrUSVString,
|
||||||
init: RootedTraceableBox<RequestInit>,
|
init: RootedTraceableBox<RequestInit>,
|
||||||
|
comp: InCompartment,
|
||||||
) -> Rc<Promise> {
|
) -> Rc<Promise> {
|
||||||
fetch::Fetch(&self.upcast(), input, init)
|
fetch::Fetch(&self.upcast(), input, init, comp)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn TestRunner(&self) -> DomRoot<TestRunner> {
|
fn TestRunner(&self) -> DomRoot<TestRunner> {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
use crate::compartments::InCompartment;
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::FunctionBinding::Function;
|
use crate::dom::bindings::codegen::Bindings::FunctionBinding::Function;
|
||||||
use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestInit;
|
use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestInit;
|
||||||
|
@ -368,8 +369,9 @@ impl WorkerGlobalScopeMethods for WorkerGlobalScope {
|
||||||
&self,
|
&self,
|
||||||
input: RequestOrUSVString,
|
input: RequestOrUSVString,
|
||||||
init: RootedTraceableBox<RequestInit>,
|
init: RootedTraceableBox<RequestInit>,
|
||||||
|
comp: InCompartment,
|
||||||
) -> Rc<Promise> {
|
) -> Rc<Promise> {
|
||||||
fetch::Fetch(self.upcast(), input, init)
|
fetch::Fetch(self.upcast(), input, init, comp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/hr-time/#the-performance-attribute
|
// https://w3c.github.io/hr-time/#the-performance-attribute
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
//! thread pool implementation, which only performs GC or code loading on
|
//! thread pool implementation, which only performs GC or code loading on
|
||||||
//! a backup thread, not on the primary worklet thread.
|
//! 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::RequestBinding::RequestCredentials;
|
||||||
use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
|
use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::WorkletBinding::WorkletMethods;
|
use crate::dom::bindings::codegen::Bindings::WorkletBinding::WorkletMethods;
|
||||||
|
@ -111,14 +111,15 @@ impl Worklet {
|
||||||
|
|
||||||
impl WorkletMethods for Worklet {
|
impl WorkletMethods for Worklet {
|
||||||
/// <https://drafts.css-houdini.org/worklets/#dom-worklet-addmodule>
|
/// <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.
|
// Step 1.
|
||||||
let global = self.window.upcast();
|
let global = self.window.upcast();
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&global);
|
let promise = Promise::new_in_current_compartment(&global, comp);
|
||||||
let promise = Promise::new_in_current_compartment(
|
|
||||||
&global,
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Step 3.
|
// Step 3.
|
||||||
let module_url_record = match self.window.Document().base_url().join(&module_url.0) {
|
let module_url_record = match self.window.Document().base_url().join(&module_url.0) {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::VRDisplayBinding::VRDisplayMethods;
|
use crate::dom::bindings::codegen::Bindings::VRDisplayBinding::VRDisplayMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::XRBinding;
|
use crate::dom::bindings::codegen::Bindings::XRBinding;
|
||||||
|
@ -87,13 +87,9 @@ impl Drop for XR {
|
||||||
|
|
||||||
impl XRMethods for XR {
|
impl XRMethods for XR {
|
||||||
/// https://immersive-web.github.io/webxr/#dom-xr-supportssessionmode
|
/// 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
|
// 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(), comp);
|
||||||
let promise = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
if mode == XRSessionMode::Immersive_vr {
|
if mode == XRSessionMode::Immersive_vr {
|
||||||
promise.resolve_native(&());
|
promise.resolve_native(&());
|
||||||
} else {
|
} else {
|
||||||
|
@ -105,12 +101,12 @@ impl XRMethods for XR {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://immersive-web.github.io/webxr/#dom-xr-requestsession
|
/// https://immersive-web.github.io/webxr/#dom-xr-requestsession
|
||||||
fn RequestSession(&self, options: &XRSessionCreationOptions) -> Rc<Promise> {
|
fn RequestSession(
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
&self,
|
||||||
let promise = Promise::new_in_current_compartment(
|
options: &XRSessionCreationOptions,
|
||||||
&self.global(),
|
comp: InCompartment,
|
||||||
InCompartment::Already(&in_compartment_proof),
|
) -> Rc<Promise> {
|
||||||
);
|
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
if options.mode != XRSessionMode::Immersive_vr {
|
if options.mode != XRSessionMode::Immersive_vr {
|
||||||
promise.reject_error(Error::NotSupported);
|
promise.reject_error(Error::NotSupported);
|
||||||
return promise;
|
return promise;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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::VRDisplayBinding::VRDisplayMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::XRBinding::XRSessionMode;
|
use crate::dom::bindings::codegen::Bindings::XRBinding::XRSessionMode;
|
||||||
use crate::dom::bindings::codegen::Bindings::XRRenderStateBinding::XRRenderStateInit;
|
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
|
/// https://immersive-web.github.io/webxr/#dom-xrsession-requestanimationframe
|
||||||
fn UpdateRenderState(&self, init: &XRRenderStateInit) -> Rc<Promise> {
|
fn UpdateRenderState(&self, init: &XRRenderStateInit, comp: InCompartment) -> Rc<Promise> {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
let p = Promise::new_in_current_compartment(
|
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
self.display.queue_renderstate(init, p.clone());
|
self.display.queue_renderstate(init, p.clone());
|
||||||
p
|
p
|
||||||
}
|
}
|
||||||
|
@ -120,12 +116,12 @@ impl XRSessionMethods for XRSession {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://immersive-web.github.io/webxr/#dom-xrsession-requestreferencespace
|
/// https://immersive-web.github.io/webxr/#dom-xrsession-requestreferencespace
|
||||||
fn RequestReferenceSpace(&self, options: &XRReferenceSpaceOptions) -> Rc<Promise> {
|
fn RequestReferenceSpace(
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
&self,
|
||||||
let p = Promise::new_in_current_compartment(
|
options: &XRReferenceSpaceOptions,
|
||||||
&self.global(),
|
comp: InCompartment,
|
||||||
InCompartment::Already(&in_compartment_proof),
|
) -> Rc<Promise> {
|
||||||
);
|
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
||||||
|
|
||||||
// https://immersive-web.github.io/webxr/#create-a-reference-space
|
// https://immersive-web.github.io/webxr/#create-a-reference-space
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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::RequestBinding::RequestInfo;
|
use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestInfo;
|
||||||
use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestInit;
|
use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestInit;
|
||||||
use crate::dom::bindings::codegen::Bindings::ResponseBinding::ResponseBinding::ResponseMethods;
|
use crate::dom::bindings::codegen::Bindings::ResponseBinding::ResponseBinding::ResponseMethods;
|
||||||
|
@ -134,12 +134,12 @@ pub fn Fetch(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
input: RequestInfo,
|
input: RequestInfo,
|
||||||
init: RootedTraceableBox<RequestInit>,
|
init: RootedTraceableBox<RequestInit>,
|
||||||
|
comp: InCompartment,
|
||||||
) -> Rc<Promise> {
|
) -> Rc<Promise> {
|
||||||
let core_resource_thread = global.core_resource_thread();
|
let core_resource_thread = global.core_resource_thread();
|
||||||
|
|
||||||
// Step 1
|
// Step 1
|
||||||
let aic = AlreadyInCompartment::assert(global);
|
let promise = Promise::new_in_current_compartment(global, comp);
|
||||||
let promise = Promise::new_in_current_compartment(global, InCompartment::Already(&aic));
|
|
||||||
let response = Response::new(global);
|
let response = Response::new(global);
|
||||||
|
|
||||||
// Step 2
|
// Step 2
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue