summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/tabs/browser_tab_manager_visibility.js
blob: cfec0fa5282cd2a3ef14c1a5f8cbb89726e1e37a (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
/**
 * Test the Tab Manager visibility respects browser.tabs.tabmanager.enabled preference
 *  */

"use strict";

// The hostname for the test URIs.
const TEST_HOSTNAME = "https://example.com";
const DUMMY_PAGE_PATH = "/browser/base/content/test/tabs/dummy_page.html";

add_task(async function tab_manager_visibility_preference_on() {
  Services.prefs.setBoolPref("browser.tabs.tabmanager.enabled", true);

  let newWindow =
    await BrowserTestUtils.openNewWindowWithFlushedCacheForMozSupports();
  await BrowserTestUtils.withNewTab(
    {
      gBrowser: newWindow.gBrowser,
      url: TEST_HOSTNAME + DUMMY_PAGE_PATH,
    },
    async function (browser) {
      await Assert.ok(
        BrowserTestUtils.is_visible(
          newWindow.document.getElementById("alltabs-button")
        ),
        "tab manage menu is visible when browser.tabs.tabmanager.enabled preference is set to true"
      );
    }
  );
  Services.prefs.clearUserPref("browser.tabs.tabmanager.enabled");
  BrowserTestUtils.closeWindow(newWindow);
});

add_task(async function tab_manager_visibility_preference_off() {
  Services.prefs.setBoolPref("browser.tabs.tabmanager.enabled", false);

  let newWindow =
    await BrowserTestUtils.openNewWindowWithFlushedCacheForMozSupports();
  await BrowserTestUtils.withNewTab(
    {
      gBrowser: newWindow.gBrowser,
      url: TEST_HOSTNAME + DUMMY_PAGE_PATH,
    },
    async function (browser) {
      await Assert.ok(
        BrowserTestUtils.is_hidden(
          newWindow.document.getElementById("alltabs-button")
        ),
        "tab manage menu is hidden when browser.tabs.tabmanager.enabled preference is set to true"
      );
    }
  );
  Services.prefs.clearUserPref("browser.tabs.tabmanager.enabled");
  BrowserTestUtils.closeWindow(newWindow);
});