summaryrefslogtreecommitdiffstats
path: root/browser/components/customizableui/test/browser_1702200_PanelMultiView_header_separator.js
blob: 471d33c37a092a884186cc33b4b1332a422ecb03 (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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

/**
 * Tests whether the separator insertion works correctly for the
 * special case where we remove the content except the header itself
 * before showing the panel view.
 */

const TEST_SITE = "http://127.0.0.1";
const RECENTLY_CLOSED_TABS_PANEL_ID = "appMenu-library-recentlyClosedTabs";
const RECENTLY_CLOSED_TABS_ITEM_ID = "appMenuRecentlyClosedTabs";

function assertHeaderSeparator() {
  let header = document.querySelector(
    `#${RECENTLY_CLOSED_TABS_PANEL_ID} .panel-header`
  );
  Assert.equal(
    header.nextSibling.tagName,
    "toolbarseparator",
    "toolbarseparator should be shown below header"
  );
}

/**
 * Open and close a tab so we can access the "Recently
 * closed tabs" panel
 */
add_task(async function test_setup() {
  let tab = BrowserTestUtils.addTab(gBrowser, TEST_SITE);
  gBrowser.selectedTab = tab;

  let browser = gBrowser.getBrowserForTab(tab);
  await BrowserTestUtils.browserLoaded(browser, false, null, true);
  await BrowserTestUtils.removeTab(tab);
});

/**
 * Tests whether the toolbarseparator is shown correctly
 * after re-entering same sub view, see bug 1702200
 *
 * - App Menu
 *   - History
 *     - Recently closed tabs
 */
add_task(async function test_header_toolbarseparator() {
  await gCUITestUtils.openMainMenu();

  let historyView = PanelMultiView.getViewNode(document, "PanelUI-history");
  document.getElementById("appMenu-history-button").click();
  await BrowserTestUtils.waitForEvent(historyView, "ViewShown");

  // Open Recently Closed Tabs and make sure there is a header separator
  let closedTabsView = PanelMultiView.getViewNode(
    document,
    RECENTLY_CLOSED_TABS_PANEL_ID
  );
  Assert.ok(!document.getElementById(RECENTLY_CLOSED_TABS_ITEM_ID).disabled);
  document.getElementById(RECENTLY_CLOSED_TABS_ITEM_ID).click();
  await BrowserTestUtils.waitForEvent(closedTabsView, "ViewShown");
  assertHeaderSeparator();

  // Go back and re-open the same view, header separator should be
  // re-added as well
  document
    .querySelector(`#${RECENTLY_CLOSED_TABS_PANEL_ID} .subviewbutton-back`)
    .click();
  await BrowserTestUtils.waitForEvent(historyView, "ViewShown");
  document.getElementById(RECENTLY_CLOSED_TABS_ITEM_ID).click();
  await BrowserTestUtils.waitForEvent(closedTabsView, "ViewShown");
  assertHeaderSeparator();

  await gCUITestUtils.hideMainMenu();
});