summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/test/mochitest/browser_dbg-expressions-thread.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /devtools/client/debugger/test/mochitest/browser_dbg-expressions-thread.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/debugger/test/mochitest/browser_dbg-expressions-thread.js')
-rw-r--r--devtools/client/debugger/test/mochitest/browser_dbg-expressions-thread.js100
1 files changed, 100 insertions, 0 deletions
diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-expressions-thread.js b/devtools/client/debugger/test/mochitest/browser_dbg-expressions-thread.js
new file mode 100644
index 0000000000..ca0406844b
--- /dev/null
+++ b/devtools/client/debugger/test/mochitest/browser_dbg-expressions-thread.js
@@ -0,0 +1,100 @@
+/* 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 <http://mozilla.org/MPL/2.0/>. */
+
+/**
+ * Test the watch expressions update when selecting a different thread in the thread panel.
+ */
+
+"use strict";
+
+const TEST_COM_URI = `${URL_ROOT_COM_SSL}examples/doc_dbg-fission-frame-sources.html`;
+const TEST_ORG_IFRAME_URI = `${URL_ROOT_ORG_SSL}examples/doc_dbg-fission-frame-sources-frame.html`;
+const DATA_URI = "data:text/html,<title>foo</title>";
+
+add_task(async function () {
+ // Make sure that the thread section is expanded
+ await pushPref("devtools.debugger.threads-visible", true);
+
+ // Load a test page with a remote frame and wait for both sources to be visible.
+ // simple1.js is imported by the main page. simple2.js comes from the frame.
+ const dbg = await initDebuggerWithAbsoluteURL(
+ TEST_COM_URI,
+ "simple1.js",
+ "simple2.js"
+ );
+
+ const threadsPaneEl = await waitForElementWithSelector(
+ dbg,
+ ".threads-pane .header-label"
+ );
+
+ await waitForElement(dbg, "threadsPaneItems");
+ const threadsEl = findAllElements(dbg, "threadsPaneItems");
+ is(threadsEl.length, 2, "There are two threads in the thread panel");
+ const [mainThreadEl, remoteThreadEl] = threadsEl;
+ is(
+ mainThreadEl.textContent,
+ "Main Thread",
+ "first thread displayed is the main thread"
+ );
+ is(
+ remoteThreadEl.textContent,
+ "Test remote frame sources",
+ "second thread displayed is the remote thread"
+ );
+
+ await addExpression(dbg, "document.location.href");
+
+ is(
+ getWatchExpressionValue(dbg, 1),
+ JSON.stringify(TEST_COM_URI),
+ "expression is evaluated on the expected thread"
+ );
+
+ info(
+ "Select the remote frame thread and check that the expression is updated"
+ );
+ let onExpressionsEvaluated = waitForDispatch(
+ dbg.store,
+ "EVALUATE_EXPRESSIONS"
+ );
+ remoteThreadEl.click();
+ await onExpressionsEvaluated;
+
+ is(
+ getWatchExpressionValue(dbg, 1),
+ JSON.stringify(TEST_ORG_IFRAME_URI),
+ "expression is evaluated on the remote origin thread"
+ );
+
+ info("Select the main thread again and check that the expression is updated");
+ onExpressionsEvaluated = waitForDispatch(dbg.store, "EVALUATE_EXPRESSIONS");
+ mainThreadEl.click();
+ await onExpressionsEvaluated;
+
+ is(
+ getWatchExpressionValue(dbg, 1),
+ JSON.stringify(TEST_COM_URI),
+ "expression is evaluated on the main thread again"
+ );
+
+ // close the threads pane so following test don't have it open
+ threadsPaneEl.click();
+
+ await navigateToAbsoluteURL(dbg, DATA_URI);
+
+ is(
+ getWatchExpressionValue(dbg, 1),
+ JSON.stringify(DATA_URI),
+ "The location.host expression is updated after a navigaiton"
+ );
+
+ await addExpression(dbg, "document.title");
+
+ is(
+ getWatchExpressionValue(dbg, 2),
+ `"foo"`,
+ "We can add expressions after a navigation"
+ );
+});