Throw type error when calling DOM constructor without new.

This commit is contained in:
Josh Matthews 2023-05-30 10:32:33 -04:00
parent 43f5b4899b
commit 56a8237ef4
3 changed files with 45 additions and 15 deletions

View file

@ -312,6 +312,12 @@ pub unsafe fn throw_invalid_this(cx: *mut JSContext, proto_id: u16) {
throw_type_error(cx, &error);
}
pub unsafe fn throw_constructor_without_new(cx: *mut JSContext, name: &str) {
debug_assert!(!JS_IsExceptionPending(cx));
let error = format!("{} constructor: 'new' is required", name);
throw_type_error(cx, &error);
}
impl Error {
/// Convert this error value to a JS value, consuming it in the process.
pub unsafe fn to_jsval(