tor-browser

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

browser_identityPopup_clearSiteData_extensions.js (2325B)


      1 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
      2 /* vim: set sts=2 sw=2 et tw=80: */
      3 /* Any copyright is dedicated to the Public Domain.
      4 * http://creativecommons.org/publicdomain/zero/1.0/ */
      5 "use strict";
      6 
      7 /*
      8 *  Test for Bug 1661534 - Extension page: "Clear Cookies and Site Data"
      9 *  does nothing.
     10 *
     11 *  Expected behavior: when viewing a page controlled by a WebExtension,
     12 *  the "Clear Cookies and Site Data..." button should not be visible.
     13 */
     14 
     15 add_task(async function testClearSiteDataFooterHiddenForExtensions() {
     16  // Create an extension that opens an options page
     17  let extension = ExtensionTestUtils.loadExtension({
     18    useAddonManager: "temporary",
     19 
     20    manifest: {
     21      permissions: ["tabs"],
     22      options_ui: {
     23        page: "options.html",
     24        open_in_tab: true,
     25      },
     26    },
     27    files: {
     28      "options.html": `<!DOCTYPE html>
     29        <html>
     30          <head>
     31            <meta charset="utf-8">
     32          </head>
     33          <body>
     34            <h1>This is a test options page for a WebExtension</h1>
     35          </body>
     36        </html>`,
     37    },
     38    async background() {
     39      await browser.runtime.openOptionsPage();
     40      browser.test.sendMessage("optionsopened");
     41    },
     42  });
     43 
     44  // Run the extension and wait until its options page has finished loading
     45  let browser = gBrowser.selectedBrowser;
     46  let browserLoadedPromise = BrowserTestUtils.browserLoaded(browser);
     47  await extension.startup();
     48  await extension.awaitMessage("optionsopened");
     49  await browserLoadedPromise;
     50 
     51  await SpecialPowers.spawn(browser, [], () => {
     52    ok(
     53      content.document.documentURI.startsWith("moz-extension://"),
     54      "Extension page has now finished loading in the browser window"
     55    );
     56  });
     57 
     58  // Open the site identity popup
     59  let { gIdentityHandler } = gBrowser.ownerGlobal;
     60  let promisePanelOpen = BrowserTestUtils.waitForEvent(
     61    gBrowser.ownerGlobal,
     62    "popupshown",
     63    true,
     64    event => event.target == gIdentityHandler._identityPopup
     65  );
     66  gIdentityHandler._identityIconBox.click();
     67  await promisePanelOpen;
     68 
     69  let clearSiteDataFooter = document.getElementById(
     70    "identity-popup-clear-sitedata-footer"
     71  );
     72 
     73  ok(
     74    clearSiteDataFooter.hidden,
     75    "The clear site data footer is hidden on a WebExtension page."
     76  );
     77 
     78  // Unload the extension
     79  await extension.unload();
     80 });