diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index abffdc85c45b..1099cac9aa73 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -1050,7 +1050,8 @@ public: const nsString& aLine, uint32_t aLineNumber, uint32_t aColumnNumber, uint32_t aFlags, uint32_t aErrorNumber, JSExnType aExnType, - bool aMutedError, uint64_t aInnerWindowId) + bool aMutedError, uint64_t aInnerWindowId, + JS::Handle aException = JS::NullHandleValue) { if (aWorkerPrivate) { aWorkerPrivate->AssertIsOnWorkerThread(); @@ -1070,6 +1071,7 @@ public: init.mMessage = aMessage; init.mFilename = aFilename; init.mLineno = aLineNumber; + init.mError = aException; } init.mCancelable = true; @@ -5919,6 +5921,12 @@ WorkerPrivate::ReportError(JSContext* aCx, const char* aFallbackMessage, mErrorHandlerRecursionCount == 1, "Bad recursion logic!"); + JS::Rooted exn(aCx); + if (!JS_GetPendingException(aCx, &exn)) { + // Probably shouldn't actually happen? But let's go ahead and just use null + // for lack of anything better. + exn.setNull(); + } JS_ClearPendingException(aCx); nsString message, filename, line; @@ -5966,7 +5974,7 @@ WorkerPrivate::ReportError(JSContext* aCx, const char* aFallbackMessage, ReportErrorRunnable::ReportError(aCx, this, fireAtScope, nullptr, message, filename, line, lineNumber, columnNumber, flags, errorNumber, exnType, - mutedError, 0); + mutedError, 0, exn); mErrorHandlerRecursionCount--; } diff --git a/testing/web-platform/meta/MANIFEST.json b/testing/web-platform/meta/MANIFEST.json index d5dc3b7d5cb8..c9cb4795b40e 100644 --- a/testing/web-platform/meta/MANIFEST.json +++ b/testing/web-platform/meta/MANIFEST.json @@ -37705,6 +37705,12 @@ "path": "web-animations/timing-model/animations/updating-the-finished-state.html", "url": "/web-animations/timing-model/animations/updating-the-finished-state.html" } + ], + "workers/Worker_ErrorEvent_error.htm": [ + { + "path": "workers/Worker_ErrorEvent_error.htm", + "url": "/workers/Worker_ErrorEvent_error.htm" + } ] } }, diff --git a/testing/web-platform/tests/workers/Worker_ErrorEvent_error.htm b/testing/web-platform/tests/workers/Worker_ErrorEvent_error.htm new file mode 100644 index 000000000000..1c1257d1bd22 --- /dev/null +++ b/testing/web-platform/tests/workers/Worker_ErrorEvent_error.htm @@ -0,0 +1,29 @@ + + + + + + diff --git a/testing/web-platform/tests/workers/support/ErrorEvent-error.js b/testing/web-platform/tests/workers/support/ErrorEvent-error.js new file mode 100644 index 000000000000..930b54c0d588 --- /dev/null +++ b/testing/web-platform/tests/workers/support/ErrorEvent-error.js @@ -0,0 +1,9 @@ +onerror = function(message, location, line, col, error) { + postMessage({ source: "onerror", value: error }); +} + +addEventListener("error", function(e) { + postMessage({ source: "event listener", value: e.error }); +}); + +throw "hello";