mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Create a helper API for entering a DOM object's compartment
Revert some unnecessary changes Fix fmt errors
This commit is contained in:
parent
84786add22
commit
adb402487e
14 changed files with 45 additions and 50 deletions
|
@ -2,6 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::dom::bindings::reflector::DomObject;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use js::jsapi::{GetCurrentRealmOrNull, JSAutoRealm, JSContext};
|
||||
|
||||
|
@ -39,3 +40,10 @@ impl<'a> InCompartment<'a> {
|
|||
InCompartment::Entered(token)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn enter_realm(object: &impl DomObject) -> JSAutoRealm {
|
||||
JSAutoRealm::new(
|
||||
object.global().get_cx(),
|
||||
object.reflector().get_jsobject().get(),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::compartments::enter_realm;
|
||||
use crate::dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
||||
|
@ -9,7 +10,6 @@ use crate::dom::bindings::codegen::Bindings::ElementBinding::ElementMethods;
|
|||
use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||
use crate::dom::bindings::conversions::{jsstring_to_str, ConversionResult, FromJSValConvertible};
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::reflector::DomObject;
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::document::AnimationFrameCallback;
|
||||
|
@ -23,7 +23,6 @@ use devtools_traits::{AutoMargins, CachedConsoleMessage, CachedConsoleMessageTyp
|
|||
use devtools_traits::{ComputedNodeLayout, ConsoleAPI, PageError};
|
||||
use devtools_traits::{EvaluateJSReply, Modification, NodeInfo, TimelineMarker};
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use js::jsapi::JSAutoRealm;
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::wrappers::ObjectClassName;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
|
@ -36,8 +35,7 @@ pub fn handle_evaluate_js(global: &GlobalScope, eval: String, reply: IpcSender<E
|
|||
// global.get_cx() returns a valid `JSContext` pointer, so this is safe.
|
||||
let result = unsafe {
|
||||
let cx = global.get_cx();
|
||||
let globalhandle = global.reflector().get_jsobject();
|
||||
let _ac = JSAutoRealm::new(cx, globalhandle.get());
|
||||
let _ac = enter_realm(global);
|
||||
rooted!(in(cx) let mut rval = UndefinedValue());
|
||||
global.evaluate_js_on_global_with_result(&eval, rval.handle_mut());
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::compartments::enter_realm;
|
||||
use crate::dom::audionode::MAX_CHANNEL_COUNT;
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::AudioBufferBinding::{
|
||||
|
@ -14,7 +15,7 @@ use crate::dom::bindings::root::DomRoot;
|
|||
use crate::dom::window::Window;
|
||||
use dom_struct::dom_struct;
|
||||
use js::jsapi::JS_GetArrayBufferViewBuffer;
|
||||
use js::jsapi::{Heap, JSAutoRealm, JSContext, JSObject};
|
||||
use js::jsapi::{Heap, JSContext, JSObject};
|
||||
use js::rust::wrappers::DetachArrayBuffer;
|
||||
use js::rust::CustomAutoRooterGuard;
|
||||
use js::typedarray::{CreateWith, Float32Array};
|
||||
|
@ -126,8 +127,7 @@ impl AudioBuffer {
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn restore_js_channel_data(&self, cx: *mut JSContext) -> bool {
|
||||
let global = self.global();
|
||||
let _ac = JSAutoRealm::new(cx, global.reflector().get_jsobject().get());
|
||||
let _ac = enter_realm(&*self);
|
||||
for (i, channel) in self.js_channels.borrow_mut().iter().enumerate() {
|
||||
if !channel.get().is_null() {
|
||||
// Already have data in JS array.
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
//! This module implements structured cloning, as defined by [HTML]
|
||||
//! (https://html.spec.whatwg.org/multipage/#safe-passing-of-structured-data).
|
||||
|
||||
use crate::compartments::enter_realm;
|
||||
use crate::dom::bindings::conversions::root_from_handleobject;
|
||||
use crate::dom::bindings::error::{Error, Fallible};
|
||||
use crate::dom::bindings::reflector::DomObject;
|
||||
|
@ -18,11 +19,11 @@ use js::glue::NewJSAutoStructuredCloneBuffer;
|
|||
use js::glue::WriteBytesToJSStructuredCloneData;
|
||||
use js::jsapi::CloneDataPolicy;
|
||||
use js::jsapi::HandleObject as RawHandleObject;
|
||||
use js::jsapi::JSContext;
|
||||
use js::jsapi::MutableHandleObject as RawMutableHandleObject;
|
||||
use js::jsapi::StructuredCloneScope;
|
||||
use js::jsapi::TransferableOwnership;
|
||||
use js::jsapi::JS_STRUCTURED_CLONE_VERSION;
|
||||
use js::jsapi::{JSAutoRealm, JSContext};
|
||||
use js::jsapi::{JSObject, JS_ClearPendingException};
|
||||
use js::jsapi::{JSStructuredCloneCallbacks, JSStructuredCloneReader, JSStructuredCloneWriter};
|
||||
use js::jsapi::{JS_ReadBytes, JS_WriteBytes};
|
||||
|
@ -307,8 +308,7 @@ impl StructuredCloneData {
|
|||
/// Panics if `JS_ReadStructuredClone` fails.
|
||||
fn read_clone(global: &GlobalScope, data: *mut u64, nbytes: size_t, rval: MutableHandleValue) {
|
||||
let cx = global.get_cx();
|
||||
let globalhandle = global.reflector().get_jsobject();
|
||||
let _ac = JSAutoRealm::new(cx, globalhandle.get());
|
||||
let _ac = enter_realm(&*global);
|
||||
let mut sc_holder = StructuredCloneHolder { blob: None };
|
||||
let sc_holder_ptr = &mut sc_holder as *mut _;
|
||||
unsafe {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::compartments::enter_realm;
|
||||
use crate::devtools;
|
||||
use crate::dom::abstractworker::{SimpleWorkerErrorHandler, WorkerScriptMsg};
|
||||
use crate::dom::abstractworkerglobalscope::{run_worker_event_loop, WorkerEventLoopMethods};
|
||||
|
@ -33,8 +34,8 @@ use devtools_traits::DevtoolScriptControlMsg;
|
|||
use dom_struct::dom_struct;
|
||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||
use ipc_channel::router::ROUTER;
|
||||
use js::jsapi::JSContext;
|
||||
use js::jsapi::JS_AddInterruptCallback;
|
||||
use js::jsapi::{JSAutoRealm, JSContext};
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::HandleValue;
|
||||
use msg::constellation_msg::{PipelineId, TopLevelBrowsingContextId};
|
||||
|
@ -462,7 +463,7 @@ impl DedicatedWorkerGlobalScope {
|
|||
WorkerScriptMsg::DOMMessage(data) => {
|
||||
let scope = self.upcast::<WorkerGlobalScope>();
|
||||
let target = self.upcast();
|
||||
let _ac = JSAutoRealm::new(scope.get_cx(), scope.reflector().get_jsobject().get());
|
||||
let _ac = enter_realm(self);
|
||||
rooted!(in(scope.get_cx()) let mut message = UndefinedValue());
|
||||
data.read(scope.upcast(), message.handle_mut());
|
||||
MessageEvent::dispatch_jsval(target, scope.upcast(), message.handle(), None, None);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::compartments::enter_realm;
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::EventSourceBinding::{
|
||||
EventSourceInit, EventSourceMethods, Wrap,
|
||||
|
@ -28,7 +29,6 @@ use http::header::{self, HeaderName, HeaderValue};
|
|||
use ipc_channel::ipc;
|
||||
use ipc_channel::router::ROUTER;
|
||||
use js::conversions::ToJSValConvertible;
|
||||
use js::jsapi::JSAutoRealm;
|
||||
use js::jsval::UndefinedValue;
|
||||
use mime::{self, Mime};
|
||||
use net_traits::request::{CacheMode, CorsSettings, CredentialsMode};
|
||||
|
@ -222,10 +222,7 @@ impl EventSourceContext {
|
|||
};
|
||||
// Steps 4-5
|
||||
let event = {
|
||||
let _ac = JSAutoRealm::new(
|
||||
event_source.global().get_cx(),
|
||||
event_source.reflector().get_jsobject().get(),
|
||||
);
|
||||
let _ac = enter_realm(&*event_source);
|
||||
rooted!(in(event_source.global().get_cx()) let mut data = UndefinedValue());
|
||||
unsafe {
|
||||
self.data
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::compartments::enter_realm;
|
||||
use crate::dom::beforeunloadevent::BeforeUnloadEvent;
|
||||
use crate::dom::bindings::callback::{CallbackContainer, CallbackFunction, ExceptionHandling};
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
|
@ -506,7 +507,7 @@ impl EventTarget {
|
|||
|
||||
let scopechain = AutoObjectVectorWrapper::new(cx);
|
||||
|
||||
let _ac = JSAutoRealm::new(cx, window.reflector().get_jsobject().get());
|
||||
let _ac = enter_realm(&*window);
|
||||
rooted!(in(cx) let mut handler = ptr::null_mut::<JSFunction>());
|
||||
let rv = unsafe {
|
||||
CompileFunction(
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::compartments::enter_realm;
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::BlobBinding::BlobMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::FileReaderBinding::{
|
||||
|
@ -28,7 +29,6 @@ use base64;
|
|||
use dom_struct::dom_struct;
|
||||
use encoding_rs::{Encoding, UTF_8};
|
||||
use js::jsapi::Heap;
|
||||
use js::jsapi::JSAutoRealm;
|
||||
use js::jsapi::JSContext;
|
||||
use js::jsapi::JSObject;
|
||||
use js::jsval::{self, JSVal};
|
||||
|
@ -262,7 +262,7 @@ impl FileReader {
|
|||
FileReader::perform_readastext(&fr.result, data, &blob_contents)
|
||||
},
|
||||
FileReaderFunction::ReadAsArrayBuffer => {
|
||||
let _ac = JSAutoRealm::new(fr.global().get_cx(), *fr.reflector().get_jsobject());
|
||||
let _ac = enter_realm(&*fr);
|
||||
FileReader::perform_readasarraybuffer(
|
||||
&fr.result,
|
||||
fr.global().get_cx(),
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
//! native Promise values that refer to the same JS value yet are distinct native objects
|
||||
//! (ie. address equality for the native objects is meaningless).
|
||||
|
||||
use crate::compartments::InCompartment;
|
||||
use crate::compartments::{enter_realm, InCompartment};
|
||||
use crate::dom::bindings::conversions::root_from_object;
|
||||
use crate::dom::bindings::error::{Error, Fallible};
|
||||
use crate::dom::bindings::reflector::{DomObject, MutDomObject, Reflector};
|
||||
|
@ -81,8 +81,7 @@ impl Drop for Promise {
|
|||
|
||||
impl Promise {
|
||||
pub fn new(global: &GlobalScope) -> Rc<Promise> {
|
||||
let compartment =
|
||||
JSAutoRealm::new(global.get_cx(), global.reflector().get_jsobject().get());
|
||||
let compartment = enter_realm(&*global);
|
||||
let comp = InCompartment::Entered(&compartment);
|
||||
Promise::new_in_current_compartment(global, comp)
|
||||
}
|
||||
|
@ -166,7 +165,7 @@ impl Promise {
|
|||
T: ToJSValConvertible,
|
||||
{
|
||||
let cx = self.global().get_cx();
|
||||
let _ac = JSAutoRealm::new(cx, self.reflector().get_jsobject().get());
|
||||
let _ac = enter_realm(&*self);
|
||||
rooted!(in(cx) let mut v = UndefinedValue());
|
||||
unsafe {
|
||||
val.to_jsval(cx, v.handle_mut());
|
||||
|
@ -187,7 +186,7 @@ impl Promise {
|
|||
T: ToJSValConvertible,
|
||||
{
|
||||
let cx = self.global().get_cx();
|
||||
let _ac = JSAutoRealm::new(cx, self.reflector().get_jsobject().get());
|
||||
let _ac = enter_realm(&*self);
|
||||
rooted!(in(cx) let mut v = UndefinedValue());
|
||||
unsafe {
|
||||
val.to_jsval(cx, v.handle_mut());
|
||||
|
@ -198,7 +197,7 @@ impl Promise {
|
|||
#[allow(unsafe_code)]
|
||||
pub fn reject_error(&self, error: Error) {
|
||||
let cx = self.global().get_cx();
|
||||
let _ac = JSAutoRealm::new(cx, self.reflector().get_jsobject().get());
|
||||
let _ac = enter_realm(&*self);
|
||||
rooted!(in(cx) let mut v = UndefinedValue());
|
||||
unsafe {
|
||||
error.to_jsval(cx, &self.global(), v.handle_mut());
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::compartments::enter_realm;
|
||||
use crate::devtools;
|
||||
use crate::dom::abstractworker::WorkerScriptMsg;
|
||||
use crate::dom::abstractworkerglobalscope::{run_worker_event_loop, WorkerEventLoopMethods};
|
||||
|
@ -9,7 +10,6 @@ use crate::dom::bindings::codegen::Bindings::ServiceWorkerGlobalScopeBinding;
|
|||
use crate::dom::bindings::codegen::Bindings::ServiceWorkerGlobalScopeBinding::ServiceWorkerGlobalScopeMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::WorkerBinding::WorkerType;
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::reflector::DomObject;
|
||||
use crate::dom::bindings::root::{DomRoot, RootCollection, ThreadLocalStackRoots};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::dedicatedworkerglobalscope::AutoWorkerReset;
|
||||
|
@ -29,7 +29,7 @@ use devtools_traits::DevtoolScriptControlMsg;
|
|||
use dom_struct::dom_struct;
|
||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||
use ipc_channel::router::ROUTER;
|
||||
use js::jsapi::{JSAutoRealm, JSContext, JS_AddInterruptCallback};
|
||||
use js::jsapi::{JSContext, JS_AddInterruptCallback};
|
||||
use js::jsval::UndefinedValue;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use net_traits::request::{CredentialsMode, Destination, ParserMetadata, Referrer, RequestBuilder};
|
||||
|
@ -410,7 +410,7 @@ impl ServiceWorkerGlobalScope {
|
|||
CommonWorker(WorkerScriptMsg::DOMMessage(data)) => {
|
||||
let scope = self.upcast::<WorkerGlobalScope>();
|
||||
let target = self.upcast();
|
||||
let _ac = JSAutoRealm::new(scope.get_cx(), scope.reflector().get_jsobject().get());
|
||||
let _ac = enter_realm(&*scope);
|
||||
rooted!(in(scope.get_cx()) let mut message = UndefinedValue());
|
||||
data.read(scope.upcast(), message.handle_mut());
|
||||
ExtendableMessageEvent::dispatch_jsval(target, scope.upcast(), message.handle());
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::compartments::enter_realm;
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::conversions::{root_from_handleobject, ToJSValConvertible};
|
||||
use crate::dom::bindings::error::{throw_dom_exception, Error};
|
||||
|
@ -548,7 +549,7 @@ impl WindowProxy {
|
|||
((*get_object_class(window_jsobject.get())).flags & JSCLASS_IS_GLOBAL),
|
||||
0
|
||||
);
|
||||
let _ac = JSAutoRealm::new(cx, window_jsobject.get());
|
||||
let _ac = enter_realm(&*window);
|
||||
|
||||
// The old window proxy no longer owns this browsing context.
|
||||
SetProxyReservedSlot(old_js_proxy.get(), 0, &PrivateValue(ptr::null_mut()));
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::compartments::enter_realm;
|
||||
use crate::dom::abstractworker::SimpleWorkerErrorHandler;
|
||||
use crate::dom::abstractworker::WorkerScriptMsg;
|
||||
use crate::dom::bindings::codegen::Bindings::WorkerBinding;
|
||||
|
@ -25,7 +26,7 @@ use crossbeam_channel::{unbounded, Sender};
|
|||
use devtools_traits::{DevtoolsPageInfo, ScriptToDevtoolsControlMsg};
|
||||
use dom_struct::dom_struct;
|
||||
use ipc_channel::ipc;
|
||||
use js::jsapi::{JSAutoRealm, JSContext, JS_RequestInterruptCallback};
|
||||
use js::jsapi::{JSContext, JS_RequestInterruptCallback};
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::HandleValue;
|
||||
use script_traits::WorkerScriptLoadOrigin;
|
||||
|
@ -144,7 +145,7 @@ impl Worker {
|
|||
|
||||
let global = worker.global();
|
||||
let target = worker.upcast();
|
||||
let _ac = JSAutoRealm::new(global.get_cx(), target.reflector().get_jsobject().get());
|
||||
let _ac = enter_realm(target);
|
||||
rooted!(in(global.get_cx()) let mut message = UndefinedValue());
|
||||
data.read(&global, message.handle_mut());
|
||||
MessageEvent::dispatch_jsval(target, &global, message.handle(), None, None);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::compartments::InCompartment;
|
||||
use crate::compartments::{enter_realm, InCompartment};
|
||||
use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestInfo;
|
||||
use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestInit;
|
||||
use crate::dom::bindings::codegen::Bindings::ResponseBinding::ResponseBinding::ResponseMethods;
|
||||
|
@ -26,7 +26,6 @@ use crate::network_listener::{
|
|||
use crate::task_source::TaskSourceName;
|
||||
use ipc_channel::ipc;
|
||||
use ipc_channel::router::ROUTER;
|
||||
use js::jsapi::JSAutoRealm;
|
||||
use net_traits::request::RequestBuilder;
|
||||
use net_traits::request::{Request as NetTraitsRequest, ServiceWorkersMode};
|
||||
use net_traits::CoreResourceMsg::Fetch as NetTraitsFetch;
|
||||
|
@ -211,10 +210,7 @@ impl FetchResponseListener for FetchContext {
|
|||
.expect("fetch promise is missing")
|
||||
.root();
|
||||
|
||||
// JSAutoRealm needs to be manually made.
|
||||
// Otherwise, Servo will crash.
|
||||
let promise_cx = promise.global().get_cx();
|
||||
let _ac = JSAutoRealm::new(promise_cx, promise.reflector().get_jsobject().get());
|
||||
let _ac = enter_realm(&*promise);
|
||||
match fetch_metadata {
|
||||
// Step 4.1
|
||||
Err(_) => {
|
||||
|
@ -262,9 +258,7 @@ impl FetchResponseListener for FetchContext {
|
|||
|
||||
fn process_response_eof(&mut self, _response: Result<ResourceFetchTiming, NetworkError>) {
|
||||
let response = self.response_object.root();
|
||||
let global = response.global();
|
||||
let cx = global.get_cx();
|
||||
let _ac = JSAutoRealm::new(cx, global.reflector().get_jsobject().get());
|
||||
let _ac = enter_realm(&*response);
|
||||
response.finish(mem::replace(&mut self.body, vec![]));
|
||||
// TODO
|
||||
// ... trailerObject is not supported in Servo yet.
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
//! a page runs its course and the script thread returns to processing events in the main event
|
||||
//! loop.
|
||||
|
||||
use crate::compartments::enter_realm;
|
||||
use crate::devtools;
|
||||
use crate::document_loader::DocumentLoader;
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
|
@ -98,7 +99,7 @@ use hyper_serde::Serde;
|
|||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use ipc_channel::router::ROUTER;
|
||||
use js::glue::GetWindowProxyClass;
|
||||
use js::jsapi::{JSAutoRealm, JSContext, JS_SetWrapObjectCallbacks};
|
||||
use js::jsapi::{JSContext, JS_SetWrapObjectCallbacks};
|
||||
use js::jsapi::{JSTracer, SetWindowProxyClass};
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::ParentRuntime;
|
||||
|
@ -2054,10 +2055,7 @@ impl ScriptThread {
|
|||
fn handle_exit_fullscreen(&self, id: PipelineId) {
|
||||
let document = self.documents.borrow().find_document(id);
|
||||
if let Some(document) = document {
|
||||
let _ac = JSAutoRealm::new(
|
||||
document.global().get_cx(),
|
||||
document.reflector().get_jsobject().get(),
|
||||
);
|
||||
let _ac = enter_realm(&*document);
|
||||
document.exit_fullscreen();
|
||||
return;
|
||||
}
|
||||
|
@ -3397,10 +3395,7 @@ impl ScriptThread {
|
|||
let script_source = percent_decode(encoded.as_bytes()).decode_utf8_lossy();
|
||||
|
||||
// Script source is ready to be evaluated (11.)
|
||||
let _ac = JSAutoRealm::new(
|
||||
global_scope.get_cx(),
|
||||
global_scope.reflector().get_jsobject().get(),
|
||||
);
|
||||
let _ac = enter_realm(global_scope);
|
||||
rooted!(in(global_scope.get_cx()) let mut jsval = UndefinedValue());
|
||||
global_scope.evaluate_js_on_global_with_result(&script_source, jsval.handle_mut());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue