tor-browser

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

browser_spotlight.js (1781B)


      1 add_task(async function test_openPreferences_spotlight() {
      2  for (let [arg, expectedPane, expectedHash, expectedSubcategory] of [
      3    ["privacy-reports", "panePrivacy", "#privacy", "reports"],
      4    ["privacy-address-autofill", "panePrivacy", "#privacy", "address-autofill"],
      5    [
      6      "privacy-payment-methods-autofill",
      7      "panePrivacy",
      8      "#privacy",
      9      "payment-methods-autofill",
     10    ],
     11    ["privacy-logins", "panePrivacy", "#privacy", "logins"],
     12    [
     13      "privacy-trackingprotection",
     14      "panePrivacy",
     15      "#privacy",
     16      "trackingprotection",
     17    ],
     18  ]) {
     19    if (
     20      arg == "privacy-credit-card-autofill" &&
     21      Services.prefs.getCharPref(
     22        "extensions.formautofill.creditCards.supported"
     23      ) == "off"
     24    ) {
     25      continue;
     26    }
     27    if (
     28      arg == "privacy-address-autofill" &&
     29      Services.prefs.getCharPref(
     30        "extensions.formautofill.addresses.supported"
     31      ) == "off"
     32    ) {
     33      continue;
     34    }
     35 
     36    let prefs = await openPreferencesViaOpenPreferencesAPI(arg, {
     37      leaveOpen: true,
     38    });
     39    is(prefs.selectedPane, expectedPane, "The right pane is selected");
     40    let doc = gBrowser.contentDocument;
     41    is(
     42      doc.location.hash,
     43      expectedHash,
     44      "The subcategory should be removed from the URI"
     45    );
     46    await TestUtils.waitForCondition(
     47      () => doc.querySelector(".spotlight"),
     48      "Wait for the spotlight"
     49    );
     50    is(
     51      doc.querySelector(".spotlight").getAttribute("data-subcategory"),
     52      expectedSubcategory,
     53      "The right subcategory is spotlighted"
     54    );
     55 
     56    doc.defaultView.spotlight(null);
     57    is(
     58      doc.querySelector(".spotlight"),
     59      null,
     60      "The spotlighted section is cleared"
     61    );
     62 
     63    BrowserTestUtils.removeTab(gBrowser.selectedTab);
     64  }
     65 });