tor-browser

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

browser_ignore_invalid_capability.js (1386B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 add_task(async function testInvalidCapabilityIgnored() {
      5  info(
      6    "Test to make sure that invalid combinations of type and capability are ignored \
      7     so the cookieExceptions management popup does not crash"
      8  );
      9  PermissionTestUtils.add(
     10    "https://mozilla.org",
     11    "cookie",
     12    Ci.nsICookiePermission.ACCESS_ALLOW
     13  );
     14 
     15  // This is an invalid combination of type & capability and should be ignored
     16  PermissionTestUtils.add(
     17    "https://foobar.org",
     18    "cookie",
     19    Ci.nsIHttpsOnlyModePermission.LOAD_INSECURE_ALLOW_SESSION
     20  );
     21 
     22  await openPreferencesViaOpenPreferencesAPI("panePrivacy", {
     23    leaveOpen: true,
     24  });
     25  let doc = gBrowser.contentDocument;
     26  let promiseSubDialogLoaded = promiseLoadSubDialog(
     27    "chrome://browser/content/preferences/dialogs/permissions.xhtml"
     28  );
     29 
     30  let cookieExceptionsButton = doc.getElementById("cookieExceptions");
     31  cookieExceptionsButton.scrollIntoView();
     32  EventUtils.synthesizeMouseAtCenter(
     33    cookieExceptionsButton,
     34    {},
     35    doc.ownerGlobal
     36  );
     37 
     38  let win = await promiseSubDialogLoaded;
     39  doc = win.document;
     40 
     41  is(
     42    doc.getElementById("permissionsBox").itemCount,
     43    1,
     44    "We only display the permission that is valid for the type cookie"
     45  );
     46  BrowserTestUtils.removeTab(gBrowser.selectedTab);
     47 });