diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /toolkit/components/asyncshutdown/tests/xpcshell/test_AsyncShutdown_blocker_error_annotations.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/asyncshutdown/tests/xpcshell/test_AsyncShutdown_blocker_error_annotations.js')
-rw-r--r-- | toolkit/components/asyncshutdown/tests/xpcshell/test_AsyncShutdown_blocker_error_annotations.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/toolkit/components/asyncshutdown/tests/xpcshell/test_AsyncShutdown_blocker_error_annotations.js b/toolkit/components/asyncshutdown/tests/xpcshell/test_AsyncShutdown_blocker_error_annotations.js new file mode 100644 index 0000000000..f0e0d966ff --- /dev/null +++ b/toolkit/components/asyncshutdown/tests/xpcshell/test_AsyncShutdown_blocker_error_annotations.js @@ -0,0 +1,55 @@ +/* Any copyright is dedicated to the Public Domain. +http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/** + * Check that when addBlocker fails, we store that failure internally + * and include its information in crash report annotation information. + */ +add_task(async function test_addBlockerFailureState() { + info("Testing addBlocker information reported to crash reporter"); + + let BLOCKER_NAME = "test_addBlocker_state blocker " + Math.random(); + + // Set up the barrier. Note that we cannot test `barrier.state` + // immediately, as it initially contains "Not started" + let barrier = new AsyncShutdown.Barrier("test_addBlocker_failure"); + let deferred = PromiseUtils.defer(); + barrier.client.addBlocker(BLOCKER_NAME, function () { + return deferred.promise; + }); + + // Add a blocker and confirm that throws. + const THROWING_BLOCKER_NAME = "test_addBlocker_throws blocker"; + Assert.throws(() => { + barrier.client.addBlocker(THROWING_BLOCKER_NAME, Promise.resolve(), 5); + }, /object as third argument/); + + let promiseDone = barrier.wait(); + + // Now that we have called `wait()`, the state should match crash + // reporting info + let crashInfo = barrier._gatherCrashReportTimeoutData( + barrier._name, + barrier.state + ); + Assert.deepEqual( + crashInfo.conditions, + barrier.state, + "Barrier state should match crash info." + ); + Assert.equal( + crashInfo.brokenAddBlockers.length, + 1, + "Should have registered the broken addblocker call." + ); + Assert.stringMatches( + crashInfo.brokenAddBlockers?.[0] || "undefined", + THROWING_BLOCKER_NAME, + "Throwing call's blocker name should be listed in message." + ); + + deferred.resolve(); + await promiseDone; +}); |