tor-browser

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

browser_update_interactive_noprompt.js (2523B)


      1 // Set some prefs that apply to all the tests in this file
      2 add_setup(async function () {
      3  await SpecialPowers.pushPrefEnv({
      4    set: [
      5      // We don't have pre-pinned certificates for the local mochitest server
      6      ["extensions.install.requireBuiltInCerts", false],
      7      ["extensions.update.requireBuiltInCerts", false],
      8 
      9      // Don't require the extensions to be signed
     10      ["xpinstall.signatures.required", false],
     11 
     12      // Point updates to the local mochitest server
     13      ["extensions.update.url", `${BASE}/browser_webext_update.json`],
     14    ],
     15  });
     16 });
     17 
     18 // Helper to test that an update of a given extension does not
     19 // generate any permission prompts.
     20 async function testUpdateNoPrompt(
     21  filename,
     22  id,
     23  initialVersion = "1.0",
     24  updateVersion = "2.0"
     25 ) {
     26  // Navigate away to ensure that BrowserOpenAddonMgr() opens a new tab
     27  BrowserTestUtils.startLoadingURIString(
     28    gBrowser.selectedBrowser,
     29    "about:mozilla"
     30  );
     31  await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
     32 
     33  // Install initial version of the test extension
     34  let addon = await promiseInstallAddon(`${BASE}/${filename}`);
     35  ok(addon, "Addon was installed");
     36  is(addon.version, initialVersion, "Version 1 of the addon is installed");
     37 
     38  // Go to Extensions in about:addons
     39  let win = await BrowserAddonUI.openAddonsMgr("addons://list/extension");
     40 
     41  await waitAboutAddonsViewLoaded(win.document);
     42 
     43  let sawPopup = false;
     44  function popupListener() {
     45    sawPopup = true;
     46  }
     47  PopupNotifications.panel.addEventListener("popupshown", popupListener);
     48 
     49  // Trigger an update check, we should see the update get applied
     50  let updatePromise = waitForUpdate(addon);
     51  triggerPageOptionsAction(win, "check-for-updates");
     52  await updatePromise;
     53 
     54  addon = await AddonManager.getAddonByID(id);
     55  is(addon.version, updateVersion, "Should have upgraded");
     56 
     57  ok(!sawPopup, "Should not have seen a permission notification");
     58  PopupNotifications.panel.removeEventListener("popupshown", popupListener);
     59 
     60  BrowserTestUtils.removeTab(gBrowser.selectedTab);
     61  await addon.uninstall();
     62 }
     63 
     64 // Test that we don't see a prompt when no new promptable permissions
     65 // are added.
     66 add_task(() =>
     67  testUpdateNoPrompt(
     68    "browser_webext_update_perms1.xpi",
     69    "update_perms@tests.mozilla.org"
     70  )
     71 );
     72 
     73 // Test that an update that narrows origin permissions is just applied without
     74 // showing a notification promt
     75 add_task(() =>
     76  testUpdateNoPrompt(
     77    "browser_webext_update_origins1.xpi",
     78    "update_origins@tests.mozilla.org"
     79  )
     80 );