aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_runtime.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/script_runtime.rs')
-rw-r--r--components/script/script_runtime.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/components/script/script_runtime.rs b/components/script/script_runtime.rs
index c44b4b04676..5ce21f01366 100644
--- a/components/script/script_runtime.rs
+++ b/components/script/script_runtime.rs
@@ -16,6 +16,7 @@ use crate::dom::bindings::conversions::private_from_object;
use crate::dom::bindings::conversions::root_from_handleobject;
use crate::dom::bindings::error::{throw_dom_exception, Error};
use crate::dom::bindings::inheritance::Castable;
+use crate::dom::bindings::principals;
use crate::dom::bindings::refcounted::{trace_refcounted_objects, LiveDOMReferences};
use crate::dom::bindings::refcounted::{Trusted, TrustedPromise};
use crate::dom::bindings::reflector::DomObject;
@@ -61,6 +62,7 @@ use js::jsapi::{
JSJitCompilerOption, JS_SetOffthreadIonCompilationEnabled, JS_SetParallelParsingEnabled,
};
use js::jsapi::{JSObject, PromiseRejectionHandlingState, SetPreserveWrapperCallbacks};
+use js::jsapi::{JSSecurityCallbacks, JS_InitDestroyPrincipalsCallback, JS_SetSecurityCallbacks};
use js::jsapi::{SetJobQueue, SetProcessBuildIdOp, SetPromiseRejectionTrackerCallback};
use js::jsval::UndefinedValue;
use js::panic::wrap_panic;
@@ -97,6 +99,12 @@ static JOB_QUEUE_TRAPS: JobQueueTraps = JobQueueTraps {
empty: Some(empty),
};
+static SECURITY_CALLBACKS: JSSecurityCallbacks = JSSecurityCallbacks {
+ // TODO: Content Security Policy <https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP>
+ contentSecurityPolicyAllows: None,
+ subsumes: Some(principals::subsumes),
+};
+
/// Common messages used to control the event loops in both the script and the worker
pub enum CommonScriptMsg {
/// Requests that the script thread measure its memory usage. The results are sent back via the
@@ -466,6 +474,10 @@ unsafe fn new_rt_and_cx_with_parent(
JS_AddExtraGCRootsTracer(cx, Some(trace_rust_roots), ptr::null_mut());
+ JS_SetSecurityCallbacks(cx, &SECURITY_CALLBACKS);
+
+ JS_InitDestroyPrincipalsCallback(cx, Some(principals::destroy_servo_jsprincipal));
+
// Needed for debug assertions about whether GC is running.
if cfg!(debug_assertions) {
JS_SetGCCallback(cx, Some(debug_gc_callback), ptr::null_mut());