ConsoleAPIStorage stores messages from system modules (.sys.mjs) under
filename-based keys. inner-window-destroyed only clears numeric window
ID keys, so these entries persist and can leak chrome windows.
When mInnerID is 0 (non-window realm), derive the storage key from the
first window found in three places:
- The captured stack's SavedFrame globals (for chrome windows with their
own compartment, e.g. aiWindow.html).
- The message argument globals (for objects created in a window realm).
- Sandbox argument globals whose prototype is a window (for errors
created in DevTools sandboxes).
Differential Revision: https://phabricator.services.mozilla.com/D292956
In `ConsoleMethodNameToMozLog`, `console.assert` is assigned to `LogLevel::Error`, same as `console.error` or `console.exception`.
But in `ConsoleMethodNameToInteger`, `console.assert` is assigned to the level `3`, which translates to `LogLevel::Info`.
We keep duplicated maps because those methods are on console hot paths, but we should make sure the levels set are consistent.
Differential Revision: https://phabricator.services.mozilla.com/D284032
Regrouped case to make the mapping methods easier to read.
Renamed the methods top clearly mention "method name" when this is what we are mapping.
Added a small comment to clarify the logic.
Differential Revision: https://phabricator.services.mozilla.com/D284031
Decreases the console trace log level for MOZ_LOG to `Verbose` (5).
This makes it the lowest logger method available, but note that console.trace() most likely triggers generating a stacktrace, so it should still be used sparingly.
Differential Revision: https://phabricator.services.mozilla.com/D283939
This commit introduces a new `ConsoleLevelIntegerToMozLog` which translates a console level (as a numeric value) to a mozlog log level.
The new method is used to simplify `InternalLogLevelToMozLog` as well as to provide a new Console::ShouldLogToMozLog(ConsoleLogLevel aLevel)
Finally ConsoleInstance shouldLog is expanded to also check if the mozlog level is matched.
Tests are added to cover this.
Differential Revision: https://phabricator.services.mozilla.com/D282618
This is the last member of StructuredCloneHolder which is mutated when reading
a StructuredCloneHolder which does not support transfers.
This does change behaviour, as the Read functions no longer clobber every
exception thrown by the StructuredClone implementation with a DataCloneError
exception, instead stealing the exceptions as they are thrown. The behaviour of
the Write function has been changed less substantially, as it already avoided
clobbering existing exceptions.
This change in behaviour is not a complete shift. Our Structured Clone custom
callbacks have historically not reliably thrown exceptions on failure, so
uncatchable exceptions are replaced with generic exceptions before being
returned to the JS engine to avoid throwing uncatchable exceptions in error
cases where we did not previously.
It's worth noting that this change assumes that the JS implementation of
structured clone reliably throws exceptions itself. In general SpiderMonkey
code is better about this (due to better-established patterns), than Gecko code
using SpiderMonkey calling conventions.
The new implementations of Read/Write use StealExceptionFromJSContext over
NoteJSContextException, as SuppressExceptions/IgnoreErrors/IgnoredErrorResult
are frequently used with StructuredCloneHolder, and JSContext exceptions are
not suppressed when SuppressExceptions is called.
Differential Revision: https://phabricator.services.mozilla.com/D281113
This reverts commit 72c32e25bf.
Revert "Bug 2013389 - Part 11: Make attachment arrays more consistent in StructuredCloneHolder, r=asuth"
This reverts commit c0912428c7.
Revert "Bug 2013389 - Part 10: Fix version tracking in nsStructuredCloneContainer, r=asuth,extension-reviewers,spidermonkey-reviewers,sfink,robwu"
This reverts commit f2e9691831.
Revert "Bug 2013389 - Part 9: Remove the now-unused ReadFromBuffer method, r=asuth"
This reverts commit 6eb034458e.
Revert "Bug 2013389 - Part 8: Avoid the unnecessary ClonedMessageData intermediate, r=asuth,mccr8,extension-reviewers,dom-worker-reviewers,robwu"
This reverts commit 4dd6f1d6ea.
Revert "Bug 2013389 - Part 7: Only deserialize once in nsFrameMessageManager, r=asuth"
This reverts commit 65d16af619.
Revert "Bug 2013389 - Part 6: Remove weak listener support from MessageManager, r=smaug"
This reverts commit 66f4b308a0.
Revert "Bug 2013389 - Part 5: Broadcasting MessageManagers cannot support transferrables, r=asuth"
This reverts commit e95e1a5a6c.
Revert "Bug 2013389 - Part 4: Avoid depending on mErrorMessage when deserializing StructuredCloneHolder, r=asuth,dom-worker-reviewers"
This reverts commit ae78c69357.
Revert "Bug 2013389 - Part 3: Remove aGlobal argument from StructuredCloneHolder::Read, r=asuth,dom-worker-reviewers"
This reverts commit 066bd37bfd.
Revert "Bug 2013389 - Part 2: Stop tracking mGlobal within StructuredCloneHolder::Read, r=asuth"
This reverts commit 6b4f3a43c0.
Revert "Bug 2013389 - Part 1: Add an Adopt API to StructuredCloneHolder, r=asuth"
This reverts commit 8624db71c2.
This is the last member of StructuredCloneHolder which is mutated when reading
a StructuredCloneHolder which does not support transfers.
This does change behaviour, as the Read functions no longer clobber every
exception thrown by the StructuredClone implementation with a DataCloneError
exception, instead stealing the exceptions as they are thrown. The behaviour of
the Write function has been changed less substantially, as it already avoided
clobbering existing exceptions.
This change in behaviour is not a complete shift. Our Structured Clone custom
callbacks have historically not reliably thrown exceptions on failure, so
uncatchable exceptions are replaced with generic exceptions before being
returned to the JS engine to avoid throwing uncatchable exceptions in error
cases where we did not previously.
It's worth noting that this change assumes that the JS implementation of
structured clone reliably throws exceptions itself. In general SpiderMonkey
code is better about this (due to better-established patterns), than Gecko code
using SpiderMonkey calling conventions.
The new implementations of Read/Write use StealExceptionFromJSContext over
NoteJSContextException, as SuppressExceptions/IgnoreErrors/IgnoredErrorResult
are frequently used with StructuredCloneHolder, and JSContext exceptions are
not suppressed when SuppressExceptions is called.
Differential Revision: https://phabricator.services.mozilla.com/D281113
That, instead of being only driven by console default level (hardcoded or via a specific pref).
The console messages won't be logged to MOZ_LOG if the they aren't enabled in MOZ_LOG.
This may lead to duplicated messages if console still logs to stdout.
Differential Revision: https://phabricator.services.mozilla.com/D280068
This reverts commit 5c5cf7465b.
Revert "Bug 2013389 - Part 10: Fix version tracking in nsStructuredCloneContainer, r=asuth,extension-reviewers,spidermonkey-reviewers,sfink,robwu"
This reverts commit c87a327d86.
Revert "Bug 2013389 - Part 9: Remove the now-unused ReadFromBuffer method, r=asuth"
This reverts commit 5adf49e5d8.
Revert "Bug 2013389 - Part 8: Avoid the unnecessary ClonedMessageData intermediate, r=asuth,mccr8,extension-reviewers,dom-worker-reviewers,robwu"
This reverts commit f6d12563fe.
Revert "Bug 2013389 - Part 7: Only deserialize once in nsFrameMessageManager, r=asuth"
This reverts commit 44c1325d76.
Revert "Bug 2013389 - Part 6: Remove weak listener support from MessageManager, r=smaug"
This reverts commit 1d1b495c91.
Revert "Bug 2013389 - Part 5: Broadcasting MessageManagers cannot support transferrables, r=asuth"
This reverts commit e2eb75ff8f.
Revert "Bug 2013389 - Part 4: Avoid depending on mErrorMessage when deserializing StructuredCloneHolder, r=asuth,dom-worker-reviewers"
This reverts commit d9a234ad7b.
Revert "Bug 2013389 - Part 3: Remove aGlobal argument from StructuredCloneHolder::Read, r=asuth,dom-worker-reviewers"
This reverts commit 48279cea50.
Revert "Bug 2013389 - Part 2: Stop tracking mGlobal within StructuredCloneHolder::Read, r=asuth"
This reverts commit 27162e5046.
Revert "Bug 2013389 - Part 1: Add an Adopt API to StructuredCloneHolder, r=asuth"
This reverts commit e3a9f32716.
This is the last member of StructuredCloneHolder which is mutated when reading
a StructuredCloneHolder which does not support transfers.
This does change behaviour, as the Read functions no longer clobber every
exception thrown by the StructuredClone implementation with a DataCloneError
exception, instead stealing the exceptions as they are thrown. The behaviour of
the Write function has been changed less substantially, as it already avoided
clobbering existing exceptions.
This change in behaviour is not a complete shift. Our Structured Clone custom
callbacks have historically not reliably thrown exceptions on failure, so
uncatchable exceptions are replaced with generic exceptions before being
returned to the JS engine to avoid throwing uncatchable exceptions in error
cases where we did not previously.
It's worth noting that this change assumes that the JS implementation of
structured clone reliably throws exceptions itself. In general SpiderMonkey
code is better about this (due to better-established patterns), than Gecko code
using SpiderMonkey calling conventions.
The new implementations of Read/Write use StealExceptionFromJSContext over
NoteJSContextException, as SuppressExceptions/IgnoreErrors/IgnoredErrorResult
are frequently used with StructuredCloneHolder, and JSContext exceptions are
not suppressed when SuppressExceptions is called.
Differential Revision: https://phabricator.services.mozilla.com/D281113
Before we switched to the Firefox Profiler in the DevTools, we had
timeline markers for these console methods. But apparently, since we did
the switch, we never added markers for them.
From our conversations with Chrome folks, they mentioned that some JS
frameworks started using these instead of performance.mark/measure
combinations especially the console.timeStamp one since it's just an
instant marker, stating that they are higher overhead. Even though I
don't completely understand their rationale, I think it makes sense to
add markers for these methods. It essentially adds 2 different subtypes
that uses the same ConsoleTimingMarker.
1. console.time and console.timeEnd when combined create a duration
marker with a label, similar to performance.mark and measure.
2. console.timeStamp creates an instant marker with a label.
One edge case is that, console.timeEnd doesn't create any markers when
it doesn't have a console.time with the same title, and vice versa.
Differential Revision: https://phabricator.services.mozilla.com/D281521
It is replaced by a standard-conforming cast to (void) which is
understood the same by the compiler.
In some cases this could be replaced by `[[maybe_unused]]` but for
expression whose value is ignored, this requires storing to a temporary
variable first, so not going that way.
One notable change is that marking an object of type already_AddRefed as
unused used to implicitly leak memory. This is now made explicit.
Most of the heavy lifting was done through:
$ git grep -l '\<Unused\> <<' | xargs sed -i -e 's/Unused << /(void)/g'
$ git grep -l mozilla/Unused.h | xargs sed -i -e '/mozilla\/Unused.h/ d'
Differential Revision: https://phabricator.services.mozilla.com/D268706
It is replaced by a standard-conforming cast to (void) which is
understood the same by the compiler.
In some cases this could be replaced by `[[maybe_unused]]` but for
expression whose value is ignored, this requires storing to a temporary
variable first, so not going that way.
One notable change is that marking an object of type already_AddRefed as
unused used to implicitly leak memory. This is now made explicit.
Most of the heavy lifting was done through:
$ git grep -l '\<Unused\> <<' | xargs sed -i -e 's/Unused << /(void)/g'
$ git grep -l mozilla/Unused.h | xargs sed -i -e '/mozilla\/Unused.h/ d'
Differential Revision: https://phabricator.services.mozilla.com/D268706
It is replaced by a standard-conforming cast to (void) which is
understood the same by the compiler.
In some cases this could be replaced by `[[maybe_unused]]` but for
expression whose value is ignored, this requires storing to a temporary
variable first, so not going that way.
One notable change is that marking an object of type already_AddRefed as
unused used to implicitly leak memory. This is now made explicit.
Most of the heavy lifting was done through:
$ git grep -l '\<Unused\> <<' | xargs sed -i -e 's/Unused << /(void)/g'
$ git grep -l mozilla/Unused.h | xargs sed -i -e '/mozilla\/Unused.h/ d'
Differential Revision: https://phabricator.services.mozilla.com/D268706
It is replaced by a standard-conforming cast to (void) which is
understood the same by the compiler.
In some cases this could be replaced by `[[maybe_unused]]` but for
expression whose value is ignored, this requires storing to a temporary
variable first, so not going that way.
One notable change is that marking an object of type already_AddRefed as
unused used to implicitly leak memory. This is now made explicit.
Most of the heavy lifting was done through:
$ git grep -l '\<Unused\> <<' | xargs sed -i -e 's/Unused << /(void)/g'
$ git grep -l mozilla/Unused.h | xargs sed -i -e '/mozilla\/Unused.h/ d'
Differential Revision: https://phabricator.services.mozilla.com/D268706
Most changes are automated. Relevant bit is dom/.clang-format. I had to
manually disable clang-format in a few places where importing external
files and so on that aren't self-contained, and fix a couple includes /
forward declarations.
Differential Revision: https://phabricator.services.mozilla.com/D256800
Disabled dom/console/tests/xpcshell/test_failing_console_listener for tsan build.
Since the failing console mechanism causes too many additional deadlock checking then time out the test.
Differential Revision: https://phabricator.services.mozilla.com/D224922
This moves handling of the preferences and log value setting into ConsoleInstance, which is where the preferences
are received. It also makes ConsoleInstance add a listener on the preferences service so that updates are triggered.
The functionality is already covered by dom/console/tests/test_jsm.xhtml
Differential Revision: https://phabricator.services.mozilla.com/D199657
This moves handling of the preferences and log value setting into ConsoleInstance, which is where the preferences
are received. It also makes ConsoleInstance add a listener on the preferences service so that updates are triggered.
The functionality is already covered by dom/console/tests/test_jsm.xhtml
Differential Revision: https://phabricator.services.mozilla.com/D199657
This patch removes the old docshell timeline and timeline markers codebase and replaces them with equivalent Gecko profiler marker. This patch also fixes Bug 1834143, which is a subset of 1421651.
Differential Revision: https://phabricator.services.mozilla.com/D184217