Bug 1990116 - Use the error report to detect warnings in workers and worklets. a=RyanVM

Original Revision: https://phabricator.services.mozilla.com/D265768

Differential Revision: https://phabricator.services.mozilla.com/D266292
This commit is contained in:
Tooru Fujisawa
2025-09-27 23:33:54 +00:00
committed by rvandermeulen@mozilla.com
parent fa777865b5
commit 9571910e5c
2 changed files with 10 additions and 6 deletions

View File

@@ -5927,7 +5927,11 @@ void WorkerPrivate::ReportError(JSContext* aCx,
}
JS::ExceptionStack exnStack(aCx);
if (JS_IsExceptionPending(aCx)) {
// NOTE: This function is used both for errors and warnings, and warnings
// can be reported while there's a pending exception.
// Warnings are always reported with non-null JSErrorReport.
if (!aReport || !aReport->isWarning()) {
MOZ_ASSERT(JS_IsExceptionPending(aCx));
if (!JS::StealPendingExceptionStack(aCx, &exnStack)) {
JS_ClearPendingException(aCx);
return;
@@ -5941,10 +5945,6 @@ void WorkerPrivate::ReportError(JSContext* aCx,
JSAutoRealm ar(aCx, stackGlobal);
report->SerializeWorkerStack(aCx, this, stack);
}
} else {
// ReportError is also used for reporting warnings,
// so there won't be a pending exception.
MOZ_ASSERT(aReport && aReport->isWarning());
}
if (report->mMessage.IsEmpty() && aToStringResult) {

View File

@@ -199,7 +199,11 @@ void WorkletJSContext::ReportError(JSErrorReport* aReport,
RefPtr<AsyncErrorReporter> reporter = new AsyncErrorReporter(xpcReport);
JSContext* cx = Context();
if (JS_IsExceptionPending(cx)) {
// NOTE: This function is used both for errors and warnings, and warnings
// can be reported while there's a pending exception.
// Warnings are always reported with non-null JSErrorReport.
if (!aReport || !aReport->isWarning()) {
MOZ_ASSERT(JS_IsExceptionPending(cx));
JS::ExceptionStack exnStack(cx);
if (JS::StealPendingExceptionStack(cx, &exnStack)) {
JS::Rooted<JSObject*> stack(cx);