diff options
author | Moonchild <moonchild@palemoon.org> | 2023-09-01 15:44:29 +0200 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2023-09-01 15:44:29 +0200 |
commit | 2d48de9998d5c4f768af051ce997777be126f8cd (patch) | |
tree | c6023db91bfadaa8e1d7c4c12d90ad63bf810454 /dom/workers | |
parent | 3b029cdfe482e5097ee09fa1998591faf9c1005b (diff) | |
parent | ee97a5dad40fb8d207b717cb2a0d487f54dd5f1d (diff) | |
download | uxp-2d48de9998d5c4f768af051ce997777be126f8cd.tar.gz |
Merge branch 'master' into releaseRC_20230901RB_20230904
Diffstat (limited to 'dom/workers')
-rw-r--r-- | dom/workers/WorkerPrivate.cpp | 38 | ||||
-rw-r--r-- | dom/workers/WorkerPrivate.h | 3 |
2 files changed, 31 insertions, 10 deletions
diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index a7a4929f3b..2f2fa78d42 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -1000,11 +1000,13 @@ private: class ReportErrorToConsoleRunnable final : public WorkerRunnable { const char* mMessage; + const nsTArray<nsString> mParams; public: // aWorkerPrivate is the worker thread we're on (or the main thread, if null) static void - Report(WorkerPrivate* aWorkerPrivate, const char* aMessage) + Report(WorkerPrivate* aWorkerPrivate, const char* aMessage, + const nsTArray<nsString>& aParams) { if (aWorkerPrivate) { aWorkerPrivate->AssertIsOnWorkerThread(); @@ -1015,23 +1017,30 @@ public: // Now fire a runnable to do the same on the parent's thread if we can. if (aWorkerPrivate) { RefPtr<ReportErrorToConsoleRunnable> runnable = - new ReportErrorToConsoleRunnable(aWorkerPrivate, aMessage); + new ReportErrorToConsoleRunnable(aWorkerPrivate, aMessage, aParams); runnable->Dispatch(); return; } + uint16_t paramCount = aParams.Length(); + const char16_t** params = new const char16_t*[paramCount]; + for (uint16_t i=0; i<paramCount; ++i) { + params[i] = aParams[i].get(); + } + // Log a warning to the console. nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, - NS_LITERAL_CSTRING("DOM"), - nullptr, - nsContentUtils::eDOM_PROPERTIES, - aMessage); + NS_LITERAL_CSTRING("DOM"), nullptr, + nsContentUtils::eDOM_PROPERTIES, aMessage, + paramCount ? params : nullptr, paramCount); + delete[] params; } private: - ReportErrorToConsoleRunnable(WorkerPrivate* aWorkerPrivate, const char* aMessage) + ReportErrorToConsoleRunnable(WorkerPrivate* aWorkerPrivate, const char* aMessage, + const nsTArray<nsString>& aParams) : WorkerRunnable(aWorkerPrivate, ParentThreadUnchangedBusyCount), - mMessage(aMessage) + mMessage(aMessage), mParams(aParams) { } virtual void @@ -1048,7 +1057,7 @@ private: { WorkerPrivate* parent = aWorkerPrivate->GetParent(); MOZ_ASSERT_IF(!parent, NS_IsMainThread()); - Report(parent, mMessage); + Report(parent, mMessage, mParams); return true; } }; @@ -6023,12 +6032,21 @@ WorkerPrivate::ReportError(JSContext* aCx, JS::ConstUTF8CharsZ aToStringResult, void WorkerPrivate::ReportErrorToConsole(const char* aMessage) { + nsTArray<nsString> emptyParams; + WorkerPrivate::ReportErrorToConsole(aMessage, emptyParams); +} + +// static +void +WorkerPrivate::ReportErrorToConsole(const char* aMessage, + const nsTArray<nsString>& aParams) +{ WorkerPrivate* wp = nullptr; if (!NS_IsMainThread()) { wp = GetCurrentThreadWorkerPrivate(); } - ReportErrorToConsoleRunnable::Report(wp, aMessage); + ReportErrorToConsoleRunnable::Report(wp, aMessage, aParams); } int32_t diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h index 0a71420047..351f5458f1 100644 --- a/dom/workers/WorkerPrivate.h +++ b/dom/workers/WorkerPrivate.h @@ -1206,6 +1206,9 @@ public: static void ReportErrorToConsole(const char* aMessage); + static void + ReportErrorToConsole(const char* aMessage, const nsTArray<nsString>& aParams); + int32_t SetTimeout(JSContext* aCx, nsIScriptTimeoutHandler* aHandler, int32_t aTimeout, bool aIsInterval, |