tor-browser

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

browser_identityPopup_clearSiteData_privateBrowsingMode.js (2007B)


      1 /**
      2 * Test: browser_identityPopup_clearSiteData_privateBrowsingMode.js
      3 *
      4 * This browser-chrome test verifies that the "Clear Site Data" controls
      5 * (button and footer) in the identity popup are correctly hidden in
      6 * private browsing mode.
      7 *
      8 * The test opens a private browsing window, loads a known HTTPS page
      9 * (`https://example.com/`), opens the identity popup via the identity
     10 * icon, and checks for the visibility of:
     11 *
     12 * - `identity-popup-clear-sitedata-footer`
     13 * - `identity-popup-clear-sitedata-button`
     14 *
     15 * Expected behavior:
     16 * These elements should not be visible while in private browsing mode.
     17 *
     18 * The test uses `BrowserTestUtils.withNewTab()` to load the page in a new
     19 * tab within the private window and ensures cleanup of both the tab and
     20 * window after the test completes.
     21 *
     22 */
     23 
     24 add_task(async function clearSiteDataHidden() {
     25  const TEST_URL = "https://example.com/";
     26 
     27  // Open a private browsing window
     28  const winPrivate = await BrowserTestUtils.openNewBrowserWindow({
     29    private: true,
     30  });
     31 
     32  // Use withNewTab to open a tab in the private window
     33  await BrowserTestUtils.withNewTab(
     34    {
     35      gBrowser: winPrivate.gBrowser,
     36      url: TEST_URL,
     37    },
     38    async _browser => {
     39      let doc = winPrivate.document;
     40      let { gIdentityHandler } = winPrivate;
     41 
     42      let panelShown = BrowserTestUtils.waitForEvent(doc, "popupshown");
     43      gIdentityHandler._identityIconBox.click();
     44      await panelShown;
     45 
     46      let clearFooter = doc.getElementById(
     47        "identity-popup-clear-sitedata-footer"
     48      );
     49      let clearButton = doc.getElementById(
     50        "identity-popup-clear-sitedata-button"
     51      );
     52 
     53      Assert.ok(
     54        BrowserTestUtils.isHidden(clearFooter),
     55        "The clear data footer should be hidden in private browsing."
     56      );
     57      Assert.ok(
     58        BrowserTestUtils.isHidden(clearButton),
     59        "The clear data button should be hidden in private browsing."
     60      );
     61    }
     62  );
     63 
     64  await BrowserTestUtils.closeWindow(winPrivate);
     65 });