mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
fix: accommodate to the modern age
This commit is contained in:
parent
01a7de50ab
commit
28c670d6c3
3 changed files with 15 additions and 6 deletions
|
@ -10,8 +10,8 @@ use crate::dom::bindings::constant::{define_constants, ConstantSpec};
|
|||
use crate::dom::bindings::conversions::{get_dom_class, DOM_OBJECT_SLOT};
|
||||
use crate::dom::bindings::guard::Guard;
|
||||
use crate::dom::bindings::utils::{ProtoOrIfaceArray, DOM_PROTOTYPE_SLOT};
|
||||
use crate::dom::window::Window;
|
||||
use crate::script_runtime::JSContext as SafeJSContext;
|
||||
use dom::window::Window;
|
||||
use js::error::throw_type_error;
|
||||
use js::glue::UncheckedUnwrapObject;
|
||||
use js::jsapi::GetWellKnownSymbol;
|
||||
|
|
|
@ -16,7 +16,10 @@ use crate::dom::bindings::error::{throw_dom_exception, throw_invalid_this, Error
|
|||
use crate::dom::bindings::inheritance::TopTypeId;
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::bindings::trace::trace_object;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::windowproxy;
|
||||
use crate::realms::AlreadyInRealm;
|
||||
use crate::realms::InRealm;
|
||||
use crate::script_runtime::JSContext as SafeJSContext;
|
||||
use js::conversions::ToJSValConvertible;
|
||||
use js::glue::SetIsFrameIdCallback;
|
||||
|
@ -110,7 +113,7 @@ enum CrossOriginObjectType {
|
|||
CrossOriginOpaque,
|
||||
}
|
||||
|
||||
unsafe fn identify_cross_origin_object(obj: HandleObject) -> CrossOriginObjectType {
|
||||
unsafe fn identify_cross_origin_object(obj: RawHandleObject) -> CrossOriginObjectType {
|
||||
let obj = UncheckedUnwrapObject(obj.get(), /* stopAtWindowProxy = */ 0);
|
||||
let obj_class = JS_GetClass(obj);
|
||||
let name = str::from_utf8(CStr::from_ptr((*obj_class).name).to_bytes())
|
||||
|
@ -123,7 +126,7 @@ unsafe fn identify_cross_origin_object(obj: HandleObject) -> CrossOriginObjectTy
|
|||
}
|
||||
}
|
||||
|
||||
unsafe fn target_subsumes_obj(cx: *mut JSContext, obj: HandleObject) -> bool {
|
||||
unsafe fn target_subsumes_obj(cx: *mut JSContext, obj: RawHandleObject) -> bool {
|
||||
//step 1 get compartment
|
||||
let obj_c = get_object_compartment(obj.get());
|
||||
let ctx_c = get_context_compartment(cx);
|
||||
|
@ -166,7 +169,7 @@ pub unsafe extern "C" fn subsumes(obj: *mut JSPrincipals, other: *mut JSPrincipa
|
|||
obj_origin.same_origin_domain(&other_origin)
|
||||
}
|
||||
|
||||
unsafe fn select_wrapper(cx: *mut JSContext, obj: HandleObject) -> *const libc::c_void {
|
||||
unsafe fn select_wrapper(cx: *mut JSContext, obj: RawHandleObject) -> *const libc::c_void {
|
||||
let security_wrapper = !target_subsumes_obj(cx, obj);
|
||||
if !security_wrapper {
|
||||
return GetCrossCompartmentWrapper();
|
||||
|
@ -603,7 +606,13 @@ unsafe extern "C" fn wrap(
|
|||
|
||||
unsafe extern "C" fn throw_dom_exception_callback(cx: *mut JSContext) {
|
||||
//TODO it might not always be a SecurityError?
|
||||
throw_dom_exception(cx, &GlobalScope::from_context(cx), Error::Security);
|
||||
let cx = SafeJSContext::from_ptr(cx);
|
||||
let in_realm_proof = AlreadyInRealm::assert_for_cx(cx);
|
||||
throw_dom_exception(
|
||||
cx,
|
||||
&GlobalScope::from_context(*cx, InRealm::in_realm(&in_realm_proof)),
|
||||
Error::Security,
|
||||
);
|
||||
}
|
||||
|
||||
unsafe extern "C" fn is_frame_id(cx: *mut JSContext, obj: *mut JSObject, id_arg: jsid) -> bool {
|
||||
|
|
|
@ -473,7 +473,7 @@ unsafe fn new_rt_and_cx_with_parent(
|
|||
|
||||
JS_AddExtraGCRootsTracer(cx, Some(trace_rust_roots), ptr::null_mut());
|
||||
|
||||
JS_SetSecurityCallbacks(runtime.rt(), &SECURITY_CALLBACKS);
|
||||
JS_SetSecurityCallbacks(cx, &SECURITY_CALLBACKS);
|
||||
|
||||
// Needed for debug assertions about whether GC is running.
|
||||
if cfg!(debug_assertions) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue