diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /devtools/client/webconsole/test/browser/browser_webconsole_batching.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/webconsole/test/browser/browser_webconsole_batching.js')
-rw-r--r-- | devtools/client/webconsole/test/browser/browser_webconsole_batching.js | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/devtools/client/webconsole/test/browser/browser_webconsole_batching.js b/devtools/client/webconsole/test/browser/browser_webconsole_batching.js new file mode 100644 index 0000000000..8c49a003a0 --- /dev/null +++ b/devtools/client/webconsole/test/browser/browser_webconsole_batching.js @@ -0,0 +1,62 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Check adding console calls as batch keep the order of the message. + +const TEST_URI = + "http://example.com/browser/devtools/client/webconsole/" + + "test/browser/test-batching.html"; +const { + l10n, +} = require("resource://devtools/client/webconsole/utils/messages.js"); + +add_task(async function () { + const hud = await openNewTabAndConsole(TEST_URI); + const messageNumber = 100; + await testSimpleBatchLogging(hud, messageNumber); + await testBatchLoggingAndClear(hud, messageNumber); +}); + +async function testSimpleBatchLogging(hud, messageNumber) { + await SpecialPowers.spawn( + gBrowser.selectedBrowser, + [messageNumber], + function (numMessages) { + content.wrappedJSObject.batchLog(numMessages); + } + ); + const allMessages = await waitFor(async () => { + const msgs = await findAllMessagesVirtualized(hud); + if (msgs.length == messageNumber) { + return msgs; + } + return null; + }); + for (let i = 0; i < messageNumber; i++) { + const node = allMessages[i].querySelector(".message-body"); + is( + node.textContent, + i.toString(), + `message at index "${i}" is the expected one` + ); + } +} + +async function testBatchLoggingAndClear(hud, messageNumber) { + await SpecialPowers.spawn( + gBrowser.selectedBrowser, + [messageNumber], + function (numMessages) { + content.wrappedJSObject.batchLogAndClear(numMessages); + } + ); + await waitFor(() => + findConsoleAPIMessage(hud, l10n.getStr("consoleCleared")) + ); + ok(true, "console cleared message is displayed"); + + const messages = findAllMessages(hud); + is(messages.length, 1, "console was cleared as expected"); +} |