CanGc fixes in errorevent.rs (#33960)

* CanGc fixes in errorevent.rs

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>

* Allow too_many_arguments to avoid lint error

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>

---------

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
This commit is contained in:
tanishka 2024-10-22 15:38:55 +05:30 committed by GitHub
parent 575e885529
commit 7015e0fb5f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 79 additions and 51 deletions

View file

@ -27,7 +27,7 @@ use crate::dom::bindings::utils::AsCCharPtrPtr;
use crate::dom::globalscope::GlobalScope;
use crate::dom::window::Window;
use crate::realms::{enter_realm, InRealm};
use crate::script_runtime::JSContext;
use crate::script_runtime::{CanGc, JSContext};
/// The exception handling used for a call.
#[derive(Clone, Copy, PartialEq)]
@ -271,7 +271,7 @@ impl Drop for CallSetup {
LeaveRealm(*self.cx, self.old_realm);
if self.handling == ExceptionHandling::Report {
let ar = enter_realm(&*self.exception_global);
report_pending_exception(*self.cx, true, InRealm::Entered(&ar));
report_pending_exception(*self.cx, true, InRealm::Entered(&ar), CanGc::note());
}
drop(self.incumbent_script.take());
drop(self.entry_script.take().unwrap());

View file

@ -29,7 +29,7 @@ use crate::dom::bindings::str::USVString;
use crate::dom::domexception::{DOMErrorName, DOMException};
use crate::dom::globalscope::GlobalScope;
use crate::realms::InRealm;
use crate::script_runtime::JSContext as SafeJSContext;
use crate::script_runtime::{CanGc, JSContext as SafeJSContext};
#[cfg(feature = "js_backtrace")]
thread_local! {
@ -267,7 +267,12 @@ impl ErrorInfo {
///
/// The `dispatch_event` argument is temporary and non-standard; passing false
/// prevents dispatching the `error` event.
pub unsafe fn report_pending_exception(cx: *mut JSContext, dispatch_event: bool, realm: InRealm) {
pub unsafe fn report_pending_exception(
cx: *mut JSContext,
dispatch_event: bool,
realm: InRealm,
can_gc: CanGc,
) {
if !JS_IsExceptionPending(cx) {
return;
}
@ -299,7 +304,7 @@ pub unsafe fn report_pending_exception(cx: *mut JSContext, dispatch_event: bool,
}
if dispatch_event {
GlobalScope::from_context(cx, realm).report_an_error(error_info, value.handle());
GlobalScope::from_context(cx, realm).report_an_error(error_info, value.handle(), can_gc);
}
}