diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
commit | 8dd16259287f58f9273002717ec4d27e97127719 (patch) | |
tree | 3863e62a53829a84037444beab3abd4ed9dfc7d0 /dom/console/ConsoleInstance.cpp | |
parent | Releasing progress-linux version 126.0.1-1~progress7.99u1. (diff) | |
download | firefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz firefox-8dd16259287f58f9273002717ec4d27e97127719.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/console/ConsoleInstance.cpp')
-rw-r--r-- | dom/console/ConsoleInstance.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/dom/console/ConsoleInstance.cpp b/dom/console/ConsoleInstance.cpp index ade82be50f..a73b83ee4c 100644 --- a/dom/console/ConsoleInstance.cpp +++ b/dom/console/ConsoleInstance.cpp @@ -65,9 +65,24 @@ ConsoleInstance::ConsoleInstance(JSContext* aCx, if (!aOptions.mMaxLogLevelPref.IsEmpty()) { if (!NS_IsMainThread()) { - NS_WARNING("Console.maxLogLevelPref is not supported on workers!"); // Set the log level based on what we have. SetLogLevel(); + + // Flag an error to the console. + JS::Rooted<JS::Value> msg(aCx); + if (!ToJSValue( + aCx, + nsLiteralCString( + "Console.maxLogLevelPref is not supported within workers!"), + &msg)) { + JS_ClearPendingException(aCx); + return; + } + + AutoTArray<JS::Value, 1> sequence; + SequenceRooter rootedSequence(aCx, &sequence); + sequence.AppendElement(std::move(msg)); + this->Error(aCx, std::move(sequence)); return; } @@ -80,8 +95,9 @@ ConsoleInstance::ConsoleInstance(JSContext* aCx, } ConsoleInstance::~ConsoleInstance() { - AssertIsOnMainThread(); - if (!mMaxLogLevelPref.IsEmpty()) { + // We should only ever have set `mMaxLogLevelPref` when on the main thread, + // but check it here to be safe. + if (!mMaxLogLevelPref.IsEmpty() && NS_IsMainThread()) { Preferences::UnregisterCallback(MaxLogLevelPrefChangedCallback, mMaxLogLevelPref, this); } @@ -128,7 +144,6 @@ void ConsoleInstance::SetLogLevel() { // static void ConsoleInstance::MaxLogLevelPrefChangedCallback( const char* /* aPrefName */, void* aSelf) { - AssertIsOnMainThread(); auto* instance = static_cast<ConsoleInstance*>(aSelf); if (MOZ_UNLIKELY(!instance->mConsole)) { // We've been unlinked already but not destroyed yet. Bail. |