summaryrefslogtreecommitdiffstats
path: root/devtools/client/storage/test/browser_storage_sidebar_toggle.js
blob: 3e27e23e88242fac9f7adacc437f49d7a904b814 (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
/* 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/. */

// Test to verify that the sidebar toggles when the toggle button is clicked.

"use strict";

const testCases = [
  {
    location: ["cookies", "https://sectest1.example.org"],
    sidebarHidden: true,
    toggleButtonVisible: false,
  },
  {
    location: getCookieId("cs2", ".example.org", "/"),
    sidebarHidden: false,
    toggleButtonVisible: true,
  },
  {
    clickToggle: true,
  },
  {
    location: getCookieId("cs2", ".example.org", "/"),
    sidebarHidden: true,
  },
];

add_task(async function () {
  // storage-listings.html explicitly mixes secure and insecure frames.
  // We should not enforce https for tests using this page.
  await pushPref("dom.security.https_first", false);

  await openTabAndSetupStorage(MAIN_DOMAIN + "storage-listings.html");

  for (const test of testCases) {
    const { location, sidebarHidden, clickToggle, toggleButtonVisible } = test;

    info("running " + JSON.stringify(test));

    if (Array.isArray(location)) {
      await selectTreeItem(location);
    } else if (location) {
      await selectTableItem(location);
    }

    if (clickToggle) {
      toggleSidebar();
    } else if (typeof toggleButtonHidden !== "undefined") {
      is(
        sidebarToggleVisible(),
        toggleButtonVisible,
        "correct visibility state of toggle button"
      );
    } else {
      is(
        gUI.sidebar.hidden,
        sidebarHidden,
        "correct visibility state of sidebar."
      );
    }

    info("-".repeat(80));
  }
});