summaryrefslogtreecommitdiffstats
path: root/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_sidebar_network_runtimes.js
blob: 0482aa70c2e5e2fe446384c79b24df93a8f47404 (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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

const networkLocationsModule = require("resource://devtools/client/aboutdebugging/src/modules/network-locations.js");

/**
 * Test the sidebar is updated correctly when network runtimes are added/removed.
 */

add_task(async function () {
  registerCleanupFunction(() => {
    Services.prefs.clearUserPref("devtools.aboutdebugging.network-locations");
  });

  const { document, tab } = await openAboutDebugging();

  const noDevicesElement = document.querySelector(".qa-sidebar-no-devices");
  ok(noDevicesElement, "Sidebar shows the 'no devices' element");

  info("Add a network location");
  networkLocationsModule.addNetworkLocation("localhost:6080");

  info("Wait for 'no devices' element to disappear");
  waitUntil(() => !document.querySelector(".qa-sidebar-no-devices"));
  ok(
    findSidebarItemByText("localhost:6080", document),
    "Found a sidebar item for localhost:6080"
  );

  info("Remove the network location");
  networkLocationsModule.removeNetworkLocation("localhost:6080");

  info("Wait for 'no devices' element to reappear");
  waitUntil(() => document.querySelector(".qa-sidebar-no-devices"));
  ok(
    !findSidebarItemByText("localhost:6080", document),
    "Sidebar item for localhost:6080 removed"
  );

  await removeTab(tab);
});