Bug 1717802 - [devtools] Fission test for event breakpoint with remote frames r=ochameau
authorHubert Boma Manilla <hmanilla@mozilla.com>
Thu, 23 Sep 2021 08:53:57 +0000
changeset 593041 38352a9dc127208982d92372c357e1a706fca246
parent 593040 22900522693fd055fd0747b2ffd020df7aaea81d
child 593042 c5fb4b924b54eb003fd27257ee8d4e14b6f3d22c
push id150255
push userhmanilla@mozilla.com
push dateThu, 23 Sep 2021 08:56:24 +0000
treeherderautoland@38352a9dc127 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1717802
milestone94.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 1717802 - [devtools] Fission test for event breakpoint with remote frames r=ochameau Differential Revision: https://phabricator.services.mozilla.com/D125685
devtools/client/debugger/test/mochitest/browser.ini
devtools/client/debugger/test/mochitest/browser_dbg-event-breakpoints-fission.js
devtools/client/debugger/test/mochitest/examples/doc-event-breakpoints-fission.html
--- a/devtools/client/debugger/test/mochitest/browser.ini
+++ b/devtools/client/debugger/test/mochitest/browser.ini
@@ -213,16 +213,17 @@ skip-if =
 [browser_dbg-worker-scopes.js]
 skip-if =
   os == 'linux' && debug # Bug 1456013
   ccov # Bug 1456013
   os == 'linux' && asan # Bug 1559547
   os == 'mac' # Bug 1607321
   os == 'win' && os_version == '10.0' && bits == 64 # Bug 1607321
 [browser_dbg-event-handler.js]
+[browser_dbg-event-breakpoints-fission.js]
 [browser_dbg-event-breakpoints.js]
 [browser_dbg-eval-throw.js]
 [browser_dbg-sourceURL-breakpoint.js]
 [browser_dbg-old-breakpoint.js]
 skip-if = os == "linux" || os == "mac" #Bug 1644044
 [browser_dbg-idb-run-to-completion.js]
 [browser_dbg-inline-script-offset.js]
 [browser_dbg-scopes-duplicated.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/test/mochitest/browser_dbg-event-breakpoints-fission.js
@@ -0,0 +1,80 @@
+/* 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 early event breakpoints and event breakpoints in a remote frame.
+
+add_task(async function () {
+    await pushPref(
+    "devtools.debugger.features.event-listeners-breakpoints",
+    true
+  );
+
+  const dbg = await initDebugger(
+    "doc-event-breakpoints-fission.html",
+    "event-breakpoints"
+  );
+
+  await selectSource(dbg, "event-breakpoints");
+  await waitForSelectedSource(dbg, "event-breakpoints");
+
+  await dbg.actions.addEventListenerBreakpoints([
+    "event.mouse.click",
+    "event.xhr.load",
+    "timer.timeout.set"
+  ]);
+
+  info("Assert early timeout event breakpoint gets hit");
+  const waitForReload = reloadBrowser();
+
+  await waitForPaused(dbg);
+  assertPauseLocation(dbg, 17, "doc-event-breakpoints-fission.html");
+  await resume(dbg);
+
+  await waitForReload;
+
+  info("Assert event breakpoints work in remote frame");
+  await invokeAndAssertBreakpoints(dbg);
+
+  info("reload the iframe")
+  await SpecialPowers.spawn(gBrowser.selectedBrowser, [], () =>
+    content.wrappedJSObject.reloadIframe()
+  );
+  info("Assert event breakpoints work in remote frame after reload");
+  await invokeAndAssertBreakpoints(dbg);
+});
+
+async function invokeAndAssertBreakpoints(dbg) {
+  invokeInTabRemoteFrame("clickHandler");
+  await waitForPaused(dbg);
+  assertPauseLocation(dbg, 12);
+  await resume(dbg);
+
+  invokeInTabRemoteFrame("xhrHandler");
+  await waitForPaused(dbg);
+  assertPauseLocation(dbg, 20);
+  await resume(dbg);
+}
+
+function assertPauseLocation(dbg, line, url = "event-breakpoints.js") {
+  const { location } = dbg.selectors.getVisibleSelectedFrame();
+  const selectedSource = dbg.selectors.getSelectedSourceWithContent();
+
+  is(location.sourceId, selectedSource.id, `Correct selected sourceId`);
+  ok(selectedSource.url.includes(url), "Correct url");
+  is(location.line, line, "Correct paused line");
+
+  assertPausedLocation(dbg);
+}
+
+async function invokeInTabRemoteFrame(fnc, ...args) {
+  info(`Invoking in tab remote frame: ${fnc}(${args.map(uneval).join(",")})`);
+  await SpecialPowers.spawn(gBrowser.selectedBrowser, [fnc, args], function (_fnc, _args) {
+    return SpecialPowers.spawn(
+      content.document.querySelector("iframe"),
+      [_fnc, _args],
+      (__fnc, __args) => content.wrappedJSObject[__fnc](...__args)
+    );
+  });
+}
+
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/test/mochitest/examples/doc-event-breakpoints-fission.html
@@ -0,0 +1,23 @@
+<!-- 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/. -->
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="utf-8"/>
+    <title>Debugger event bp fission test page</title>
+    <script>
+      function reloadIframe() {
+        return new Promise(resolve => {
+          const iframe = document.querySelector("iframe");
+          iframe.addEventListener("load", () => resolve(), { once: true });
+          iframe.setAttribute("src", iframe.getAttribute("src"));
+        });
+      }
+        setTimeout(() => console.log("timeout fired"), 0)
+    </script>
+  </head>
+  <body>
+    <iframe src="http://example.org/browser/devtools/client/debugger/test/mochitest/examples/doc-event-breakpoints.html"></iframe>
+  </body>
+</html>