mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Refactor:Refactors report_cross_origin_denial method to use unsafe block (#36365)
The method report_cross_origin_denial was marked as unsafe, have instead moved the unsafe code within the method into an unsafe block within the method and removed the unsafe marking for the method. Testing: No testing needed Fixes: This PR resolves #36356. Signed-off-by : Ashok Kaushik kaushikashok45@gmail.com --------- Signed-off-by: ashok.kaushik <ashok.kaushik@zohocorp.com> Co-authored-by: ashok.kaushik <ashok.kaushik@zohocorp.com>
This commit is contained in:
parent
b87bf0b806
commit
a67409fb25
1 changed files with 7 additions and 5 deletions
|
@ -509,7 +509,7 @@ fn ensure_cross_origin_property_holder(
|
||||||
/// What this function does corresponds to the operations in
|
/// What this function does corresponds to the operations in
|
||||||
/// <https://html.spec.whatwg.org/multipage/#the-location-interface> denoted as
|
/// <https://html.spec.whatwg.org/multipage/#the-location-interface> denoted as
|
||||||
/// "Throw a `SecurityError` DOMException".
|
/// "Throw a `SecurityError` DOMException".
|
||||||
pub(crate) unsafe fn report_cross_origin_denial<D: DomTypes>(
|
pub(crate) fn report_cross_origin_denial<D: DomTypes>(
|
||||||
cx: SafeJSContext,
|
cx: SafeJSContext,
|
||||||
id: RawHandleId,
|
id: RawHandleId,
|
||||||
access: &str,
|
access: &str,
|
||||||
|
@ -520,11 +520,13 @@ pub(crate) unsafe fn report_cross_origin_denial<D: DomTypes>(
|
||||||
id_to_source(cx, id).as_deref().unwrap_or("< error >"),
|
id_to_source(cx, id).as_deref().unwrap_or("< error >"),
|
||||||
);
|
);
|
||||||
let in_realm_proof = AlreadyInRealm::assert_for_cx(cx);
|
let in_realm_proof = AlreadyInRealm::assert_for_cx(cx);
|
||||||
|
unsafe {
|
||||||
if !JS_IsExceptionPending(*cx) {
|
if !JS_IsExceptionPending(*cx) {
|
||||||
let global = D::GlobalScope::from_context(*cx, InRealm::Already(&in_realm_proof));
|
let global = D::GlobalScope::from_context(*cx, InRealm::Already(&in_realm_proof));
|
||||||
// TODO: include `id` and `access` in the exception message
|
// TODO: include `id` and `access` in the exception message
|
||||||
<D as DomHelpers<D>>::throw_dom_exception(cx, &global, Error::Security, CanGc::note());
|
<D as DomHelpers<D>>::throw_dom_exception(cx, &global, Error::Security, CanGc::note());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue