From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../mochitest/browser_dbg-expressions-watch.js | 91 ++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 devtools/client/debugger/test/mochitest/browser_dbg-expressions-watch.js (limited to 'devtools/client/debugger/test/mochitest/browser_dbg-expressions-watch.js') diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-expressions-watch.js b/devtools/client/debugger/test/mochitest/browser_dbg-expressions-watch.js new file mode 100644 index 0000000000..5f2c6aba40 --- /dev/null +++ b/devtools/client/debugger/test/mochitest/browser_dbg-expressions-watch.js @@ -0,0 +1,91 @@ +/* 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 . */ + +/** + * Test the watch expressions "refresh" button: + * - hidden when no expression is available + * - visible with one or more expressions + * - updates expressions values after clicking on it + * - disappears when all expressions are removed + */ + +"use strict"; + +add_task(async function () { + const dbg = await initDebugger("doc-script-switching.html"); + + invokeInTab("firstCall"); + await waitForPaused(dbg); + + ok( + !getRefreshExpressionsElement(dbg), + "No refresh button is displayed when there are no watch expressions" + ); + + await addExpression(dbg, "someVariable"); + + ok( + getRefreshExpressionsElement(dbg), + "Refresh button is displayed after adding a watch expression" + ); + + is( + getWatchExpressionLabel(dbg, 1), + "someVariable", + "Watch expression was added" + ); + is( + getWatchExpressionValue(dbg, 1), + "(unavailable)", + "Watch expression has no value" + ); + + info("Switch to the console and update the value of the watched variable"); + const { hud } = await dbg.toolbox.selectTool("webconsole"); + await evaluateExpressionInConsole(hud, "var someVariable = 1"); + + info("Switch back to the debugger"); + await dbg.toolbox.selectTool("jsdebugger"); + + is( + getWatchExpressionLabel(dbg, 1), + "someVariable", + "Watch expression is still available" + ); + is( + getWatchExpressionValue(dbg, 1), + "(unavailable)", + "Watch expression still has no value" + ); + + info( + "Click on the watch expression refresh button and wait for the " + + "expression to update." + ); + const refreshed = waitForDispatch(dbg.store, "EVALUATE_EXPRESSIONS"); + await clickElement(dbg, "expressionRefresh"); + await refreshed; + + is( + getWatchExpressionLabel(dbg, 1), + "someVariable", + "Watch expression is still available" + ); + is( + getWatchExpressionValue(dbg, 1), + "1", + "Watch expression value has been updated" + ); + + await deleteExpression(dbg, "someVariable"); + + ok( + !getRefreshExpressionsElement(dbg), + "The refresh button is no longer displayed after removing watch expressions" + ); +}); + +function getRefreshExpressionsElement(dbg) { + return findElement(dbg, "expressionRefresh", 1); +} -- cgit v1.2.3