Bug 1479058 - Add new test.
authorBrian Hackett <bhackett1024@gmail.com>
Tue, 14 Aug 2018 15:34:29 +0000
changeset 431444 c95be400d029a6c961aa77468d123b44f2f1de09
parent 431443 45e3f5d8e29402e8fda2fea772dc5d08d8866fd7
child 431445 f5873a719ec0ba10ca55a09c3a36320ee6abbedb
push id34443
push usercsabou@mozilla.com
push dateWed, 15 Aug 2018 00:53:32 +0000
treeherdermozilla-central@b80906e2fbc9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1479058
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1479058 - Add new test.
devtools/client/debugger/new/test/mochitest/browser.ini
devtools/client/debugger/new/test/mochitest/browser_dbg_rr_console_warp-01.js
devtools/client/debugger/new/test/mochitest/examples/doc_rr_error.html
--- a/devtools/client/debugger/new/test/mochitest/browser.ini
+++ b/devtools/client/debugger/new/test/mochitest/browser.ini
@@ -626,16 +626,17 @@ support-files =
   examples/pause-points.js
   examples/script-mutate.js
   examples/script-switching-02.js
   examples/script-switching-01.js
   examples/times2.js
   examples/doc_rr_basic.html
   examples/doc_rr_continuous.html
   examples/doc_rr_recovery.html
+  examples/doc_rr_error.html
 
 [browser_dbg-asm.js]
 [browser_dbg-async-stepping.js]
 [browser_dbg-sourcemapped-breakpoint-console.js]
 skip-if = (os == "win" && ccov) # Bug 1453549
 [browser_dbg-sourcemapped-scopes.js]
 skip-if = ccov || (verify && debug && (os == 'linux')) # Bug 1441545
 [browser_dbg-sourcemapped-stepping.js]
@@ -743,8 +744,10 @@ skip-if = os != "mac" || debug || !night
 [browser_dbg_rr_recovery-01.js]
 skip-if = true # See bug 1481009
 [browser_dbg_rr_replay-01.js]
 skip-if = os != "mac" || debug || !nightly_build
 [browser_dbg_rr_replay-02.js]
 skip-if = os != "mac" || debug || !nightly_build
 [browser_dbg_rr_replay-03.js]
 skip-if = os != "mac" || debug || !nightly_build
+[browser_dbg_rr_console_warp-01.js]
+skip-if = os != "mac" || debug || !nightly_build
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/new/test/mochitest/browser_dbg_rr_console_warp-01.js
@@ -0,0 +1,83 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+var { HUDService } = require("devtools/client/webconsole/hudservice");
+
+// This functionality was copied from devtools/client/webconsole/test/mochitest/head.js,
+// since this test straddles both the web console and the debugger. I couldn't
+// figure out how to load that script directly here.
+
+function findMessages(hud, text, selector = ".message") {
+  const messages = hud.ui.outputNode.querySelectorAll(selector);
+  const elements = Array.prototype.filter.call(
+    messages,
+    (el) => el.textContent.includes(text)
+  );
+  return elements;
+}
+
+async function openContextMenu(hud, element) {
+  const onConsoleMenuOpened = hud.ui.consoleOutput.once("menu-open");
+  synthesizeContextMenuEvent(element);
+  await onConsoleMenuOpened;
+  const doc = hud.ui.consoleOutput.owner.chromeWindow.document;
+  return doc.getElementById("webconsole-menu");
+}
+
+function hideContextMenu(hud) {
+  const doc = hud.ui.consoleOutput.owner.chromeWindow.document;
+  const popup = doc.getElementById("webconsole-menu");
+  if (!popup) {
+    return Promise.resolve();
+  }
+
+  const onPopupHidden = once(popup, "popuphidden");
+  popup.hidePopup();
+  return onPopupHidden;
+}
+
+// Test basic console time warping functionality in web replay.
+async function test() {
+  waitForExplicitFinish();
+
+  let tab = BrowserTestUtils.addTab(gBrowser, null, { recordExecution: "*" });
+  gBrowser.selectedTab = tab;
+  openTrustedLinkIn(EXAMPLE_URL + "doc_rr_error.html", "current");
+  await once(Services.ppmm, "RecordingFinished");
+
+  let console = await openToolboxForTab(tab, "webconsole");
+  let hud = console.getCurrentPanel().hud;
+  let messages = findMessages(hud, "Number 5");
+  ok(messages.length == 1, "Found one message");
+  let message = messages.pop();
+
+  let menuPopup = await openContextMenu(hud, message);
+  let timeWarpItem = menuPopup.querySelector("#console-menu-time-warp");
+  ok(timeWarpItem, "Time warp menu item is available");
+  timeWarpItem.click();
+  await hideContextMenu(hud);
+
+  await once(Services.ppmm, "TimeWarpFinished");
+
+  let toolbox = await attachDebugger(tab), client = toolbox.threadClient;
+  await client.interrupt();
+
+  await checkEvaluateInTopFrame(client, "number", 5);
+
+  // Initially we are paused inside the 'new Error()' call on line 19. The
+  // first reverse step takes us to the start of that line.
+  await reverseStepOverToLine(client, 19);
+
+  await reverseStepOverToLine(client, 18);
+  await setBreakpoint(client, "doc_rr_error.html", 12);
+  await rewindToLine(client, 12);
+  await checkEvaluateInTopFrame(client, "number", 4);
+  await resumeToLine(client, 12);
+  await checkEvaluateInTopFrame(client, "number", 5);
+
+  await toolbox.destroy();
+  await gBrowser.removeTab(tab);
+  finish();
+}
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/new/test/mochitest/examples/doc_rr_error.html
@@ -0,0 +1,23 @@
+<html lang="en" dir="ltr">
+<body>
+<div id="maindiv">Hello World!</div>
+</body>
+<script>
+const cpmm = SpecialPowers.Services.cpmm;
+function recordingFinished() {
+  cpmm.sendAsyncMessage("RecordingFinished");
+}
+var number = 0;
+function f() {
+  number++;
+  document.getElementById("maindiv").innerHTML = "Number: " + number;
+  if (number >= 10) {
+    window.setTimeout(recordingFinished);
+    return;
+  }
+  window.setTimeout(f, 1);
+  throw new Error("Number " + number);
+}
+window.setTimeout(f, 1);
+</script>
+</html>