mirror of
https://github.com/servo/servo.git
synced 2025-06-20 07:08:59 +01:00
Auto merge of #25597 - kunalmohan:25581-Compartment, r=jdm
Rename compartment to realm <!-- Please describe your changes on the following line: --> Rename compartment-related terminology to use realms instead. r?@jdm --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #25581 (GitHub issue number if applicable) <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
commit
12693b51f5
54 changed files with 226 additions and 259 deletions
|
@ -377,9 +377,6 @@ mod gen {
|
||||||
slice_ms: i64,
|
slice_ms: i64,
|
||||||
},
|
},
|
||||||
low_frequency_heap_growth: i64,
|
low_frequency_heap_growth: i64,
|
||||||
per_compartment: {
|
|
||||||
enabled: bool,
|
|
||||||
},
|
|
||||||
per_zone: {
|
per_zone: {
|
||||||
enabled: bool,
|
enabled: bool,
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* 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::dom::bindings::cell::Ref;
|
use crate::dom::bindings::cell::Ref;
|
||||||
use crate::dom::bindings::codegen::Bindings::FormDataBinding::FormDataMethods;
|
use crate::dom::bindings::codegen::Bindings::FormDataBinding::FormDataMethods;
|
||||||
use crate::dom::bindings::error::{Error, Fallible};
|
use crate::dom::bindings::error::{Error, Fallible};
|
||||||
|
@ -14,6 +13,7 @@ use crate::dom::blob::{normalize_type_string, Blob};
|
||||||
use crate::dom::formdata::FormData;
|
use crate::dom::formdata::FormData;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
|
use crate::realms::{AlreadyInRealm, InRealm};
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::JSContext;
|
||||||
use js::jsapi::Heap;
|
use js::jsapi::Heap;
|
||||||
use js::jsapi::JSObject;
|
use js::jsapi::JSObject;
|
||||||
|
@ -52,11 +52,9 @@ pub enum FetchedData {
|
||||||
// https://fetch.spec.whatwg.org/#concept-body-consume-body
|
// https://fetch.spec.whatwg.org/#concept-body-consume-body
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn consume_body<T: BodyOperations + DomObject>(object: &T, body_type: BodyType) -> Rc<Promise> {
|
pub fn consume_body<T: BodyOperations + DomObject>(object: &T, body_type: BodyType) -> Rc<Promise> {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&object.global());
|
let in_realm_proof = AlreadyInRealm::assert(&object.global());
|
||||||
let promise = Promise::new_in_current_compartment(
|
let promise =
|
||||||
&object.global(),
|
Promise::new_in_current_realm(&object.global(), InRealm::Already(&in_realm_proof));
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Step 1
|
// Step 1
|
||||||
if object.get_body_used() || object.is_locked() {
|
if object.get_body_used() || object.is_locked() {
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* 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::enter_realm;
|
|
||||||
use crate::dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods;
|
use crate::dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods;
|
use crate::dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
||||||
|
@ -17,6 +16,7 @@ use crate::dom::element::Element;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::node::{window_from_node, Node, ShadowIncluding};
|
use crate::dom::node::{window_from_node, Node, ShadowIncluding};
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::realms::enter_realm;
|
||||||
use crate::script_thread::Documents;
|
use crate::script_thread::Documents;
|
||||||
use devtools_traits::{AutoMargins, ComputedNodeLayout, TimelineMarkerType};
|
use devtools_traits::{AutoMargins, ComputedNodeLayout, TimelineMarkerType};
|
||||||
use devtools_traits::{EvaluateJSReply, Modification, NodeInfo, TimelineMarker};
|
use devtools_traits::{EvaluateJSReply, Modification, NodeInfo, TimelineMarker};
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* 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::enter_realm;
|
|
||||||
use crate::dom::audionode::MAX_CHANNEL_COUNT;
|
use crate::dom::audionode::MAX_CHANNEL_COUNT;
|
||||||
use crate::dom::bindings::cell::{DomRefCell, Ref};
|
use crate::dom::bindings::cell::{DomRefCell, Ref};
|
||||||
use crate::dom::bindings::codegen::Bindings::AudioBufferBinding::{
|
use crate::dom::bindings::codegen::Bindings::AudioBufferBinding::{
|
||||||
|
@ -13,6 +12,7 @@ use crate::dom::bindings::num::Finite;
|
||||||
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
|
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
|
||||||
use crate::dom::bindings::root::DomRoot;
|
use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::realms::enter_realm;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::JSContext;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use js::jsapi::JS_GetArrayBufferViewBuffer;
|
use js::jsapi::JS_GetArrayBufferViewBuffer;
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* 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::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::{
|
||||||
|
@ -24,6 +23,7 @@ use crate::dom::htmlmediaelement::HTMLMediaElement;
|
||||||
use crate::dom::mediaelementaudiosourcenode::MediaElementAudioSourceNode;
|
use crate::dom::mediaelementaudiosourcenode::MediaElementAudioSourceNode;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::realms::InRealm;
|
||||||
use crate::task_source::TaskSource;
|
use crate::task_source::TaskSource;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
|
@ -127,9 +127,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, comp: InCompartment) -> Rc<Promise> {
|
fn Suspend(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
let promise = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
if self.context.control_thread_state() == ProcessingState::Closed {
|
if self.context.control_thread_state() == ProcessingState::Closed {
|
||||||
|
@ -188,9 +188,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, comp: InCompartment) -> Rc<Promise> {
|
fn Close(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
let promise = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
if self.context.control_thread_state() == ProcessingState::Closed {
|
if self.context.control_thread_state() == ProcessingState::Closed {
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* 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::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;
|
||||||
|
@ -47,6 +46,7 @@ use crate::dom::pannernode::PannerNode;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
use crate::dom::stereopannernode::StereoPannerNode;
|
use crate::dom::stereopannernode::StereoPannerNode;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::realms::InRealm;
|
||||||
use crate::task_source::TaskSource;
|
use crate::task_source::TaskSource;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use js::rust::CustomAutoRooterGuard;
|
use js::rust::CustomAutoRooterGuard;
|
||||||
|
@ -282,9 +282,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, comp: InCompartment) -> Rc<Promise> {
|
fn Resume(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
let promise = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
if self.audio_context_impl.lock().unwrap().state() == ProcessingState::Closed {
|
if self.audio_context_impl.lock().unwrap().state() == ProcessingState::Closed {
|
||||||
|
@ -437,10 +437,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,
|
comp: InRealm,
|
||||||
) -> Rc<Promise> {
|
) -> Rc<Promise> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
let promise = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
let global = self.global();
|
let global = self.global();
|
||||||
let window = global.as_window();
|
let window = global.as_window();
|
||||||
|
|
||||||
|
|
|
@ -205,7 +205,7 @@ impl CallbackInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wraps the reflector for `p` into the compartment of `cx`.
|
/// Wraps the reflector for `p` into the realm of `cx`.
|
||||||
pub fn wrap_call_this_object<T: DomObject>(cx: JSContext, p: &T, mut rval: MutableHandleObject) {
|
pub fn wrap_call_this_object<T: DomObject>(cx: JSContext, p: &T, mut rval: MutableHandleObject) {
|
||||||
rval.set(p.reflector().get_jsobject().get());
|
rval.set(p.reflector().get_jsobject().get());
|
||||||
assert!(!rval.get().is_null());
|
assert!(!rval.get().is_null());
|
||||||
|
@ -225,7 +225,7 @@ pub struct CallSetup {
|
||||||
exception_global: DomRoot<GlobalScope>,
|
exception_global: DomRoot<GlobalScope>,
|
||||||
/// The `JSContext` used for the call.
|
/// The `JSContext` used for the call.
|
||||||
cx: JSContext,
|
cx: JSContext,
|
||||||
/// The compartment we were in before the call.
|
/// The realm we were in before the call.
|
||||||
old_realm: *mut Realm,
|
old_realm: *mut Realm,
|
||||||
/// The exception handling used for the call.
|
/// The exception handling used for the call.
|
||||||
handling: ExceptionHandling,
|
handling: ExceptionHandling,
|
||||||
|
|
|
@ -44,7 +44,7 @@ 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'],
|
'inRealms': ['PromiseAttribute', 'PromiseNativeHandler'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'URL': {
|
'URL': {
|
||||||
|
@ -57,99 +57,99 @@ DOMInterfaces = {
|
||||||
},
|
},
|
||||||
|
|
||||||
'Window': {
|
'Window': {
|
||||||
'inCompartments': ['Fetch'],
|
'inRealms': ['Fetch'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'WorkerGlobalScope': {
|
'WorkerGlobalScope': {
|
||||||
'inCompartments': ['Fetch'],
|
'inRealms': ['Fetch'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'CustomElementRegistry': {
|
'CustomElementRegistry': {
|
||||||
'inCompartments': ['WhenDefined'],
|
'inRealms': ['WhenDefined'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'AudioContext': {
|
'AudioContext': {
|
||||||
'inCompartments': ['Suspend', 'Close'],
|
'inRealms': ['Suspend', 'Close'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'NavigationPreloadManager': {
|
'NavigationPreloadManager': {
|
||||||
'inCompartments': ['Enable', 'Disable', 'SetHeaderValue', 'GetState'],
|
'inRealms': ['Enable', 'Disable', 'SetHeaderValue', 'GetState'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'HTMLMediaElement': {
|
'HTMLMediaElement': {
|
||||||
'inCompartments': ['Play'],
|
'inRealms': ['Play'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'BluetoothRemoteGATTDescriptor': {
|
'BluetoothRemoteGATTDescriptor': {
|
||||||
'inCompartments': ['ReadValue', 'WriteValue'],
|
'inRealms': ['ReadValue', 'WriteValue'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'OfflineAudioContext': {
|
'OfflineAudioContext': {
|
||||||
'inCompartments': ['StartRendering'],
|
'inRealms': ['StartRendering'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'BluetoothRemoteGATTServer': {
|
'BluetoothRemoteGATTServer': {
|
||||||
'inCompartments': ['Connect'],
|
'inRealms': ['Connect'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'ServiceWorkerContainer': {
|
'ServiceWorkerContainer': {
|
||||||
'inCompartments': ['Register'],
|
'inRealms': ['Register'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'Navigator': {
|
'Navigator': {
|
||||||
'inCompartments': ['GetVRDisplays'],
|
'inRealms': ['GetVRDisplays'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'MediaDevices': {
|
'MediaDevices': {
|
||||||
'inCompartments': ['GetUserMedia'],
|
'inRealms': ['GetUserMedia'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'XRSession': {
|
'XRSession': {
|
||||||
'inCompartments': ['UpdateRenderState', 'RequestReferenceSpace'],
|
'inRealms': ['UpdateRenderState', 'RequestReferenceSpace'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'Bluetooth': {
|
'Bluetooth': {
|
||||||
'inCompartments': ['RequestDevice', 'GetAvailability'],
|
'inRealms': ['RequestDevice', 'GetAvailability'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'BaseAudioContext': {
|
'BaseAudioContext': {
|
||||||
'inCompartments': ['Resume', 'DecodeAudioData'],
|
'inRealms': ['Resume', 'DecodeAudioData'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'RTCPeerConnection': {
|
'RTCPeerConnection': {
|
||||||
'inCompartments': ['AddIceCandidate', 'CreateOffer', 'CreateAnswer', 'SetLocalDescription', 'SetRemoteDescription'],
|
'inRealms': ['AddIceCandidate', 'CreateOffer', 'CreateAnswer', 'SetLocalDescription', 'SetRemoteDescription'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'BluetoothRemoteGATTCharacteristic': {
|
'BluetoothRemoteGATTCharacteristic': {
|
||||||
'inCompartments': ['ReadValue', 'WriteValue', 'StartNotifications', 'StopNotifications'],
|
'inRealms': ['ReadValue', 'WriteValue', 'StartNotifications', 'StopNotifications'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'VRDisplay': {
|
'VRDisplay': {
|
||||||
'inCompartments': ['RequestPresent', 'ExitPresent'],
|
'inRealms': ['RequestPresent', 'ExitPresent'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'Worklet': {
|
'Worklet': {
|
||||||
'inCompartments': ['AddModule'],
|
'inRealms': ['AddModule'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'TestWorklet': {
|
'TestWorklet': {
|
||||||
'inCompartments': ['AddModule'],
|
'inRealms': ['AddModule'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'BluetoothDevice': {
|
'BluetoothDevice': {
|
||||||
'inCompartments': ['WatchAdvertisements'],
|
'inRealms': ['WatchAdvertisements'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'XR': {
|
'XR': {
|
||||||
'inCompartments': ['SupportsSessionMode', 'RequestSession'],
|
'inRealms': ['SupportsSessionMode', 'RequestSession'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'GPU': {
|
'GPU': {
|
||||||
'inCompartments': ['RequestAdapter'],
|
'inRealms': ['RequestAdapter'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'GPUAdapter': {
|
'GPUAdapter': {
|
||||||
'inCompartments': ['RequestDevice'],
|
'inRealms': ['RequestDevice'],
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -771,14 +771,14 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
||||||
#
|
#
|
||||||
# 1) Normal call to API with a Promise argument. This is a case the
|
# 1) Normal call to API with a Promise argument. This is a case the
|
||||||
# spec covers, and we should be using the current Realm's
|
# spec covers, and we should be using the current Realm's
|
||||||
# Promise. That means the current compartment.
|
# Promise. That means the current realm.
|
||||||
# 2) Promise return value from a callback or callback interface.
|
# 2) Promise return value from a callback or callback interface.
|
||||||
# This is in theory a case the spec covers but in practice it
|
# This is in theory a case the spec covers but in practice it
|
||||||
# really doesn't define behavior here because it doesn't define
|
# really doesn't define behavior here because it doesn't define
|
||||||
# what Realm we're in after the callback returns, which is when
|
# what Realm we're in after the callback returns, which is when
|
||||||
# the argument conversion happens. We will use the current
|
# the argument conversion happens. We will use the current
|
||||||
# compartment, which is the compartment of the callable (which
|
# realm, which is the realm of the callable (which
|
||||||
# may itself be a cross-compartment wrapper itself), which makes
|
# may itself be a cross-realm wrapper itself), which makes
|
||||||
# as much sense as anything else. In practice, such an API would
|
# as much sense as anything else. In practice, such an API would
|
||||||
# once again be providing a Promise to signal completion of an
|
# once again be providing a Promise to signal completion of an
|
||||||
# operation, which would then not be exposed to anyone other than
|
# operation, which would then not be exposed to anyone other than
|
||||||
|
@ -3397,8 +3397,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:
|
if nativeMethodName in descriptor.inRealmMethods:
|
||||||
args.append(CGGeneric("InCompartment::in_compartment(&AlreadyInCompartment::assert_for_cx(cx))"))
|
args.append(CGGeneric("InRealm::in_realm(&AlreadyInRealm::assert_for_cx(cx))"))
|
||||||
|
|
||||||
# Build up our actual call
|
# Build up our actual call
|
||||||
self.cgRoot = CGList([], "\n")
|
self.cgRoot = CGList([], "\n")
|
||||||
|
@ -5671,7 +5671,7 @@ let global = DomRoot::downcast::<dom::types::%s>(global).unwrap();
|
||||||
// Step 2 https://html.spec.whatwg.org/multipage/#htmlconstructor
|
// Step 2 https://html.spec.whatwg.org/multipage/#htmlconstructor
|
||||||
// The custom element definition cannot use an element interface as its constructor
|
// The custom element definition cannot use an element interface as its constructor
|
||||||
|
|
||||||
// The new_target might be a cross-compartment wrapper. Get the underlying object
|
// The new_target might be a cross-realm wrapper. Get the underlying object
|
||||||
// so we can do the spec's object-identity checks.
|
// so we can do the spec's object-identity checks.
|
||||||
rooted!(in(*cx) let new_target = UnwrapObjectDynamic(args.new_target().to_object(), *cx, 1));
|
rooted!(in(*cx) let new_target = UnwrapObjectDynamic(args.new_target().to_object(), *cx, 1));
|
||||||
if new_target.is_null() {
|
if new_target.is_null() {
|
||||||
|
@ -5697,11 +5697,11 @@ rooted!(in(*cx) let mut prototype = ptr::null_mut::<JSObject>());
|
||||||
if !proto_val.is_object() {
|
if !proto_val.is_object() {
|
||||||
// Step 7 of https://html.spec.whatwg.org/multipage/#htmlconstructor.
|
// Step 7 of https://html.spec.whatwg.org/multipage/#htmlconstructor.
|
||||||
// This fallback behavior is designed to match analogous behavior for the
|
// This fallback behavior is designed to match analogous behavior for the
|
||||||
// JavaScript built-ins. So we enter the compartment of our underlying
|
// JavaScript built-ins. So we enter the realm of our underlying
|
||||||
// newTarget object and fall back to the prototype object from that global.
|
// newTarget object and fall back to the prototype object from that global.
|
||||||
// XXX The spec says to use GetFunctionRealm(), which is not actually
|
// XXX The spec says to use GetFunctionRealm(), which is not actually
|
||||||
// the same thing as what we have here (e.g. in the case of scripted callable proxies
|
// the same thing as what we have here (e.g. in the case of scripted callable proxies
|
||||||
// whose target is not same-compartment with the proxy, or bound functions, etc).
|
// whose target is not same-realm with the proxy, or bound functions, etc).
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1317658
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1317658
|
||||||
|
|
||||||
rooted!(in(*cx) let global_object = CurrentGlobalOrNull(*cx));
|
rooted!(in(*cx) let global_object = CurrentGlobalOrNull(*cx));
|
||||||
|
@ -5712,7 +5712,7 @@ rooted!(in(*cx) let mut prototype = ptr::null_mut::<JSObject>());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrap prototype in this context since it is from the newTarget compartment
|
// Wrap prototype in this context since it is from the newTarget realm
|
||||||
if !JS_WrapObject(*cx, prototype.handle_mut()) {
|
if !JS_WrapObject(*cx, prototype.handle_mut()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -5770,15 +5770,15 @@ class CGInterfaceTrait(CGThing):
|
||||||
def __init__(self, descriptor):
|
def __init__(self, descriptor):
|
||||||
CGThing.__init__(self)
|
CGThing.__init__(self)
|
||||||
|
|
||||||
def attribute_arguments(needCx, argument=None, inCompartment=False):
|
def attribute_arguments(needCx, argument=None, inRealm=False):
|
||||||
if needCx:
|
if needCx:
|
||||||
yield "cx", "SafeJSContext"
|
yield "cx", "SafeJSContext"
|
||||||
|
|
||||||
if argument:
|
if argument:
|
||||||
yield "value", argument_type(descriptor, argument)
|
yield "value", argument_type(descriptor, argument)
|
||||||
|
|
||||||
if inCompartment:
|
if inRealm:
|
||||||
yield "_comp", "InCompartment"
|
yield "_comp", "InRealm"
|
||||||
|
|
||||||
def members():
|
def members():
|
||||||
for m in descriptor.interface.members:
|
for m in descriptor.interface.members:
|
||||||
|
@ -5790,7 +5790,7 @@ class CGInterfaceTrait(CGThing):
|
||||||
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)
|
inRealm=name in descriptor.inRealmMethods)
|
||||||
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():
|
||||||
|
@ -5799,7 +5799,7 @@ class CGInterfaceTrait(CGThing):
|
||||||
yield (name,
|
yield (name,
|
||||||
attribute_arguments(
|
attribute_arguments(
|
||||||
typeNeedsCx(m.type, True),
|
typeNeedsCx(m.type, True),
|
||||||
inCompartment=name in descriptor.inCompartmentMethods
|
inRealm=name in descriptor.inRealmMethods
|
||||||
),
|
),
|
||||||
return_type(descriptor, m.type, infallible))
|
return_type(descriptor, m.type, infallible))
|
||||||
|
|
||||||
|
@ -5814,7 +5814,7 @@ class CGInterfaceTrait(CGThing):
|
||||||
attribute_arguments(
|
attribute_arguments(
|
||||||
typeNeedsCx(m.type, False),
|
typeNeedsCx(m.type, False),
|
||||||
m.type,
|
m.type,
|
||||||
inCompartment=name in descriptor.inCompartmentMethods
|
inRealm=name in descriptor.inRealmMethods
|
||||||
),
|
),
|
||||||
rettype)
|
rettype)
|
||||||
|
|
||||||
|
@ -5831,7 +5831,7 @@ class CGInterfaceTrait(CGThing):
|
||||||
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)
|
inRealm=name in descriptor.inRealmMethods)
|
||||||
|
|
||||||
# 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'
|
||||||
|
@ -5842,7 +5842,7 @@ class CGInterfaceTrait(CGThing):
|
||||||
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)
|
inRealm=name in descriptor.inRealmMethods)
|
||||||
rettype = return_type(descriptor, rettype, infallible)
|
rettype = return_type(descriptor, rettype, infallible)
|
||||||
yield name, arguments, rettype
|
yield name, arguments, rettype
|
||||||
|
|
||||||
|
@ -6138,8 +6138,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::realms::InRealm',
|
||||||
'crate::compartments::AlreadyInCompartment',
|
'crate::realms::AlreadyInRealm',
|
||||||
'crate::script_runtime::JSContext as SafeJSContext',
|
'crate::script_runtime::JSContext as SafeJSContext',
|
||||||
'libc',
|
'libc',
|
||||||
'servo_config::pref',
|
'servo_config::pref',
|
||||||
|
@ -6861,7 +6861,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, inCompartment=False):
|
def method_arguments(descriptorProvider, returnType, arguments, passJSBits=True, trailing=None, inRealm=False):
|
||||||
if needCx(returnType, arguments, passJSBits):
|
if needCx(returnType, arguments, passJSBits):
|
||||||
yield "cx", "SafeJSContext"
|
yield "cx", "SafeJSContext"
|
||||||
|
|
||||||
|
@ -6873,8 +6873,8 @@ def method_arguments(descriptorProvider, returnType, arguments, passJSBits=True,
|
||||||
if trailing:
|
if trailing:
|
||||||
yield trailing
|
yield trailing
|
||||||
|
|
||||||
if inCompartment:
|
if inRealm:
|
||||||
yield "_comp", "InCompartment"
|
yield "_comp", "InRealm"
|
||||||
|
|
||||||
|
|
||||||
def return_type(descriptorProvider, rettype, infallible):
|
def return_type(descriptorProvider, rettype, infallible):
|
||||||
|
|
|
@ -220,7 +220,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.inRealmMethods = [name for name in desc.get('inRealms', [])]
|
||||||
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
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
//! This module implements structured cloning, as defined by [HTML]
|
//! This module implements structured cloning, as defined by [HTML]
|
||||||
//! (https://html.spec.whatwg.org/multipage/#safe-passing-of-structured-data).
|
//! (https://html.spec.whatwg.org/multipage/#safe-passing-of-structured-data).
|
||||||
|
|
||||||
use crate::compartments::enter_realm;
|
|
||||||
use crate::dom::bindings::conversions::{root_from_object, ToJSValConvertible};
|
use crate::dom::bindings::conversions::{root_from_object, ToJSValConvertible};
|
||||||
use crate::dom::bindings::error::{Error, Fallible};
|
use crate::dom::bindings::error::{Error, Fallible};
|
||||||
use crate::dom::bindings::reflector::DomObject;
|
use crate::dom::bindings::reflector::DomObject;
|
||||||
|
@ -15,6 +14,7 @@ use crate::dom::bindings::transferable::Transferable;
|
||||||
use crate::dom::blob::Blob;
|
use crate::dom::blob::Blob;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::messageport::MessagePort;
|
use crate::dom::messageport::MessagePort;
|
||||||
|
use crate::realms::enter_realm;
|
||||||
use crate::script_runtime::JSContext as SafeJSContext;
|
use crate::script_runtime::JSContext as SafeJSContext;
|
||||||
use js::glue::CopyJSStructuredCloneData;
|
use js::glue::CopyJSStructuredCloneData;
|
||||||
use js::glue::DeleteJSAutoStructuredCloneBuffer;
|
use js::glue::DeleteJSAutoStructuredCloneBuffer;
|
||||||
|
|
|
@ -7,7 +7,7 @@ use bluetooth_traits::{BluetoothResponse, BluetoothResponseResult};
|
||||||
use bluetooth_traits::blocklist::{Blocklist, uuid_is_blocklisted};
|
use bluetooth_traits::blocklist::{Blocklist, uuid_is_blocklisted};
|
||||||
use bluetooth_traits::scanfilter::{BluetoothScanfilter, BluetoothScanfilterSequence};
|
use bluetooth_traits::scanfilter::{BluetoothScanfilter, BluetoothScanfilterSequence};
|
||||||
use bluetooth_traits::scanfilter::{RequestDeviceoptions, ServiceUUIDSequence};
|
use bluetooth_traits::scanfilter::{RequestDeviceoptions, ServiceUUIDSequence};
|
||||||
use crate::compartments::{AlreadyInCompartment, InCompartment};
|
use crate::realms::{AlreadyInRealm, InRealm};
|
||||||
use crate::dom::bindings::cell::{DomRefCell, Ref};
|
use crate::dom::bindings::cell::{DomRefCell, Ref};
|
||||||
use crate::dom::bindings::codegen::Bindings::BluetoothBinding::{self, BluetoothDataFilterInit};
|
use crate::dom::bindings::codegen::Bindings::BluetoothBinding::{self, BluetoothDataFilterInit};
|
||||||
use crate::dom::bindings::codegen::Bindings::BluetoothBinding::{BluetoothMethods, RequestDeviceOptions};
|
use crate::dom::bindings::codegen::Bindings::BluetoothBinding::{BluetoothMethods, RequestDeviceOptions};
|
||||||
|
@ -291,11 +291,8 @@ where
|
||||||
T: AsyncBluetoothListener + DomObject + 'static,
|
T: AsyncBluetoothListener + DomObject + 'static,
|
||||||
F: FnOnce(StringOrUnsignedLong) -> Fallible<UUID>,
|
F: FnOnce(StringOrUnsignedLong) -> Fallible<UUID>,
|
||||||
{
|
{
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&attribute.global());
|
let in_realm_proof = AlreadyInRealm::assert(&attribute.global());
|
||||||
let p = Promise::new_in_current_compartment(
|
let p = Promise::new_in_current_realm(&attribute.global(), InRealm::Already(&in_realm_proof));
|
||||||
&attribute.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
|
|
||||||
let result_uuid = if let Some(u) = uuid {
|
let result_uuid = if let Some(u) = uuid {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
|
@ -534,8 +531,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, comp: InCompartment) -> Rc<Promise> {
|
fn RequestDevice(&self, option: &RequestDeviceOptions, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
let p = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
// 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)
|
||||||
|
@ -552,8 +549,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, comp: InCompartment) -> Rc<Promise> {
|
fn GetAvailability(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
let p = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
// 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,6 @@
|
||||||
* 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::BluetoothDeviceBinding;
|
use crate::dom::bindings::codegen::Bindings::BluetoothDeviceBinding;
|
||||||
use crate::dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods;
|
use crate::dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods;
|
||||||
|
@ -22,6 +21,7 @@ use crate::dom::bluetoothremotegattservice::BluetoothRemoteGATTService;
|
||||||
use crate::dom::eventtarget::EventTarget;
|
use crate::dom::eventtarget::EventTarget;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
|
use crate::realms::InRealm;
|
||||||
use bluetooth_traits::{BluetoothCharacteristicMsg, BluetoothDescriptorMsg};
|
use bluetooth_traits::{BluetoothCharacteristicMsg, BluetoothDescriptorMsg};
|
||||||
use bluetooth_traits::{BluetoothRequest, BluetoothResponse, BluetoothServiceMsg};
|
use bluetooth_traits::{BluetoothRequest, BluetoothResponse, BluetoothServiceMsg};
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -278,8 +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, comp: InCompartment) -> Rc<Promise> {
|
fn WatchAdvertisements(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
let p = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
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,6 @@
|
||||||
* 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::BluetoothCharacteristicPropertiesBinding::BluetoothCharacteristicPropertiesMethods;
|
use crate::dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding::BluetoothCharacteristicPropertiesMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding;
|
use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding;
|
||||||
|
@ -24,6 +23,7 @@ use crate::dom::bluetoothuuid::{BluetoothDescriptorUUID, BluetoothUUID};
|
||||||
use crate::dom::eventtarget::EventTarget;
|
use crate::dom::eventtarget::EventTarget;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
|
use crate::realms::InRealm;
|
||||||
use bluetooth_traits::blocklist::{uuid_is_blocklisted, Blocklist};
|
use bluetooth_traits::blocklist::{uuid_is_blocklisted, Blocklist};
|
||||||
use bluetooth_traits::{BluetoothRequest, BluetoothResponse, GATTType};
|
use bluetooth_traits::{BluetoothRequest, BluetoothResponse, GATTType};
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -138,8 +138,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, comp: InCompartment) -> Rc<Promise> {
|
fn ReadValue(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
let p = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
|
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Reads) {
|
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Reads) {
|
||||||
|
@ -171,8 +171,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, comp: InCompartment) -> Rc<Promise> {
|
fn WriteValue(&self, value: ArrayBufferViewOrArrayBuffer, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
let p = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
|
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Writes) {
|
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Writes) {
|
||||||
|
@ -222,8 +222,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, comp: InCompartment) -> Rc<Promise> {
|
fn StartNotifications(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
let p = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
|
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Reads) {
|
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Reads) {
|
||||||
|
@ -259,8 +259,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, comp: InCompartment) -> Rc<Promise> {
|
fn StopNotifications(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
let p = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
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,6 @@
|
||||||
* 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::BluetoothRemoteGATTCharacteristicBinding::BluetoothRemoteGATTCharacteristicMethods;
|
use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding::BluetoothRemoteGATTCharacteristicMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTDescriptorBinding;
|
use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTDescriptorBinding;
|
||||||
|
@ -20,6 +19,7 @@ use crate::dom::bluetoothremotegattcharacteristic::{
|
||||||
};
|
};
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
|
use crate::realms::InRealm;
|
||||||
use bluetooth_traits::blocklist::{uuid_is_blocklisted, Blocklist};
|
use bluetooth_traits::blocklist::{uuid_is_blocklisted, Blocklist};
|
||||||
use bluetooth_traits::{BluetoothRequest, BluetoothResponse};
|
use bluetooth_traits::{BluetoothRequest, BluetoothResponse};
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -94,8 +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, comp: InCompartment) -> Rc<Promise> {
|
fn ReadValue(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
let p = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
|
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Reads) {
|
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Reads) {
|
||||||
|
@ -126,8 +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, comp: InCompartment) -> Rc<Promise> {
|
fn WriteValue(&self, value: ArrayBufferViewOrArrayBuffer, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
let p = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
|
|
||||||
// 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,6 @@
|
||||||
* 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::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;
|
||||||
|
@ -15,6 +14,7 @@ use crate::dom::bluetoothdevice::BluetoothDevice;
|
||||||
use crate::dom::bluetoothuuid::{BluetoothServiceUUID, BluetoothUUID};
|
use crate::dom::bluetoothuuid::{BluetoothServiceUUID, BluetoothUUID};
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
|
use crate::realms::InRealm;
|
||||||
use bluetooth_traits::{BluetoothRequest, BluetoothResponse, GATTType};
|
use bluetooth_traits::{BluetoothRequest, BluetoothResponse, GATTType};
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use ipc_channel::ipc::IpcSender;
|
use ipc_channel::ipc::IpcSender;
|
||||||
|
@ -71,9 +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, comp: InCompartment) -> Rc<Promise> {
|
fn Connect(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
let p = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
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,6 @@
|
||||||
* 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::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;
|
||||||
|
@ -31,6 +30,7 @@ use crate::dom::node::{document_from_node, window_from_node, Node, ShadowIncludi
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use crate::microtask::Microtask;
|
use crate::microtask::Microtask;
|
||||||
|
use crate::realms::InRealm;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::JSContext;
|
||||||
use crate::script_thread::ScriptThread;
|
use crate::script_thread::ScriptThread;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -417,20 +417,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, comp: InCompartment) -> Rc<Promise> {
|
fn WhenDefined(&self, name: DOMString, comp: InRealm) -> 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 promise = Promise::new_in_current_compartment(&global_scope, comp);
|
let promise = Promise::new_in_current_realm(&global_scope, comp);
|
||||||
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 promise = Promise::new_in_current_compartment(&global_scope, comp);
|
let promise = Promise::new_in_current_realm(&global_scope, comp);
|
||||||
promise.resolve_native(&UndefinedValue());
|
promise.resolve_native(&UndefinedValue());
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
@ -440,7 +440,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 promise = Promise::new_in_current_compartment(&global_scope, comp);
|
let promise = Promise::new_in_current_realm(&global_scope, comp);
|
||||||
map.insert(name, promise.clone());
|
map.insert(name, promise.clone());
|
||||||
promise
|
promise
|
||||||
});
|
});
|
||||||
|
@ -535,7 +535,7 @@ impl CustomElementDefinition {
|
||||||
rooted!(in(*cx) let constructor = ObjectValue(self.constructor.callback()));
|
rooted!(in(*cx) let constructor = ObjectValue(self.constructor.callback()));
|
||||||
rooted!(in(*cx) let mut element = ptr::null_mut::<JSObject>());
|
rooted!(in(*cx) let mut element = ptr::null_mut::<JSObject>());
|
||||||
{
|
{
|
||||||
// Go into the constructor's compartment
|
// Go into the constructor's realm
|
||||||
let _ac = JSAutoRealm::new(*cx, self.constructor.callback());
|
let _ac = JSAutoRealm::new(*cx, self.constructor.callback());
|
||||||
let args = HandleValueArray::new();
|
let args = HandleValueArray::new();
|
||||||
if unsafe { !Construct1(*cx, constructor.handle(), &args, element.handle_mut()) } {
|
if unsafe { !Construct1(*cx, constructor.handle(), &args, element.handle_mut()) } {
|
||||||
|
@ -676,7 +676,7 @@ fn run_upgrade_constructor(
|
||||||
{
|
{
|
||||||
// Step 8.1 TODO when shadow DOM exists
|
// Step 8.1 TODO when shadow DOM exists
|
||||||
|
|
||||||
// Go into the constructor's compartment
|
// Go into the constructor's realm
|
||||||
let _ac = JSAutoRealm::new(*cx, constructor.callback());
|
let _ac = JSAutoRealm::new(*cx, constructor.callback());
|
||||||
let args = HandleValueArray::new();
|
let args = HandleValueArray::new();
|
||||||
// Step 8.2
|
// Step 8.2
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* 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::enter_realm;
|
|
||||||
use crate::devtools;
|
use crate::devtools;
|
||||||
use crate::dom::abstractworker::{SimpleWorkerErrorHandler, WorkerScriptMsg};
|
use crate::dom::abstractworker::{SimpleWorkerErrorHandler, WorkerScriptMsg};
|
||||||
use crate::dom::abstractworkerglobalscope::{run_worker_event_loop, WorkerEventLoopMethods};
|
use crate::dom::abstractworkerglobalscope::{run_worker_event_loop, WorkerEventLoopMethods};
|
||||||
|
@ -27,6 +26,7 @@ use crate::dom::messageevent::MessageEvent;
|
||||||
use crate::dom::worker::{TrustedWorkerAddress, Worker};
|
use crate::dom::worker::{TrustedWorkerAddress, Worker};
|
||||||
use crate::dom::workerglobalscope::WorkerGlobalScope;
|
use crate::dom::workerglobalscope::WorkerGlobalScope;
|
||||||
use crate::fetch::load_whole_resource;
|
use crate::fetch::load_whole_resource;
|
||||||
|
use crate::realms::enter_realm;
|
||||||
use crate::script_runtime::ScriptThreadEventCategory::WorkerEvent;
|
use crate::script_runtime::ScriptThreadEventCategory::WorkerEvent;
|
||||||
use crate::script_runtime::{
|
use crate::script_runtime::{
|
||||||
new_child_runtime, CommonScriptMsg, JSContext as SafeJSContext, Runtime, ScriptChan, ScriptPort,
|
new_child_runtime, CommonScriptMsg, JSContext as SafeJSContext, Runtime, ScriptChan, ScriptPort,
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* 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::document_loader::{DocumentLoader, LoadType};
|
use crate::document_loader::{DocumentLoader, LoadType};
|
||||||
use crate::dom::activation::{synthetic_click_activation, ActivationSource};
|
use crate::dom::activation::{synthetic_click_activation, ActivationSource};
|
||||||
use crate::dom::attr::Attr;
|
use crate::dom::attr::Attr;
|
||||||
|
@ -97,6 +96,7 @@ use crate::dom::wheelevent::WheelEvent;
|
||||||
use crate::dom::window::{ReflowReason, Window};
|
use crate::dom::window::{ReflowReason, Window};
|
||||||
use crate::dom::windowproxy::WindowProxy;
|
use crate::dom::windowproxy::WindowProxy;
|
||||||
use crate::fetch::FetchCanceller;
|
use crate::fetch::FetchCanceller;
|
||||||
|
use crate::realms::{AlreadyInRealm, InRealm};
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::JSContext;
|
||||||
use crate::script_runtime::{CommonScriptMsg, ScriptThreadEventCategory};
|
use crate::script_runtime::{CommonScriptMsg, ScriptThreadEventCategory};
|
||||||
use crate::script_thread::{MainThreadScriptMsg, ScriptThread};
|
use crate::script_thread::{MainThreadScriptMsg, ScriptThread};
|
||||||
|
@ -3170,11 +3170,9 @@ impl Document {
|
||||||
// https://fullscreen.spec.whatwg.org/#dom-element-requestfullscreen
|
// https://fullscreen.spec.whatwg.org/#dom-element-requestfullscreen
|
||||||
pub fn enter_fullscreen(&self, pending: &Element) -> Rc<Promise> {
|
pub fn enter_fullscreen(&self, pending: &Element) -> Rc<Promise> {
|
||||||
// Step 1
|
// Step 1
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let in_realm_proof = AlreadyInRealm::assert(&self.global());
|
||||||
let promise = Promise::new_in_current_compartment(
|
let promise =
|
||||||
&self.global(),
|
Promise::new_in_current_realm(&self.global(), InRealm::Already(&in_realm_proof));
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
let mut error = false;
|
let mut error = false;
|
||||||
|
|
||||||
// Step 4
|
// Step 4
|
||||||
|
@ -3241,11 +3239,8 @@ impl Document {
|
||||||
pub fn exit_fullscreen(&self) -> Rc<Promise> {
|
pub fn exit_fullscreen(&self) -> Rc<Promise> {
|
||||||
let global = self.global();
|
let global = self.global();
|
||||||
// Step 1
|
// Step 1
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&global);
|
let in_realm_proof = AlreadyInRealm::assert(&global);
|
||||||
let promise = Promise::new_in_current_compartment(
|
let promise = Promise::new_in_current_realm(&global, InRealm::Already(&in_realm_proof));
|
||||||
&global,
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
);
|
|
||||||
// Step 2
|
// Step 2
|
||||||
if self.fullscreen_element.get().is_none() {
|
if self.fullscreen_element.get().is_none() {
|
||||||
promise.reject_error(Error::Type(String::from("fullscreen is null")));
|
promise.reject_error(Error::Type(String::from("fullscreen is null")));
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* 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::enter_realm;
|
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::EventSourceBinding::{
|
use crate::dom::bindings::codegen::Bindings::EventSourceBinding::{
|
||||||
EventSourceInit, EventSourceMethods, Wrap,
|
EventSourceInit, EventSourceMethods, Wrap,
|
||||||
|
@ -20,6 +19,7 @@ use crate::dom::messageevent::MessageEvent;
|
||||||
use crate::dom::performanceresourcetiming::InitiatorType;
|
use crate::dom::performanceresourcetiming::InitiatorType;
|
||||||
use crate::fetch::{create_a_potential_cors_request, FetchCanceller};
|
use crate::fetch::{create_a_potential_cors_request, FetchCanceller};
|
||||||
use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingListener};
|
use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingListener};
|
||||||
|
use crate::realms::enter_realm;
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
use crate::task_source::{TaskSource, TaskSourceName};
|
||||||
use crate::timers::OneshotTimerCallback;
|
use crate::timers::OneshotTimerCallback;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* 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::enter_realm;
|
|
||||||
use crate::dom::beforeunloadevent::BeforeUnloadEvent;
|
use crate::dom::beforeunloadevent::BeforeUnloadEvent;
|
||||||
use crate::dom::bindings::callback::{CallbackContainer, CallbackFunction, ExceptionHandling};
|
use crate::dom::bindings::callback::{CallbackContainer, CallbackFunction, ExceptionHandling};
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
|
@ -34,6 +33,7 @@ use crate::dom::htmlformelement::FormControlElementHelpers;
|
||||||
use crate::dom::node::document_from_node;
|
use crate::dom::node::document_from_node;
|
||||||
use crate::dom::virtualmethods::VirtualMethods;
|
use crate::dom::virtualmethods::VirtualMethods;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::realms::enter_realm;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use fnv::FnvHasher;
|
use fnv::FnvHasher;
|
||||||
use js::jsapi::{JSAutoRealm, JSFunction, JS_GetFunctionObject, SourceText};
|
use js::jsapi::{JSAutoRealm, JSFunction, JS_GetFunctionObject, SourceText};
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* 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::enter_realm;
|
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::BlobBinding::BlobMethods;
|
use crate::dom::bindings::codegen::Bindings::BlobBinding::BlobMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::FileReaderBinding::{
|
use crate::dom::bindings::codegen::Bindings::FileReaderBinding::{
|
||||||
|
@ -22,6 +21,7 @@ use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
use crate::dom::eventtarget::EventTarget;
|
use crate::dom::eventtarget::EventTarget;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::progressevent::ProgressEvent;
|
use crate::dom::progressevent::ProgressEvent;
|
||||||
|
use crate::realms::enter_realm;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::JSContext;
|
||||||
use crate::task_source::file_reading::FileReadingTask;
|
use crate::task_source::file_reading::FileReadingTask;
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
use crate::task_source::{TaskSource, TaskSourceName};
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* 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::codegen::Bindings::GPUBinding::GPURequestAdapterOptions;
|
use crate::dom::bindings::codegen::Bindings::GPUBinding::GPURequestAdapterOptions;
|
||||||
use crate::dom::bindings::codegen::Bindings::GPUBinding::{self, GPUMethods, GPUPowerPreference};
|
use crate::dom::bindings::codegen::Bindings::GPUBinding::{self, GPUMethods, GPUPowerPreference};
|
||||||
use crate::dom::bindings::error::Error;
|
use crate::dom::bindings::error::Error;
|
||||||
|
@ -13,6 +12,7 @@ use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::gpuadapter::GPUAdapter;
|
use crate::dom::gpuadapter::GPUAdapter;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
|
use crate::realms::InRealm;
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
use crate::task_source::{TaskSource, TaskSourceName};
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use ipc_channel::ipc::{self, IpcSender};
|
use ipc_channel::ipc::{self, IpcSender};
|
||||||
|
@ -104,13 +104,9 @@ pub fn response_async<T: AsyncWGPUListener + DomObject + 'static>(
|
||||||
|
|
||||||
impl GPUMethods for GPU {
|
impl GPUMethods for GPU {
|
||||||
// https://gpuweb.github.io/gpuweb/#dom-gpu-requestadapter
|
// https://gpuweb.github.io/gpuweb/#dom-gpu-requestadapter
|
||||||
fn RequestAdapter(
|
fn RequestAdapter(&self, options: &GPURequestAdapterOptions, comp: InRealm) -> Rc<Promise> {
|
||||||
&self,
|
|
||||||
options: &GPURequestAdapterOptions,
|
|
||||||
comp: InCompartment,
|
|
||||||
) -> Rc<Promise> {
|
|
||||||
let global = &self.global();
|
let global = &self.global();
|
||||||
let promise = Promise::new_in_current_compartment(global, comp);
|
let promise = Promise::new_in_current_realm(global, comp);
|
||||||
let sender = response_async(&promise, self);
|
let sender = response_async(&promise, self);
|
||||||
let power_preference = match options.powerPreference {
|
let power_preference = match options.powerPreference {
|
||||||
Some(GPUPowerPreference::Low_power) => wgpu::instance::PowerPreference::LowPower,
|
Some(GPUPowerPreference::Low_power) => wgpu::instance::PowerPreference::LowPower,
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* 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::codegen::Bindings::GPUAdapterBinding::{
|
use crate::dom::bindings::codegen::Bindings::GPUAdapterBinding::{
|
||||||
self, GPUAdapterMethods, GPUDeviceDescriptor,
|
self, GPUAdapterMethods, GPUDeviceDescriptor,
|
||||||
};
|
};
|
||||||
|
@ -15,6 +14,7 @@ use crate::dom::gpu::response_async;
|
||||||
use crate::dom::gpu::AsyncWGPUListener;
|
use crate::dom::gpu::AsyncWGPUListener;
|
||||||
use crate::dom::gpudevice::GPUDevice;
|
use crate::dom::gpudevice::GPUDevice;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
|
use crate::realms::InRealm;
|
||||||
use crate::script_runtime::JSContext as SafeJSContext;
|
use crate::script_runtime::JSContext as SafeJSContext;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use js::jsapi::{Heap, JSObject};
|
use js::jsapi::{Heap, JSObject};
|
||||||
|
@ -78,8 +78,8 @@ impl GPUAdapterMethods for GPUAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://gpuweb.github.io/gpuweb/#dom-gpuadapter-requestdevice
|
/// https://gpuweb.github.io/gpuweb/#dom-gpuadapter-requestdevice
|
||||||
fn RequestDevice(&self, descriptor: &GPUDeviceDescriptor, comp: InCompartment) -> Rc<Promise> {
|
fn RequestDevice(&self, descriptor: &GPUDeviceDescriptor, comp: InRealm) -> Rc<Promise> {
|
||||||
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
let promise = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
let sender = response_async(&promise, self);
|
let sender = response_async(&promise, self);
|
||||||
let desc = wgpu::instance::DeviceDescriptor {
|
let desc = wgpu::instance::DeviceDescriptor {
|
||||||
extensions: wgpu::instance::Extensions {
|
extensions: wgpu::instance::Extensions {
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* 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::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;
|
||||||
|
@ -63,6 +62,7 @@ use crate::dom::virtualmethods::VirtualMethods;
|
||||||
use crate::fetch::{create_a_potential_cors_request, FetchCanceller};
|
use crate::fetch::{create_a_potential_cors_request, FetchCanceller};
|
||||||
use crate::microtask::{Microtask, MicrotaskRunnable};
|
use crate::microtask::{Microtask, MicrotaskRunnable};
|
||||||
use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingListener};
|
use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingListener};
|
||||||
|
use crate::realms::InRealm;
|
||||||
use crate::script_thread::ScriptThread;
|
use crate::script_thread::ScriptThread;
|
||||||
use crate::task_source::TaskSource;
|
use crate::task_source::TaskSource;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -2105,8 +2105,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, comp: InCompartment) -> Rc<Promise> {
|
fn Play(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
let promise = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
// 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,6 @@
|
||||||
* 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::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;
|
||||||
|
@ -16,6 +15,7 @@ use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::mediastream::MediaStream;
|
use crate::dom::mediastream::MediaStream;
|
||||||
use crate::dom::mediastreamtrack::MediaStreamTrack;
|
use crate::dom::mediastreamtrack::MediaStreamTrack;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
|
use crate::realms::InRealm;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use servo_media::streams::capture::{Constrain, ConstrainRange, MediaTrackConstraintSet};
|
use servo_media::streams::capture::{Constrain, ConstrainRange, MediaTrackConstraintSet};
|
||||||
use servo_media::streams::MediaStreamType;
|
use servo_media::streams::MediaStreamType;
|
||||||
|
@ -46,12 +46,8 @@ 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(
|
fn GetUserMedia(&self, constraints: &MediaStreamConstraints, comp: InRealm) -> Rc<Promise> {
|
||||||
&self,
|
let p = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
constraints: &MediaStreamConstraints,
|
|
||||||
comp: InCompartment,
|
|
||||||
) -> 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,6 @@
|
||||||
* 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::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::HTMLMediaElementBinding::HTMLMediaElementMethods;
|
use crate::dom::bindings::codegen::Bindings::HTMLMediaElementBinding::HTMLMediaElementMethods;
|
||||||
|
@ -22,6 +21,7 @@ use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::htmlmediaelement::HTMLMediaElement;
|
use crate::dom::htmlmediaelement::HTMLMediaElement;
|
||||||
use crate::dom::mediametadata::MediaMetadata;
|
use crate::dom::mediametadata::MediaMetadata;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::realms::{AlreadyInRealm, InRealm};
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use embedder_traits::MediaMetadata as EmbedderMediaMetadata;
|
use embedder_traits::MediaMetadata as EmbedderMediaMetadata;
|
||||||
use embedder_traits::MediaSessionEvent;
|
use embedder_traits::MediaSessionEvent;
|
||||||
|
@ -85,8 +85,8 @@ impl MediaSession {
|
||||||
if let Some(media) = self.media_instance.get() {
|
if let Some(media) = self.media_instance.get() {
|
||||||
match action {
|
match action {
|
||||||
MediaSessionActionType::Play => {
|
MediaSessionActionType::Play => {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let in_realm_proof = AlreadyInRealm::assert(&self.global());
|
||||||
media.Play(InCompartment::Already(&in_compartment_proof));
|
media.Play(InRealm::Already(&in_realm_proof));
|
||||||
},
|
},
|
||||||
MediaSessionActionType::Pause => {
|
MediaSessionActionType::Pause => {
|
||||||
media.Pause();
|
media.Pause();
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* 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::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,
|
||||||
|
@ -14,6 +13,7 @@ use crate::dom::domexception::{DOMErrorName, DOMException};
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
use crate::dom::serviceworkerregistration::ServiceWorkerRegistration;
|
use crate::dom::serviceworkerregistration::ServiceWorkerRegistration;
|
||||||
|
use crate::realms::InRealm;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use js::jsval::UndefinedValue;
|
use js::jsval::UndefinedValue;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
@ -44,8 +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, comp: InCompartment) -> Rc<Promise> {
|
fn Enable(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let promise = Promise::new_in_current_compartment(&*self.global(), comp);
|
let promise = Promise::new_in_current_realm(&*self.global(), comp);
|
||||||
|
|
||||||
// 2.
|
// 2.
|
||||||
if self.serviceworker_registration.active().is_none() {
|
if self.serviceworker_registration.active().is_none() {
|
||||||
|
@ -66,8 +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, comp: InCompartment) -> Rc<Promise> {
|
fn Disable(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let promise = Promise::new_in_current_compartment(&*self.global(), comp);
|
let promise = Promise::new_in_current_realm(&*self.global(), comp);
|
||||||
|
|
||||||
// 2.
|
// 2.
|
||||||
if self.serviceworker_registration.active().is_none() {
|
if self.serviceworker_registration.active().is_none() {
|
||||||
|
@ -88,8 +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, comp: InCompartment) -> Rc<Promise> {
|
fn SetHeaderValue(&self, value: ByteString, comp: InRealm) -> Rc<Promise> {
|
||||||
let promise = Promise::new_in_current_compartment(&*self.global(), comp);
|
let promise = Promise::new_in_current_realm(&*self.global(), comp);
|
||||||
|
|
||||||
// 2.
|
// 2.
|
||||||
if self.serviceworker_registration.active().is_none() {
|
if self.serviceworker_registration.active().is_none() {
|
||||||
|
@ -110,8 +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, comp: InCompartment) -> Rc<Promise> {
|
fn GetState(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let promise = Promise::new_in_current_compartment(&*self.global(), comp);
|
let promise = Promise::new_in_current_realm(&*self.global(), comp);
|
||||||
// 2.
|
// 2.
|
||||||
let mut state = NavigationPreloadState::empty();
|
let mut state = NavigationPreloadState::empty();
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* 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::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;
|
||||||
|
@ -22,6 +21,7 @@ use crate::dom::promise::Promise;
|
||||||
use crate::dom::serviceworkercontainer::ServiceWorkerContainer;
|
use crate::dom::serviceworkercontainer::ServiceWorkerContainer;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use crate::dom::xr::XR;
|
use crate::dom::xr::XR;
|
||||||
|
use crate::realms::InRealm;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
@ -172,8 +172,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, comp: InCompartment) -> Rc<Promise> {
|
fn GetVRDisplays(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
let promise = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
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,6 @@
|
||||||
* 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::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};
|
||||||
|
@ -21,6 +20,7 @@ use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
use crate::dom::offlineaudiocompletionevent::OfflineAudioCompletionEvent;
|
use crate::dom::offlineaudiocompletionevent::OfflineAudioCompletionEvent;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::realms::InRealm;
|
||||||
use crate::task_source::TaskSource;
|
use crate::task_source::TaskSource;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
|
@ -127,8 +127,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, comp: InCompartment) -> Rc<Promise> {
|
fn StartRendering(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
let promise = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
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,6 @@
|
||||||
* 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::dom::bindings::codegen::Bindings::PermissionStatusBinding::PermissionDescriptor;
|
use crate::dom::bindings::codegen::Bindings::PermissionStatusBinding::PermissionDescriptor;
|
||||||
use crate::dom::bindings::codegen::Bindings::PermissionStatusBinding::PermissionStatusMethods;
|
use crate::dom::bindings::codegen::Bindings::PermissionStatusBinding::PermissionStatusMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::PermissionStatusBinding::{
|
use crate::dom::bindings::codegen::Bindings::PermissionStatusBinding::{
|
||||||
|
@ -17,6 +16,7 @@ use crate::dom::bluetoothpermissionresult::BluetoothPermissionResult;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::permissionstatus::PermissionStatus;
|
use crate::dom::permissionstatus::PermissionStatus;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
|
use crate::realms::{AlreadyInRealm, InRealm};
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::JSContext;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use js::conversions::ConversionResult;
|
use js::conversions::ConversionResult;
|
||||||
|
@ -97,11 +97,8 @@ impl Permissions {
|
||||||
let p = match promise {
|
let p = match promise {
|
||||||
Some(promise) => promise,
|
Some(promise) => promise,
|
||||||
None => {
|
None => {
|
||||||
let in_compartment_proof = AlreadyInCompartment::assert(&self.global());
|
let in_realm_proof = AlreadyInRealm::assert(&self.global());
|
||||||
Promise::new_in_current_compartment(
|
Promise::new_in_current_realm(&self.global(), InRealm::Already(&in_realm_proof))
|
||||||
&self.global(),
|
|
||||||
InCompartment::Already(&in_compartment_proof),
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,13 +11,13 @@
|
||||||
//! native Promise values that refer to the same JS value yet are distinct native objects
|
//! native Promise values that refer to the same JS value yet are distinct native objects
|
||||||
//! (ie. address equality for the native objects is meaningless).
|
//! (ie. address equality for the native objects is meaningless).
|
||||||
|
|
||||||
use crate::compartments::{enter_realm, InCompartment};
|
|
||||||
use crate::dom::bindings::conversions::root_from_object;
|
use crate::dom::bindings::conversions::root_from_object;
|
||||||
use crate::dom::bindings::error::{Error, Fallible};
|
use crate::dom::bindings::error::{Error, Fallible};
|
||||||
use crate::dom::bindings::reflector::{DomObject, MutDomObject, Reflector};
|
use crate::dom::bindings::reflector::{DomObject, MutDomObject, Reflector};
|
||||||
use crate::dom::bindings::utils::AsCCharPtrPtr;
|
use crate::dom::bindings::utils::AsCCharPtrPtr;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::promisenativehandler::PromiseNativeHandler;
|
use crate::dom::promisenativehandler::PromiseNativeHandler;
|
||||||
|
use crate::realms::{enter_realm, InRealm};
|
||||||
use crate::script_runtime::JSContext as SafeJSContext;
|
use crate::script_runtime::JSContext as SafeJSContext;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use js::conversions::ToJSValConvertible;
|
use js::conversions::ToJSValConvertible;
|
||||||
|
@ -83,12 +83,12 @@ impl Drop for Promise {
|
||||||
|
|
||||||
impl Promise {
|
impl Promise {
|
||||||
pub fn new(global: &GlobalScope) -> Rc<Promise> {
|
pub fn new(global: &GlobalScope) -> Rc<Promise> {
|
||||||
let compartment = enter_realm(&*global);
|
let realm = enter_realm(&*global);
|
||||||
let comp = InCompartment::Entered(&compartment);
|
let comp = InRealm::Entered(&realm);
|
||||||
Promise::new_in_current_compartment(global, comp)
|
Promise::new_in_current_realm(global, comp)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_in_current_compartment(global: &GlobalScope, _comp: InCompartment) -> Rc<Promise> {
|
pub fn new_in_current_realm(global: &GlobalScope, _comp: InRealm) -> Rc<Promise> {
|
||||||
let cx = global.get_cx();
|
let cx = global.get_cx();
|
||||||
rooted!(in(*cx) let mut obj = ptr::null_mut::<JSObject>());
|
rooted!(in(*cx) let mut obj = ptr::null_mut::<JSObject>());
|
||||||
Promise::create_js_promise(cx, HandleObject::null(), obj.handle_mut());
|
Promise::create_js_promise(cx, HandleObject::null(), obj.handle_mut());
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* 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::RTCIceCandidateBinding::RTCIceCandidateInit;
|
use crate::dom::bindings::codegen::Bindings::RTCIceCandidateBinding::RTCIceCandidateInit;
|
||||||
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding;
|
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding;
|
||||||
|
@ -33,6 +32,7 @@ use crate::dom::rtcpeerconnectioniceevent::RTCPeerConnectionIceEvent;
|
||||||
use crate::dom::rtcsessiondescription::RTCSessionDescription;
|
use crate::dom::rtcsessiondescription::RTCSessionDescription;
|
||||||
use crate::dom::rtctrackevent::RTCTrackEvent;
|
use crate::dom::rtctrackevent::RTCTrackEvent;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::realms::InRealm;
|
||||||
use crate::task::TaskCanceller;
|
use crate::task::TaskCanceller;
|
||||||
use crate::task_source::networking::NetworkingTaskSource;
|
use crate::task_source::networking::NetworkingTaskSource;
|
||||||
use crate::task_source::TaskSource;
|
use crate::task_source::TaskSource;
|
||||||
|
@ -454,8 +454,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, comp: InCompartment) -> Rc<Promise> {
|
fn AddIceCandidate(&self, candidate: &RTCIceCandidateInit, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
let p = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
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"
|
||||||
|
@ -489,8 +489,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, comp: InCompartment) -> Rc<Promise> {
|
fn CreateOffer(&self, _options: &RTCOfferOptions, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
let p = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
if self.closed.get() {
|
if self.closed.get() {
|
||||||
p.reject_error(Error::InvalidState);
|
p.reject_error(Error::InvalidState);
|
||||||
return p;
|
return p;
|
||||||
|
@ -501,8 +501,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, comp: InCompartment) -> Rc<Promise> {
|
fn CreateAnswer(&self, _options: &RTCAnswerOptions, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
let p = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
if self.closed.get() {
|
if self.closed.get() {
|
||||||
p.reject_error(Error::InvalidState);
|
p.reject_error(Error::InvalidState);
|
||||||
return p;
|
return p;
|
||||||
|
@ -523,13 +523,9 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-setlocaldescription
|
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-setlocaldescription
|
||||||
fn SetLocalDescription(
|
fn SetLocalDescription(&self, desc: &RTCSessionDescriptionInit, comp: InRealm) -> Rc<Promise> {
|
||||||
&self,
|
|
||||||
desc: &RTCSessionDescriptionInit,
|
|
||||||
comp: InCompartment,
|
|
||||||
) -> Rc<Promise> {
|
|
||||||
// XXXManishearth validate the current state
|
// XXXManishearth validate the current state
|
||||||
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
let p = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
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());
|
||||||
|
@ -560,13 +556,9 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-setremotedescription
|
/// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-setremotedescription
|
||||||
fn SetRemoteDescription(
|
fn SetRemoteDescription(&self, desc: &RTCSessionDescriptionInit, comp: InRealm) -> Rc<Promise> {
|
||||||
&self,
|
|
||||||
desc: &RTCSessionDescriptionInit,
|
|
||||||
comp: InCompartment,
|
|
||||||
) -> Rc<Promise> {
|
|
||||||
// XXXManishearth validate the current state
|
// XXXManishearth validate the current state
|
||||||
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
let p = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
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,6 @@
|
||||||
* 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::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,
|
||||||
|
@ -16,6 +15,7 @@ use crate::dom::eventtarget::EventTarget;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
use crate::dom::serviceworker::ServiceWorker;
|
use crate::dom::serviceworker::ServiceWorker;
|
||||||
|
use crate::realms::InRealm;
|
||||||
use crate::script_thread::ScriptThread;
|
use crate::script_thread::ScriptThread;
|
||||||
use crate::serviceworkerjob::{Job, JobType};
|
use crate::serviceworkerjob::{Job, JobType};
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -59,10 +59,10 @@ impl ServiceWorkerContainerMethods for ServiceWorkerContainer {
|
||||||
&self,
|
&self,
|
||||||
script_url: USVString,
|
script_url: USVString,
|
||||||
options: &RegistrationOptions,
|
options: &RegistrationOptions,
|
||||||
comp: InCompartment,
|
comp: InRealm,
|
||||||
) -> Rc<Promise> {
|
) -> Rc<Promise> {
|
||||||
// A: Step 1
|
// A: Step 1
|
||||||
let promise = Promise::new_in_current_compartment(&*self.global(), comp);
|
let promise = Promise::new_in_current_realm(&*self.global(), comp);
|
||||||
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
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* 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::enter_realm;
|
|
||||||
use crate::devtools;
|
use crate::devtools;
|
||||||
use crate::dom::abstractworker::WorkerScriptMsg;
|
use crate::dom::abstractworker::WorkerScriptMsg;
|
||||||
use crate::dom::abstractworkerglobalscope::{run_worker_event_loop, WorkerEventLoopMethods};
|
use crate::dom::abstractworkerglobalscope::{run_worker_event_loop, WorkerEventLoopMethods};
|
||||||
|
@ -23,6 +22,7 @@ use crate::dom::messageevent::MessageEvent;
|
||||||
use crate::dom::worker::TrustedWorkerAddress;
|
use crate::dom::worker::TrustedWorkerAddress;
|
||||||
use crate::dom::workerglobalscope::WorkerGlobalScope;
|
use crate::dom::workerglobalscope::WorkerGlobalScope;
|
||||||
use crate::fetch::load_whole_resource;
|
use crate::fetch::load_whole_resource;
|
||||||
|
use crate::realms::enter_realm;
|
||||||
use crate::script_runtime::{
|
use crate::script_runtime::{
|
||||||
new_rt_and_cx, CommonScriptMsg, JSContext as SafeJSContext, Runtime, ScriptChan,
|
new_rt_and_cx, CommonScriptMsg, JSContext as SafeJSContext, Runtime, ScriptChan,
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
// check-tidy: no specs after this line
|
// check-tidy: no specs after this line
|
||||||
|
|
||||||
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;
|
||||||
|
@ -49,6 +48,7 @@ use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
use crate::dom::promisenativehandler::{Callback, PromiseNativeHandler};
|
use crate::dom::promisenativehandler::{Callback, PromiseNativeHandler};
|
||||||
use crate::dom::url::URL;
|
use crate::dom::url::URL;
|
||||||
|
use crate::realms::InRealm;
|
||||||
use crate::script_runtime::JSContext as SafeJSContext;
|
use crate::script_runtime::JSContext as SafeJSContext;
|
||||||
use crate::timers::OneshotTimerCallback;
|
use crate::timers::OneshotTimerCallback;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -990,7 +990,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,
|
comp: InRealm,
|
||||||
) -> Rc<Promise> {
|
) -> Rc<Promise> {
|
||||||
let global = self.global();
|
let global = self.global();
|
||||||
let handler = PromiseNativeHandler::new(
|
let handler = PromiseNativeHandler::new(
|
||||||
|
@ -998,7 +998,7 @@ impl TestBindingMethods for TestBinding {
|
||||||
resolve.map(SimpleHandler::new),
|
resolve.map(SimpleHandler::new),
|
||||||
reject.map(SimpleHandler::new),
|
reject.map(SimpleHandler::new),
|
||||||
);
|
);
|
||||||
let p = Promise::new_in_current_compartment(&global, comp);
|
let p = Promise::new_in_current_realm(&global, comp);
|
||||||
p.append_native_handler(&handler);
|
p.append_native_handler(&handler);
|
||||||
return p;
|
return p;
|
||||||
|
|
||||||
|
@ -1021,8 +1021,8 @@ impl TestBindingMethods for TestBinding {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn PromiseAttribute(&self, comp: InCompartment) -> Rc<Promise> {
|
fn PromiseAttribute(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
Promise::new_in_current_compartment(&self.global(), comp)
|
Promise::new_in_current_realm(&self.global(), comp)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn AcceptPromise(&self, _promise: &Promise) {}
|
fn AcceptPromise(&self, _promise: &Promise) {}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* 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;
|
||||||
|
@ -18,6 +17,7 @@ use crate::dom::promise::Promise;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use crate::dom::worklet::Worklet;
|
use crate::dom::worklet::Worklet;
|
||||||
use crate::dom::workletglobalscope::WorkletGlobalScopeType;
|
use crate::dom::workletglobalscope::WorkletGlobalScopeType;
|
||||||
|
use crate::realms::InRealm;
|
||||||
use crate::script_thread::ScriptThread;
|
use crate::script_thread::ScriptThread;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
@ -57,7 +57,7 @@ impl TestWorkletMethods for TestWorklet {
|
||||||
&self,
|
&self,
|
||||||
moduleURL: USVString,
|
moduleURL: USVString,
|
||||||
options: &WorkletOptions,
|
options: &WorkletOptions,
|
||||||
comp: InCompartment,
|
comp: InRealm,
|
||||||
) -> Rc<Promise> {
|
) -> Rc<Promise> {
|
||||||
self.worklet.AddModule(moduleURL, options, comp)
|
self.worklet.AddModule(moduleURL, options, comp)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* 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::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;
|
||||||
|
@ -33,6 +32,7 @@ use crate::dom::vrframedata::VRFrameData;
|
||||||
use crate::dom::vrpose::VRPose;
|
use crate::dom::vrpose::VRPose;
|
||||||
use crate::dom::vrstageparameters::VRStageParameters;
|
use crate::dom::vrstageparameters::VRStageParameters;
|
||||||
use crate::dom::webglrenderingcontext::{WebGLMessageSender, WebGLRenderingContext};
|
use crate::dom::webglrenderingcontext::{WebGLMessageSender, WebGLRenderingContext};
|
||||||
|
use crate::realms::InRealm;
|
||||||
use crate::script_runtime::CommonScriptMsg;
|
use crate::script_runtime::CommonScriptMsg;
|
||||||
use crate::script_runtime::ScriptThreadEventCategory::WebVREvent;
|
use crate::script_runtime::ScriptThreadEventCategory::WebVREvent;
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
use crate::task_source::{TaskSource, TaskSourceName};
|
||||||
|
@ -322,8 +322,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>, comp: InCompartment) -> Rc<Promise> {
|
fn RequestPresent(&self, layers: Vec<VRLayer>, comp: InRealm) -> Rc<Promise> {
|
||||||
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
let promise = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
// 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
|
||||||
|
@ -386,8 +386,8 @@ impl VRDisplayMethods for VRDisplay {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/webvr/#dom-vrdisplay-exitpresent
|
// https://w3c.github.io/webvr/#dom-vrdisplay-exitpresent
|
||||||
fn ExitPresent(&self, comp: InCompartment) -> Rc<Promise> {
|
fn ExitPresent(&self, comp: InRealm) -> Rc<Promise> {
|
||||||
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
let promise = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
|
|
||||||
// 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,7 +2,6 @@
|
||||||
* 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,
|
||||||
|
@ -57,6 +56,7 @@ use crate::dom::workletglobalscope::WorkletGlobalScopeType;
|
||||||
use crate::fetch;
|
use crate::fetch;
|
||||||
use crate::layout_image::fetch_image_for_layout;
|
use crate::layout_image::fetch_image_for_layout;
|
||||||
use crate::microtask::MicrotaskQueue;
|
use crate::microtask::MicrotaskQueue;
|
||||||
|
use crate::realms::InRealm;
|
||||||
use crate::script_runtime::{
|
use crate::script_runtime::{
|
||||||
CommonScriptMsg, JSContext, Runtime, ScriptChan, ScriptPort, ScriptThreadEventCategory,
|
CommonScriptMsg, JSContext, Runtime, ScriptChan, ScriptPort, ScriptThreadEventCategory,
|
||||||
};
|
};
|
||||||
|
@ -1259,7 +1259,7 @@ impl WindowMethods for Window {
|
||||||
&self,
|
&self,
|
||||||
input: RequestOrUSVString,
|
input: RequestOrUSVString,
|
||||||
init: RootedTraceableBox<RequestInit>,
|
init: RootedTraceableBox<RequestInit>,
|
||||||
comp: InCompartment,
|
comp: InRealm,
|
||||||
) -> Rc<Promise> {
|
) -> Rc<Promise> {
|
||||||
fetch::Fetch(&self.upcast(), input, init, comp)
|
fetch::Fetch(&self.upcast(), input, init, comp)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* 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::enter_realm;
|
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::conversions::{root_from_handleobject, ToJSValConvertible};
|
use crate::dom::bindings::conversions::{root_from_handleobject, ToJSValConvertible};
|
||||||
use crate::dom::bindings::error::{throw_dom_exception, Error};
|
use crate::dom::bindings::error::{throw_dom_exception, Error};
|
||||||
|
@ -18,6 +17,7 @@ use crate::dom::document::Document;
|
||||||
use crate::dom::element::Element;
|
use crate::dom::element::Element;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
|
use crate::realms::enter_realm;
|
||||||
use crate::script_runtime::JSContext as SafeJSContext;
|
use crate::script_runtime::JSContext as SafeJSContext;
|
||||||
use crate::script_thread::ScriptThread;
|
use crate::script_thread::ScriptThread;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -586,10 +586,10 @@ impl WindowProxy {
|
||||||
|
|
||||||
// Brain transpant the window proxy.
|
// Brain transpant the window proxy.
|
||||||
// We need to do this, because the Window and WindowProxy
|
// We need to do this, because the Window and WindowProxy
|
||||||
// objects need to be in the same compartment.
|
// objects need to be in the same realm.
|
||||||
// JS_TransplantObject does this by copying the contents
|
// JS_TransplantObject does this by copying the contents
|
||||||
// of the old window proxy to the new window proxy, then
|
// of the old window proxy to the new window proxy, then
|
||||||
// making the old window proxy a cross-compartment wrapper
|
// making the old window proxy a cross-realm wrapper
|
||||||
// pointing to the new window proxy.
|
// pointing to the new window proxy.
|
||||||
rooted!(in(*cx) let new_js_proxy = NewWindowProxy(*cx, window_jsobject, handler));
|
rooted!(in(*cx) let new_js_proxy = NewWindowProxy(*cx, window_jsobject, handler));
|
||||||
debug!(
|
debug!(
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* 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::enter_realm;
|
|
||||||
use crate::dom::abstractworker::SimpleWorkerErrorHandler;
|
use crate::dom::abstractworker::SimpleWorkerErrorHandler;
|
||||||
use crate::dom::abstractworker::WorkerScriptMsg;
|
use crate::dom::abstractworker::WorkerScriptMsg;
|
||||||
use crate::dom::bindings::codegen::Bindings::MessagePortBinding::PostMessageOptions;
|
use crate::dom::bindings::codegen::Bindings::MessagePortBinding::PostMessageOptions;
|
||||||
|
@ -23,6 +22,7 @@ use crate::dom::eventtarget::EventTarget;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::messageevent::MessageEvent;
|
use crate::dom::messageevent::MessageEvent;
|
||||||
use crate::dom::workerglobalscope::prepare_workerscope_init;
|
use crate::dom::workerglobalscope::prepare_workerscope_init;
|
||||||
|
use crate::realms::enter_realm;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::JSContext;
|
||||||
use crate::task::TaskOnce;
|
use crate::task::TaskOnce;
|
||||||
use crossbeam_channel::{unbounded, Sender};
|
use crossbeam_channel::{unbounded, Sender};
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* 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, Ref};
|
use crate::dom::bindings::cell::{DomRefCell, Ref};
|
||||||
use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestInit;
|
use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestInit;
|
||||||
use crate::dom::bindings::codegen::Bindings::VoidFunctionBinding::VoidFunction;
|
use crate::dom::bindings::codegen::Bindings::VoidFunctionBinding::VoidFunction;
|
||||||
|
@ -26,6 +25,7 @@ use crate::dom::window::{base64_atob, base64_btoa};
|
||||||
use crate::dom::workerlocation::WorkerLocation;
|
use crate::dom::workerlocation::WorkerLocation;
|
||||||
use crate::dom::workernavigator::WorkerNavigator;
|
use crate::dom::workernavigator::WorkerNavigator;
|
||||||
use crate::fetch;
|
use crate::fetch;
|
||||||
|
use crate::realms::InRealm;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::JSContext;
|
||||||
use crate::script_runtime::{get_reports, CommonScriptMsg, Runtime, ScriptChan, ScriptPort};
|
use crate::script_runtime::{get_reports, CommonScriptMsg, Runtime, ScriptChan, ScriptPort};
|
||||||
use crate::task::TaskCanceller;
|
use crate::task::TaskCanceller;
|
||||||
|
@ -354,7 +354,7 @@ impl WorkerGlobalScopeMethods for WorkerGlobalScope {
|
||||||
&self,
|
&self,
|
||||||
input: RequestOrUSVString,
|
input: RequestOrUSVString,
|
||||||
init: RootedTraceableBox<RequestInit>,
|
init: RootedTraceableBox<RequestInit>,
|
||||||
comp: InCompartment,
|
comp: InRealm,
|
||||||
) -> Rc<Promise> {
|
) -> Rc<Promise> {
|
||||||
fetch::Fetch(self.upcast(), input, init, comp)
|
fetch::Fetch(self.upcast(), input, init, comp)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
//! 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::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;
|
||||||
|
@ -34,6 +33,7 @@ use crate::dom::workletglobalscope::WorkletGlobalScopeInit;
|
||||||
use crate::dom::workletglobalscope::WorkletGlobalScopeType;
|
use crate::dom::workletglobalscope::WorkletGlobalScopeType;
|
||||||
use crate::dom::workletglobalscope::WorkletTask;
|
use crate::dom::workletglobalscope::WorkletTask;
|
||||||
use crate::fetch::load_whole_resource;
|
use crate::fetch::load_whole_resource;
|
||||||
|
use crate::realms::InRealm;
|
||||||
use crate::script_runtime::new_rt_and_cx;
|
use crate::script_runtime::new_rt_and_cx;
|
||||||
use crate::script_runtime::CommonScriptMsg;
|
use crate::script_runtime::CommonScriptMsg;
|
||||||
use crate::script_runtime::Runtime;
|
use crate::script_runtime::Runtime;
|
||||||
|
@ -115,11 +115,11 @@ impl WorkletMethods for Worklet {
|
||||||
&self,
|
&self,
|
||||||
module_url: USVString,
|
module_url: USVString,
|
||||||
options: &WorkletOptions,
|
options: &WorkletOptions,
|
||||||
comp: InCompartment,
|
comp: InRealm,
|
||||||
) -> Rc<Promise> {
|
) -> Rc<Promise> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let global = self.window.upcast();
|
let global = self.window.upcast();
|
||||||
let promise = Promise::new_in_current_compartment(&global, comp);
|
let promise = Promise::new_in_current_realm(&global, comp);
|
||||||
|
|
||||||
// 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,6 @@
|
||||||
* 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::VRDisplayBinding::VRDisplayMethods;
|
use crate::dom::bindings::codegen::Bindings::VRDisplayBinding::VRDisplayMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::XRBinding;
|
use crate::dom::bindings::codegen::Bindings::XRBinding;
|
||||||
|
@ -25,6 +24,7 @@ use crate::dom::vrdisplay::VRDisplay;
|
||||||
use crate::dom::vrdisplayevent::VRDisplayEvent;
|
use crate::dom::vrdisplayevent::VRDisplayEvent;
|
||||||
use crate::dom::xrsession::XRSession;
|
use crate::dom::xrsession::XRSession;
|
||||||
use crate::dom::xrtest::XRTest;
|
use crate::dom::xrtest::XRTest;
|
||||||
|
use crate::realms::InRealm;
|
||||||
use crate::script_thread::ScriptThread;
|
use crate::script_thread::ScriptThread;
|
||||||
use crate::task_source::TaskSource;
|
use crate::task_source::TaskSource;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -161,11 +161,11 @@ impl XRMethods for XR {
|
||||||
&self,
|
&self,
|
||||||
mode: XRSessionMode,
|
mode: XRSessionMode,
|
||||||
init: RootedTraceableBox<XRSessionInit>,
|
init: RootedTraceableBox<XRSessionInit>,
|
||||||
comp: InCompartment,
|
comp: InRealm,
|
||||||
) -> Rc<Promise> {
|
) -> Rc<Promise> {
|
||||||
let global = self.global();
|
let global = self.global();
|
||||||
let window = global.as_window();
|
let window = global.as_window();
|
||||||
let promise = Promise::new_in_current_compartment(&global, comp);
|
let promise = Promise::new_in_current_realm(&global, comp);
|
||||||
|
|
||||||
if mode != XRSessionMode::Inline {
|
if mode != XRSessionMode::Inline {
|
||||||
if !ScriptThread::is_user_interacting() {
|
if !ScriptThread::is_user_interacting() {
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* 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::enter_realm;
|
|
||||||
use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding;
|
use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding;
|
||||||
use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding::{
|
use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding::{
|
||||||
XRHandedness, XRInputSourceMethods, XRTargetRayMode,
|
XRHandedness, XRInputSourceMethods, XRTargetRayMode,
|
||||||
|
@ -12,6 +11,7 @@ use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom};
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::xrsession::XRSession;
|
use crate::dom::xrsession::XRSession;
|
||||||
use crate::dom::xrspace::XRSpace;
|
use crate::dom::xrspace::XRSpace;
|
||||||
|
use crate::realms::enter_realm;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::JSContext;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use js::conversions::ToJSValConvertible;
|
use js::conversions::ToJSValConvertible;
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* 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::enter_realm;
|
|
||||||
use crate::dom::bindings::codegen::Bindings::EventBinding::EventBinding::EventMethods;
|
use crate::dom::bindings::codegen::Bindings::EventBinding::EventBinding::EventMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::XRInputSourcesChangeEventBinding::{
|
use crate::dom::bindings::codegen::Bindings::XRInputSourcesChangeEventBinding::{
|
||||||
self, XRInputSourcesChangeEventMethods,
|
self, XRInputSourcesChangeEventMethods,
|
||||||
|
@ -16,6 +15,7 @@ use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use crate::dom::xrinputsource::XRInputSource;
|
use crate::dom::xrinputsource::XRInputSource;
|
||||||
use crate::dom::xrsession::XRSession;
|
use crate::dom::xrsession::XRSession;
|
||||||
|
use crate::realms::enter_realm;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::JSContext;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use js::conversions::ToJSValConvertible;
|
use js::conversions::ToJSValConvertible;
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* 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::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::NavigatorBinding::NavigatorMethods;
|
use crate::dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorBinding::NavigatorMethods;
|
||||||
|
@ -38,6 +37,7 @@ use crate::dom::xrrenderstate::XRRenderState;
|
||||||
use crate::dom::xrsessionevent::XRSessionEvent;
|
use crate::dom::xrsessionevent::XRSessionEvent;
|
||||||
use crate::dom::xrspace::XRSpace;
|
use crate::dom::xrspace::XRSpace;
|
||||||
use crate::dom::xrwebgllayer::XRWebGLLayer;
|
use crate::dom::xrwebgllayer::XRWebGLLayer;
|
||||||
|
use crate::realms::InRealm;
|
||||||
use crate::task_source::TaskSource;
|
use crate::task_source::TaskSource;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use euclid::{Rect, RigidTransform3D, Transform3D};
|
use euclid::{Rect, RigidTransform3D, Transform3D};
|
||||||
|
@ -453,7 +453,7 @@ impl XRSessionMethods for XRSession {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://immersive-web.github.io/webxr/#dom-xrsession-updaterenderstate
|
/// https://immersive-web.github.io/webxr/#dom-xrsession-updaterenderstate
|
||||||
fn UpdateRenderState(&self, init: &XRRenderStateInit, _: InCompartment) -> ErrorResult {
|
fn UpdateRenderState(&self, init: &XRRenderStateInit, _: InRealm) -> ErrorResult {
|
||||||
// Step 2
|
// Step 2
|
||||||
if self.ended.get() {
|
if self.ended.get() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState);
|
||||||
|
@ -545,8 +545,8 @@ 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, ty: XRReferenceSpaceType, comp: InCompartment) -> Rc<Promise> {
|
fn RequestReferenceSpace(&self, ty: XRReferenceSpaceType, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_compartment(&self.global(), comp);
|
let p = Promise::new_in_current_realm(&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,6 @@
|
||||||
* 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::enter_realm;
|
|
||||||
use crate::dom::bindings::codegen::Bindings::XRViewBinding::XREye;
|
use crate::dom::bindings::codegen::Bindings::XRViewBinding::XREye;
|
||||||
use crate::dom::bindings::codegen::Bindings::XRViewerPoseBinding;
|
use crate::dom::bindings::codegen::Bindings::XRViewerPoseBinding;
|
||||||
use crate::dom::bindings::codegen::Bindings::XRViewerPoseBinding::XRViewerPoseMethods;
|
use crate::dom::bindings::codegen::Bindings::XRViewerPoseBinding::XRViewerPoseMethods;
|
||||||
|
@ -13,6 +12,7 @@ use crate::dom::xrpose::XRPose;
|
||||||
use crate::dom::xrrigidtransform::XRRigidTransform;
|
use crate::dom::xrrigidtransform::XRRigidTransform;
|
||||||
use crate::dom::xrsession::{cast_transform, ApiViewerPose, XRSession};
|
use crate::dom::xrsession::{cast_transform, ApiViewerPose, XRSession};
|
||||||
use crate::dom::xrview::XRView;
|
use crate::dom::xrview::XRView;
|
||||||
|
use crate::realms::enter_realm;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::JSContext;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use js::conversions::ToJSValConvertible;
|
use js::conversions::ToJSValConvertible;
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* 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::{enter_realm, 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;
|
||||||
|
@ -23,6 +22,7 @@ use crate::dom::serviceworkerglobalscope::ServiceWorkerGlobalScope;
|
||||||
use crate::network_listener::{
|
use crate::network_listener::{
|
||||||
self, submit_timing_data, NetworkListener, PreInvoke, ResourceTimingListener,
|
self, submit_timing_data, NetworkListener, PreInvoke, ResourceTimingListener,
|
||||||
};
|
};
|
||||||
|
use crate::realms::{enter_realm, InRealm};
|
||||||
use crate::task_source::TaskSourceName;
|
use crate::task_source::TaskSourceName;
|
||||||
use ipc_channel::ipc;
|
use ipc_channel::ipc;
|
||||||
use ipc_channel::router::ROUTER;
|
use ipc_channel::router::ROUTER;
|
||||||
|
@ -137,12 +137,12 @@ pub fn Fetch(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
input: RequestInfo,
|
input: RequestInfo,
|
||||||
init: RootedTraceableBox<RequestInit>,
|
init: RootedTraceableBox<RequestInit>,
|
||||||
comp: InCompartment,
|
comp: InRealm,
|
||||||
) -> 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 promise = Promise::new_in_current_compartment(global, comp);
|
let promise = Promise::new_in_current_realm(global, comp);
|
||||||
let response = Response::new(global);
|
let response = Response::new(global);
|
||||||
|
|
||||||
// Step 2
|
// Step 2
|
||||||
|
|
|
@ -64,8 +64,6 @@ pub mod document_loader;
|
||||||
mod dom;
|
mod dom;
|
||||||
#[warn(deprecated)]
|
#[warn(deprecated)]
|
||||||
mod canvas_state;
|
mod canvas_state;
|
||||||
#[warn(deprecated)]
|
|
||||||
mod compartments;
|
|
||||||
mod euclidext;
|
mod euclidext;
|
||||||
#[warn(deprecated)]
|
#[warn(deprecated)]
|
||||||
pub mod fetch;
|
pub mod fetch;
|
||||||
|
@ -82,6 +80,8 @@ mod microtask;
|
||||||
#[warn(deprecated)]
|
#[warn(deprecated)]
|
||||||
mod network_listener;
|
mod network_listener;
|
||||||
#[warn(deprecated)]
|
#[warn(deprecated)]
|
||||||
|
mod realms;
|
||||||
|
#[warn(deprecated)]
|
||||||
mod script_module;
|
mod script_module;
|
||||||
#[warn(deprecated)]
|
#[warn(deprecated)]
|
||||||
pub mod script_runtime;
|
pub mod script_runtime;
|
||||||
|
|
|
@ -7,38 +7,38 @@ use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::JSContext;
|
||||||
use js::jsapi::{GetCurrentRealmOrNull, JSAutoRealm};
|
use js::jsapi::{GetCurrentRealmOrNull, JSAutoRealm};
|
||||||
|
|
||||||
pub struct AlreadyInCompartment(());
|
pub struct AlreadyInRealm(());
|
||||||
|
|
||||||
impl AlreadyInCompartment {
|
impl AlreadyInRealm {
|
||||||
#![allow(unsafe_code)]
|
#![allow(unsafe_code)]
|
||||||
pub fn assert(global: &GlobalScope) -> AlreadyInCompartment {
|
pub fn assert(global: &GlobalScope) -> AlreadyInRealm {
|
||||||
unsafe {
|
unsafe {
|
||||||
assert!(!GetCurrentRealmOrNull(*global.get_cx()).is_null());
|
assert!(!GetCurrentRealmOrNull(*global.get_cx()).is_null());
|
||||||
}
|
}
|
||||||
AlreadyInCompartment(())
|
AlreadyInRealm(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn assert_for_cx(cx: JSContext) -> AlreadyInCompartment {
|
pub fn assert_for_cx(cx: JSContext) -> AlreadyInRealm {
|
||||||
unsafe {
|
unsafe {
|
||||||
assert!(!GetCurrentRealmOrNull(*cx).is_null());
|
assert!(!GetCurrentRealmOrNull(*cx).is_null());
|
||||||
}
|
}
|
||||||
AlreadyInCompartment(())
|
AlreadyInRealm(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub enum InCompartment<'a> {
|
pub enum InRealm<'a> {
|
||||||
Already(&'a AlreadyInCompartment),
|
Already(&'a AlreadyInRealm),
|
||||||
Entered(&'a JSAutoRealm),
|
Entered(&'a JSAutoRealm),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> InCompartment<'a> {
|
impl<'a> InRealm<'a> {
|
||||||
pub fn in_compartment(token: &AlreadyInCompartment) -> InCompartment {
|
pub fn in_realm(token: &AlreadyInRealm) -> InRealm {
|
||||||
InCompartment::Already(token)
|
InRealm::Already(token)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn entered(token: &JSAutoRealm) -> InCompartment {
|
pub fn entered(token: &JSAutoRealm) -> InRealm {
|
||||||
InCompartment::Entered(token)
|
InRealm::Entered(token)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
//! The script module mod contains common traits and structs
|
//! The script module mod contains common traits and structs
|
||||||
//! related to `type=module` for script thread or worker threads.
|
//! related to `type=module` for script thread or worker threads.
|
||||||
|
|
||||||
use crate::compartments::{enter_realm, AlreadyInCompartment, InCompartment};
|
|
||||||
use crate::document_loader::LoadType;
|
use crate::document_loader::LoadType;
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
|
use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
|
||||||
|
@ -32,6 +31,7 @@ use crate::dom::window::Window;
|
||||||
use crate::dom::worker::TrustedWorkerAddress;
|
use crate::dom::worker::TrustedWorkerAddress;
|
||||||
use crate::network_listener::{self, NetworkListener};
|
use crate::network_listener::{self, NetworkListener};
|
||||||
use crate::network_listener::{PreInvoke, ResourceTimingListener};
|
use crate::network_listener::{PreInvoke, ResourceTimingListener};
|
||||||
|
use crate::realms::{enter_realm, AlreadyInRealm, InRealm};
|
||||||
use crate::task::TaskBox;
|
use crate::task::TaskBox;
|
||||||
use crate::task_source::TaskSourceName;
|
use crate::task_source::TaskSourceName;
|
||||||
use encoding_rs::UTF_8;
|
use encoding_rs::UTF_8;
|
||||||
|
@ -325,8 +325,8 @@ impl ModuleTree {
|
||||||
))),
|
))),
|
||||||
);
|
);
|
||||||
|
|
||||||
let _compartment = enter_realm(&*owner.global());
|
let _realm = enter_realm(&*owner.global());
|
||||||
AlreadyInCompartment::assert(&*owner.global());
|
AlreadyInRealm::assert(&*owner.global());
|
||||||
let _ais = AutoIncumbentScript::new(&*owner.global());
|
let _ais = AutoIncumbentScript::new(&*owner.global());
|
||||||
|
|
||||||
let promise = promise.as_ref().unwrap();
|
let promise = promise.as_ref().unwrap();
|
||||||
|
@ -724,11 +724,11 @@ impl ModuleOwner {
|
||||||
))),
|
))),
|
||||||
);
|
);
|
||||||
|
|
||||||
let compartment = enter_realm(&*self.global());
|
let realm = enter_realm(&*self.global());
|
||||||
let comp = InCompartment::Entered(&compartment);
|
let comp = InRealm::Entered(&realm);
|
||||||
let _ais = AutoIncumbentScript::new(&*self.global());
|
let _ais = AutoIncumbentScript::new(&*self.global());
|
||||||
|
|
||||||
let promise = Promise::new_in_current_compartment(&self.global(), comp);
|
let promise = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
|
|
||||||
promise.append_native_handler(&handler);
|
promise.append_native_handler(&handler);
|
||||||
|
|
||||||
|
@ -1324,8 +1324,8 @@ fn fetch_module_descendants_and_link(
|
||||||
unsafe {
|
unsafe {
|
||||||
let global = owner.global();
|
let global = owner.global();
|
||||||
|
|
||||||
let _compartment = enter_realm(&*global);
|
let _realm = enter_realm(&*global);
|
||||||
AlreadyInCompartment::assert(&*global);
|
AlreadyInRealm::assert(&*global);
|
||||||
let _ais = AutoIncumbentScript::new(&*global);
|
let _ais = AutoIncumbentScript::new(&*global);
|
||||||
|
|
||||||
let abv = CreateAutoObjectVector(*global.get_cx());
|
let abv = CreateAutoObjectVector(*global.get_cx());
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
//! a page runs its course and the script thread returns to processing events in the main event
|
//! a page runs its course and the script thread returns to processing events in the main event
|
||||||
//! loop.
|
//! loop.
|
||||||
|
|
||||||
use crate::compartments::enter_realm;
|
|
||||||
use crate::devtools;
|
use crate::devtools;
|
||||||
use crate::document_loader::DocumentLoader;
|
use crate::document_loader::DocumentLoader;
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
|
@ -69,6 +68,7 @@ use crate::dom::worklet::WorkletThreadPool;
|
||||||
use crate::dom::workletglobalscope::WorkletGlobalScopeInit;
|
use crate::dom::workletglobalscope::WorkletGlobalScopeInit;
|
||||||
use crate::fetch::FetchCanceller;
|
use crate::fetch::FetchCanceller;
|
||||||
use crate::microtask::{Microtask, MicrotaskQueue};
|
use crate::microtask::{Microtask, MicrotaskQueue};
|
||||||
|
use crate::realms::enter_realm;
|
||||||
use crate::script_runtime::{get_reports, new_rt_and_cx, JSContext, Runtime, ScriptPort};
|
use crate::script_runtime::{get_reports, new_rt_and_cx, JSContext, Runtime, ScriptPort};
|
||||||
use crate::script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory};
|
use crate::script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory};
|
||||||
use crate::serviceworkerjob::{Job, JobQueue};
|
use crate::serviceworkerjob::{Job, JobQueue};
|
||||||
|
@ -701,7 +701,7 @@ pub struct ScriptThread {
|
||||||
/// In the event of thread panic, all data on the stack runs its destructor. However, there
|
/// In the event of thread panic, all data on the stack runs its destructor. However, there
|
||||||
/// are no reachable, owning pointers to the DOM memory, so it never gets freed by default
|
/// are no reachable, owning pointers to the DOM memory, so it never gets freed by default
|
||||||
/// when the script thread fails. The ScriptMemoryFailsafe uses the destructor bomb pattern
|
/// when the script thread fails. The ScriptMemoryFailsafe uses the destructor bomb pattern
|
||||||
/// to forcibly tear down the JS compartments for pages associated with the failing ScriptThread.
|
/// to forcibly tear down the JS realms for pages associated with the failing ScriptThread.
|
||||||
struct ScriptMemoryFailsafe<'a> {
|
struct ScriptMemoryFailsafe<'a> {
|
||||||
owner: Option<&'a ScriptThread>,
|
owner: Option<&'a ScriptThread>,
|
||||||
}
|
}
|
||||||
|
@ -2264,7 +2264,7 @@ impl ScriptThread {
|
||||||
warn!("resize sent to nonexistent pipeline");
|
warn!("resize sent to nonexistent pipeline");
|
||||||
}
|
}
|
||||||
|
|
||||||
// exit_fullscreen creates a new JS promise object, so we need to have entered a compartment
|
// exit_fullscreen creates a new JS promise object, so we need to have entered a realm
|
||||||
fn handle_exit_fullscreen(&self, id: PipelineId) {
|
fn handle_exit_fullscreen(&self, id: PipelineId) {
|
||||||
let document = self.documents.borrow().find_document(id);
|
let document = self.documents.borrow().find_document(id);
|
||||||
if let Some(document) = document {
|
if let Some(document) = document {
|
||||||
|
|
|
@ -62,7 +62,6 @@
|
||||||
"js.mem.gc.incremental.enabled": true,
|
"js.mem.gc.incremental.enabled": true,
|
||||||
"js.mem.gc.incremental.slice_ms": 10,
|
"js.mem.gc.incremental.slice_ms": 10,
|
||||||
"js.mem.gc.low_frequency_heap_growth": 150,
|
"js.mem.gc.low_frequency_heap_growth": 150,
|
||||||
"js.mem.gc.per_compartment.enabled": true,
|
|
||||||
"js.mem.gc.per_zone.enabled": false,
|
"js.mem.gc.per_zone.enabled": false,
|
||||||
"js.mem.gc.zeal.frequency": 100,
|
"js.mem.gc.zeal.frequency": 100,
|
||||||
"js.mem.gc.zeal.level": 0,
|
"js.mem.gc.zeal.level": 0,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue