@@ -6720,7 +6720,7 @@ static bool can_add_backtrace(JSValueConst obj)
67206720 if (JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT)
67216721 return false;
67226722 p = JS_VALUE_GET_OBJ(obj);
6723- if (p->class_id != JS_CLASS_ERROR)
6723+ if (p->class_id != JS_CLASS_ERROR && p->class_id != JS_CLASS_DOM_EXCEPTION )
67246724 return false;
67256725 if (find_own_property1(p, JS_ATOM_stack))
67266726 return false;
@@ -57684,7 +57684,8 @@ static void js_domexception_mark(JSRuntime *rt, JSValueConst val,
5768457684}
5768557685
5768657686static JSValue js_domexception_constructor0(JSContext *ctx, JSValueConst new_target,
57687- int argc, JSValueConst *argv)
57687+ int argc, JSValueConst *argv,
57688+ bool add_backtrace)
5768857689{
5768957690 JSDOMExceptionData *s;
5769057691 JSValue obj, message, name;
@@ -57711,6 +57712,9 @@ static JSValue js_domexception_constructor0(JSContext *ctx, JSValueConst new_tar
5771157712 s->message = message;
5771257713 s->code = -1;
5771357714 JS_SetOpaqueInternal(obj, s);
57715+ if (add_backtrace)
57716+ build_backtrace(ctx, obj, JS_UNDEFINED, NULL, 0, 0,
57717+ JS_BACKTRACE_FLAG_SKIP_FIRST_LEVEL);
5771457718 return obj;
5771557719fail3:
5771657720 JS_FreeValue(ctx, name);
@@ -57726,7 +57730,7 @@ static JSValue js_domexception_constructor(JSContext *ctx, JSValueConst new_targ
5772657730{
5772757731 if (JS_IsUndefined(new_target))
5772857732 return JS_ThrowTypeError(ctx, "constructor requires 'new'");
57729- return js_domexception_constructor0(ctx, new_target, argc, argv);
57733+ return js_domexception_constructor0(ctx, new_target, argc, argv, true );
5773057734}
5773157735
5773257736static JSValue js_domexception_get_name(JSContext *ctx, JSValueConst this_val)
@@ -57803,9 +57807,10 @@ JSValue JS_PRINTF_FORMAT_ATTR(3, 4) JS_ThrowDOMException(JSContext *ctx, const c
5780357807 }
5780457808 argv[0] = js_message;
5780557809 argv[1] = js_name;
57806- obj = js_domexception_constructor0(ctx, JS_UNDEFINED, 2, argv);
57810+ obj = js_domexception_constructor0(ctx, JS_UNDEFINED, 2, argv, false );
5780757811 JS_FreeValue(ctx, js_message);
5780857812 JS_FreeValue(ctx, js_name);
57813+ build_backtrace(ctx, obj, JS_UNDEFINED, NULL, 0, 0, 0);
5780957814 JS_Throw(ctx, obj);
5781057815end:
5781157816 va_end(ap);
0 commit comments