summaryrefslogtreecommitdiffstats
path: root/devtools/client/storage/test/browser_storage_sidebar.js
blob: e55a0365f144113e50b697f6249ca66caf569e26 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/* 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 opens, closes and updates
// This test is not testing the values in the sidebar, being tested in _values

// Format: [
//   <id of the table item to click> or <id array for tree item to select> or
//     null to press Escape,
//   <do we wait for the async "sidebar-updated" event>,
//   <is the sidebar open>
// ]

"use strict";

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

  {
    location: ["localStorage", "http://sectest1.example.org"],
    sidebarHidden: true,
  },
  {
    location: "iframe-u-ls1",
    sidebarHidden: false,
  },
  {
    location: "iframe-u-ls1",
    sidebarHidden: false,
  },
  {
    sendEscape: true,
  },

  {
    location: ["sessionStorage", "http://test1.example.org"],
    sidebarHidden: true,
  },
  {
    location: "ss1",
    sidebarHidden: false,
  },
  {
    sendEscape: true,
  },

  {
    location: ["indexedDB", "http://test1.example.org"],
    sidebarHidden: true,
  },
  {
    location: "idb2 (default)",
    sidebarHidden: false,
  },

  {
    location: [
      "indexedDB",
      "http://test1.example.org",
      "idb2 (default)",
      "obj3",
    ],
    sidebarHidden: true,
  },

  {
    location: ["indexedDB", "https://sectest1.example.org", "idb-s2 (default)"],
    sidebarHidden: true,
  },
  {
    location: "obj-s2",
    sidebarHidden: false,
  },
  {
    sendEscape: true,
  },
  {
    location: "obj-s2",
    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, sendEscape } = test;

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

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

    if (sendEscape) {
      EventUtils.sendKey("ESCAPE", gPanelWindow);
    } else {
      is(
        gUI.sidebar.hidden,
        sidebarHidden,
        "correct visibility state of sidebar."
      );
    }

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