summaryrefslogtreecommitdiffstats
path: root/devtools/client/framework/test/browser_toolbox_fission_navigation.js
blob: 123a06cce2471195e93e4bc38ceadeb1ce8d9f62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";

const EXAMPLE_COM_URI =
  "https://example.com/document-builder.sjs?html=<div id=com>com";
const EXAMPLE_ORG_URI =
  "https://example.org/document-builder.sjs?html=<div id=org>org";

add_task(async function () {
  const tab = await addTab(EXAMPLE_COM_URI);

  const toolbox = await openToolboxForTab(tab, "inspector");
  const comNode = await getNodeBySelector(toolbox, "#com");
  ok(comNode, "Found node for the COM page");

  info("Navigate to the ORG page");
  await navigateTo(EXAMPLE_ORG_URI);
  const orgNode = await getNodeBySelector(toolbox, "#org");
  ok(orgNode, "Found node for the ORG page");

  info("Reload the ORG page");
  await navigateTo(EXAMPLE_ORG_URI);
  const orgNodeAfterReload = await getNodeBySelector(toolbox, "#org");
  ok(orgNodeAfterReload, "Found node for the ORG page after reload");
  isnot(orgNode, orgNodeAfterReload, "The new node is different");

  info("Navigate back to the COM page");
  await navigateTo(EXAMPLE_COM_URI);
  const comNodeAfterNavigation = await getNodeBySelector(toolbox, "#com");
  ok(comNodeAfterNavigation, "Found node for the COM page after navigation");

  info("Navigate to about:blank");
  await navigateTo("about:blank");
  const blankBodyAfterNavigation = await getNodeBySelector(toolbox, "body");
  ok(
    blankBodyAfterNavigation,
    "Found node for the about:blank page after navigation"
  );

  info("Navigate to about:robots");
  await navigateTo("about:robots");
  const aboutRobotsAfterNavigation = await getNodeBySelector(
    toolbox,
    "div.container"
  );
  ok(
    aboutRobotsAfterNavigation,
    "Found node for the about:robots page after navigation"
  );
});

async function getNodeBySelector(toolbox, selector) {
  const inspector = await toolbox.selectTool("inspector");
  return inspector.walker.querySelector(inspector.walker.rootNode, selector);
}