tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_1702200_PanelMultiView_header_separator.js (2475B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /**
      7 * Tests whether the separator insertion works correctly for the
      8 * special case where we remove the content except the header itself
      9 * before showing the panel view.
     10 */
     11 
     12 const TEST_SITE = "http://127.0.0.1";
     13 const RECENTLY_CLOSED_TABS_PANEL_ID = "appMenu-library-recentlyClosedTabs";
     14 const RECENTLY_CLOSED_TABS_ITEM_ID = "appMenuRecentlyClosedTabs";
     15 
     16 function assertHeaderSeparator() {
     17  let header = document.querySelector(
     18    `#${RECENTLY_CLOSED_TABS_PANEL_ID} .panel-header`
     19  );
     20  Assert.equal(
     21    header.nextSibling.tagName,
     22    "toolbarseparator",
     23    "toolbarseparator should be shown below header"
     24  );
     25 }
     26 
     27 /**
     28 * Open and close a tab so we can access the "Recently
     29 * closed tabs" panel
     30 */
     31 add_task(async function test_setup() {
     32  let tab = BrowserTestUtils.addTab(gBrowser, TEST_SITE);
     33  gBrowser.selectedTab = tab;
     34 
     35  let browser = gBrowser.getBrowserForTab(tab);
     36  await BrowserTestUtils.browserLoaded(browser, false, null, true);
     37  await BrowserTestUtils.removeTab(tab);
     38 });
     39 
     40 /**
     41 * Tests whether the toolbarseparator is shown correctly
     42 * after re-entering same sub view, see bug 1702200
     43 *
     44 * - App Menu
     45 *   - History
     46 *     - Recently closed tabs
     47 */
     48 add_task(async function test_header_toolbarseparator() {
     49  await gCUITestUtils.openMainMenu();
     50 
     51  let historyView = PanelMultiView.getViewNode(document, "PanelUI-history");
     52  document.getElementById("appMenu-history-button").click();
     53  await BrowserTestUtils.waitForEvent(historyView, "ViewShown");
     54 
     55  // Open Recently Closed Tabs and make sure there is a header separator
     56  let closedTabsView = PanelMultiView.getViewNode(
     57    document,
     58    RECENTLY_CLOSED_TABS_PANEL_ID
     59  );
     60  Assert.ok(!document.getElementById(RECENTLY_CLOSED_TABS_ITEM_ID).disabled);
     61  document.getElementById(RECENTLY_CLOSED_TABS_ITEM_ID).click();
     62  await BrowserTestUtils.waitForEvent(closedTabsView, "ViewShown");
     63  assertHeaderSeparator();
     64 
     65  // Go back and re-open the same view, header separator should be
     66  // re-added as well
     67  document
     68    .querySelector(`#${RECENTLY_CLOSED_TABS_PANEL_ID} .subviewbutton-back`)
     69    .click();
     70  await BrowserTestUtils.waitForEvent(historyView, "ViewShown");
     71  document.getElementById(RECENTLY_CLOSED_TABS_ITEM_ID).click();
     72  await BrowserTestUtils.waitForEvent(closedTabsView, "ViewShown");
     73  assertHeaderSeparator();
     74 
     75  await gCUITestUtils.hideMainMenu();
     76 });