From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../test/mochitest/browser_dbg-pause-on-unload.js | 87 ++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 devtools/client/debugger/test/mochitest/browser_dbg-pause-on-unload.js (limited to 'devtools/client/debugger/test/mochitest/browser_dbg-pause-on-unload.js') diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-pause-on-unload.js b/devtools/client/debugger/test/mochitest/browser_dbg-pause-on-unload.js new file mode 100644 index 0000000000..662bd8685b --- /dev/null +++ b/devtools/client/debugger/test/mochitest/browser_dbg-pause-on-unload.js @@ -0,0 +1,87 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at . */ + +// Tests that the debugger works when pausing on unload. + +"use strict"; + +const TEST_URL_1 = + "data:text/html," + + encodeURI( + `` + ); + +add_task(async function debuggerStatementOnUnload() { + const dbg = await initDebuggerWithAbsoluteURL(TEST_URL_1); + + await addExpression(dbg, "event.type"); + is(getWatchExpressionLabel(dbg, 1), "event.type"); + is(getWatchExpressionValue(dbg, 1), "(unavailable)"); + + info("Reloading the page should trigger the debugger statement on unload"); + const evaluated = waitForDispatch(dbg.store, "EVALUATE_EXPRESSIONS"); + const onReload = reload(dbg); + + await waitForPaused(dbg); + await waitForInlinePreviews(dbg); + assertPausedAtSourceAndLine(dbg, findSource(dbg, TEST_URL_1).id, 1, 56); + + await evaluated; + is( + getWatchExpressionValue(dbg, 1), + `"unload"`, + "event.type evaluation does return the expected result" + ); + + // Verify that project search works while being paused on unload + await openProjectSearch(dbg); + await doProjectSearch(dbg, "unload", 1); + + info("Resume execution and wait for the page to complete its reload"); + await resume(dbg); + await onReload; +}); + +// Note that inline exception doesn't work on single line `); + +add_task(async function exceptionsOnUnload() { + const dbg = await initDebuggerWithAbsoluteURL(TEST_URL_2); + + info("Enable pause on uncaught exception (but not for caught exception)"); + await togglePauseOnExceptions(dbg, true, false); + + await openProjectSearch(dbg); + await doProjectSearch(dbg, "exception", 1); + is(getExpandedResultsCount(dbg), 2); + + info("Reloading the page should trigger the debugger statement on unload"); + const onReload = reload(dbg); + + // Cover catching exception on unload + await waitForPaused(dbg); + assertPausedAtSourceAndLine(dbg, findSource(dbg, TEST_URL_2).id, 2, 49); + + // But also that previous inline exceptions are still visible + await assertInlineExceptionPreview(dbg, 3, 4, { + fields: [["", TEST_URL_2 + ":3"]], + result: "TypeError: [].inlineException is not a function", + expression: "inlineException", + }); + + // Verify that project search results are still displayed + is(getExpandedResultsCount(dbg), 2); + + // Stop pausing on exception to prevent pausing on the inline exception on the load of the next page + await togglePauseOnExceptions(dbg, false, false); + + info("Resume execution and wait for the page to complete its reload"); + await resume(dbg); + await onReload; +}); -- cgit v1.2.3