summaryrefslogtreecommitdiffstats
path: root/dom/console/ConsoleInstance.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
commit8dd16259287f58f9273002717ec4d27e97127719 (patch)
tree3863e62a53829a84037444beab3abd4ed9dfc7d0 /dom/console/ConsoleInstance.cpp
parentReleasing progress-linux version 126.0.1-1~progress7.99u1. (diff)
downloadfirefox-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.cpp23
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.