summaryrefslogtreecommitdiffstats
path: root/devtools/client/application/test/browser/browser_application_panel_target-switching.js
blob: ff8d521e30400abbdbde7bc0adbc57613d7731dd (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
57
58
59
60
61
62
63
64
65
66
67
68
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";

// Test switching for the top-level target.

// We use about:robots, because this page will run in the parent process.
// Navigating from about:robots to a regular content page will always trigger
// a target switch, with or without fission.
const PARENT_PROCESS_URI = "about:robots";
const CONTENT_PROCESS_URI_WORKERS =
  URL_ROOT + "resources/service-workers/simple.html";
const CONTENT_PROCESS_URI_MANIFEST =
  URL_ROOT + "resources/manifest/load-ok.html";

// test workers when target switching
add_task(async function () {
  await enableApplicationPanel();

  info("Open a page that runs in the parent process");
  const { panel, commands, tab } = await openNewTabAndApplicationPanel(
    PARENT_PROCESS_URI
  );
  const doc = panel.panelWin.document;

  info("Check for non-existing service worker");
  selectPage(panel, "service-workers");
  const isWorkerListEmpty = !!doc.querySelector(".js-registration-list-empty");
  ok(isWorkerListEmpty, "No Service Worker displayed");

  info("Navigate to a page that runs in the child process");
  await navigateTo(CONTENT_PROCESS_URI_WORKERS);

  info("Wait until the service worker appears in the application panel");
  await waitUntil(() => getWorkerContainers(doc).length === 1);

  // close the tab
  info("Closing the tab.");
  await unregisterAllWorkers(commands.client, doc);
  await BrowserTestUtils.removeTab(tab);
});

// test manifest when target switching
add_task(async function () {
  await enableApplicationPanel();

  info("Open a page that runs in the parent process");
  const { panel, tab } = await openNewTabAndApplicationPanel(
    PARENT_PROCESS_URI
  );
  const doc = panel.panelWin.document;

  info("Waiting for the 'no manifest' message to appear");
  selectPage(panel, "manifest");
  await waitUntil(() => doc.querySelector(".js-manifest-empty") !== null);

  info("Navigate to a page that runs in the child process");
  await navigateTo(CONTENT_PROCESS_URI_MANIFEST);

  info("Waiting for the manifest to load");
  selectPage(panel, "manifest");
  await waitUntil(() => doc.querySelector(".js-manifest") !== null);
  ok(true, "Manifest loaded successfully");

  // close the tab
  info("Closing the tab.");
  await BrowserTestUtils.removeTab(tab);
});