summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/test/mochitest/browser_dbg-editor-scroll.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /devtools/client/debugger/test/mochitest/browser_dbg-editor-scroll.js
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/debugger/test/mochitest/browser_dbg-editor-scroll.js')
-rw-r--r--devtools/client/debugger/test/mochitest/browser_dbg-editor-scroll.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-editor-scroll.js b/devtools/client/debugger/test/mochitest/browser_dbg-editor-scroll.js
new file mode 100644
index 0000000000..f69c0c9b71
--- /dev/null
+++ b/devtools/client/debugger/test/mochitest/browser_dbg-editor-scroll.js
@@ -0,0 +1,48 @@
+/* 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/>. */
+
+// Tests that the editor keeps proper scroll position per document
+// while also moving to the correct location upon pause/breakpoint selection
+
+"use strict";
+
+requestLongerTimeout(2);
+
+add_task(async function() {
+ // This test runs too slowly on linux debug. I'd like to figure out
+ // which is the slowest part of this and make it run faster, but to
+ // fix a frequent failure allow a longer timeout.
+ const dbg = await initDebugger("doc-editor-scroll.html");
+
+ // Set the initial breakpoint.
+ await selectSource(dbg, "simple1.js");
+ await addBreakpoint(dbg, "simple1.js", 26);
+
+ const cm = getCM(dbg);
+
+ info("Open long file, scroll down to line below the fold");
+ await selectSource(dbg, "long.js");
+ cm.scrollTo(0, 600);
+
+ info("Ensure vertical scroll is the same after switching documents");
+ await selectSource(dbg, "simple1.js");
+ is(cm.getScrollInfo().top, 0);
+ await selectSource(dbg, "long.js");
+ is(cm.getScrollInfo().top, 600);
+
+ info("Trigger a pause, click on a frame, ensure the right line is selected");
+ invokeInTab("doNamedEval");
+ await waitForPaused(dbg);
+ findElement(dbg, "frame", 1).focus();
+ await clickElement(dbg, "frame", 1);
+ ok(cm.getScrollInfo().top != 0, "frame scrolled down to correct location");
+
+ info("Navigating while paused, goes to the correct location");
+ await selectSource(dbg, "long.js");
+ is(cm.getScrollInfo().top, 600);
+
+ info("Open new source, ensure it's at 0 scroll");
+ await selectSource(dbg, "frames.js");
+ is(cm.getScrollInfo().top, 0);
+});