Commit 65fb779c authored by Alexandre Poirot's avatar Alexandre Poirot
Browse files

Bug 1759818 - [devtools] Assert the breakable lines for iframe html pages. r=bomsy

While adding this new html page for breakable lines,
I revisit how we load same-url.sjs and use this iframe document instead.
This feel more natural than dynamically injecting a document-builder iframe.

Also I promote breakable lines and positions tests to become features tests.

And it looks like adding the iframe target slow things down for the quick open.
So I tuned the related assertion to avoid intermittents.

Last but not least, this patch highlights two limitations for iframe html debugging:
* only the first inline script is "breakable" (others are ignored)
* on reload, no content is displayed at all (this is new to me)

Differential Revision: https://phabricator.services.mozilla.com/D143989
parent 7a084ed8
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ prefs =

# Feature tests:
[browser_dbg-features-asm.js]
[browser_dbg-features-breakable-lines.js]
[browser_dbg-features-breakable-positions.js]
[browser_dbg-features-source-tree.js]
[browser_dbg-features-source-text-content.js]
[browser_dbg-features-wasm.js]
@@ -37,8 +39,6 @@ prefs =
[browser_dbg-asyncstacks.js]
[browser_dbg-audiocontext.js]
[browser_dbg-async-stepping.js]
[browser_dbg-breakable-lines.js]
[browser_dbg-breakable-positions.js]
[browser_dbg-sourcemapped-breakpoint-console.js]
skip-if = (os == "win" && ccov) # Bug 1453549
[browser_dbg-xhr-breakpoints.js]
+27 −3
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ add_task(async function testBreakableLinesOverReloads() {
  );

  info("Assert breakable lines of the first html page load");
  await assertBreakableLines(dbg, "index.html", 57, [
  await assertBreakableLines(dbg, "index.html", 59, [
    [16, 17],
    [21],
    [23],
@@ -40,22 +40,46 @@ add_task(async function testBreakableLinesOverReloads() {
  info("Assert breakable lines of the simple first load of script.js");
  await assertBreakableLines(dbg, "script.js", 3, [[1], [3]]);

  info("Assert breakable lines of the first iframe page load");
  await assertBreakableLines(dbg, "iframe.html", 30, [
    [16, 17],
    // [22, 23], // We only see the first inline script as breakable
  ]);

  info(
    "Reload the page, wait for sources and assert that breakable lines get updated"
  );
  testServer.switchToNextVersion();
  await reload(dbg, "index.html", "script.js", "original.js");
  await reload(dbg, "index.html", "script.js", "original.js", "iframe.html");

  info("Assert breakable lines of the more complex second load of script.js");
  await assertBreakableLines(dbg, "script.js", 23, [[2], [13, 23]]);

  info("Assert breakable lines of the second html page load");
  await assertBreakableLines(dbg, "index.html", 28, [[22], [24]]);
  await assertBreakableLines(dbg, "index.html", 30, [[22], [24]]);

  info("Assert breakable lines of the second orignal file");
  // See first assertion about original.js,
  // the size of original.js doesn't match the size of the test file
  await assertBreakableLines(dbg, "original.js", 18, [[1, 3], [8, 11], [13]]);

  await selectSource(dbg, "iframe.html");
  // When EFT is disabled, iframe.html is a regular source and the right content is displayed
  if (isEveryFrameTargetEnabled()) {
    is(
      getCM(dbg).getValue(),
      `Error: Incorrect contents fetched, please reload.`
    );
  }
  /**
   * Bug 1762381 - Can't assert breakable lines yet, because the iframe page content fails loading

  info("Assert breakable lines of the second iframe page load");
  await assertBreakableLines(dbg, "iframe.html", 27, [
    [15, 17],
    [21, 23],
  ]);
  */
});

function shouldLineBeBreakable(breakableLines, line) {
+2 −2
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ add_task(async function testBreakableLinesOverReloads() {
  );

  info("Assert breakable lines of the first html page load");
  await assertBreakablePositions(dbg, "index.html", 57, [
  await assertBreakablePositions(dbg, "index.html", 59, [
    { line: 16, columns: [6, 14] },
    { line: 17, columns: [] },
    { line: 21, columns: [6, 14] },
@@ -83,7 +83,7 @@ add_task(async function testBreakableLinesOverReloads() {
  ]);

  info("Assert breakable lines of the second html page load");
  await assertBreakablePositions(dbg, "index.html", 28, [
  await assertBreakablePositions(dbg, "index.html", 30, [
    { line: 22, columns: [6, 14] },
    { line: 24, columns: [] },
  ]);
+40 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ const TEST_URL = testServer.urlFor("index.html");

const INTEGRATION_TEST_PAGE_SOURCES = [
  "index.html",
  "iframe.html",
  "script.js",
  "onload.js",
  "test-functions.js",
@@ -268,6 +269,45 @@ add_task(async function testSourceTreeOnTheIntegrationTestPage() {

  await waitForSourcesInSourceTree(dbg, INTEGRATION_TEST_PAGE_SOURCES);

  info(
    "Assert the number of sources and source actors for the same-url.sjs sources"
  );
  const mainThreadSameUrlSource = findSourceInThread(
    dbg,
    "same-url.sjs",
    "Main Thread"
  );
  ok(mainThreadSameUrlSource, "Found same-url.js in the main thread");
  is(
    dbg.selectors.getSourceActorsForSource(mainThreadSameUrlSource.id).length,
    3,
    "same-url.js is loaded 3 times in the main thread"
  );

  const iframeSameUrlSource = findSourceInThread(
    dbg,
    "same-url.sjs",
    testServer.urlFor("iframe.html")
  );
  ok(iframeSameUrlSource, "Found same-url.js in the iframe thread");
  is(
    dbg.selectors.getSourceActorsForSource(iframeSameUrlSource.id).length,
    1,
    "same-url.js is loaded one time in the iframe thread"
  );

  const workerSameUrlSource = findSourceInThread(
    dbg,
    "same-url.sjs",
    "same-url.sjs"
  );
  ok(workerSameUrlSource, "Found same-url.js in the worker thread");
  is(
    dbg.selectors.getSourceActorsForSource(workerSameUrlSource.id).length,
    1,
    "same-url.js is loaded one time in the worker thread"
  );

  info("Assert the content of the named eval");
  await selectSource(dbg, "named-eval.js");
  assertTextContentOnLine(dbg, 3, `console.log("named-eval");`);
+29 −0
Original line number Diff line number Diff line
<!-- Any copyright is dedicated to the Public Domain.
     http://creativecommons.org/publicdomain/zero/1.0/ -->
<!doctype html>

<html>
  <head>
    <meta charset="utf-8"/>
    <title>Iframe v1</title>
  </head>

  <body>
    <!-- A simple inline script, that helps to cover breakable lines/columns -->
    <!-- Have them define first, so that we avoid shifting lines when adding new scripts later in the html -->
    <script>
      // Comment
      console.log('iframe breakable-line');
    </script>

    <!-- A second inline script, that helps cover bugs when having two distinct inline scripts -->
    <script>
      // Another comment
      console.log("second iframe inline script");
    </script>

    <!-- A script whose URL is loaded in many different ways -->
    <script src="same-url.sjs"></script>
  </body>

</html>
Loading