tor-browser

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

browser_openPreferences.js (2071B)


      1 "use strict";
      2 
      3 var gTestTab;
      4 var gContentAPI;
      5 
      6 add_task(setup_UITourTest);
      7 
      8 add_UITour_task(async function test_openPreferences() {
      9  let promiseTabOpened = BrowserTestUtils.waitForNewTab(
     10    gBrowser,
     11    "about:preferences"
     12  );
     13  await gContentAPI.openPreferences();
     14  let tab = await promiseTabOpened;
     15  BrowserTestUtils.removeTab(tab);
     16 });
     17 
     18 add_UITour_task(async function test_openInvalidPreferences() {
     19  await gContentAPI.openPreferences(999);
     20 
     21  try {
     22    await waitForConditionPromise(() => {
     23      return gBrowser.selectedBrowser.currentURI.spec.startsWith(
     24        "about:preferences"
     25      );
     26    }, "Check if about:preferences opened");
     27    ok(false, "No about:preferences tab should have opened");
     28  } catch (ex) {
     29    ok(true, "No about:preferences tab opened: " + ex);
     30  }
     31 });
     32 
     33 add_UITour_task(async function test_openPrivacyPreferences() {
     34  let promiseTabOpened = BrowserTestUtils.waitForNewTab(
     35    gBrowser,
     36    "about:preferences#privacy"
     37  );
     38  await gContentAPI.openPreferences("privacy");
     39  let tab = await promiseTabOpened;
     40  BrowserTestUtils.removeTab(tab);
     41 });
     42 
     43 add_UITour_task(async function test_openPrivacyReports() {
     44  if (
     45    !AppConstants.MOZ_TELEMETRY_REPORTING &&
     46    !(AppConstants.MOZ_DATA_REPORTING && AppConstants.MOZ_CRASHREPORTER)
     47  ) {
     48    return;
     49  }
     50  let promiseTabOpened = BrowserTestUtils.waitForNewTab(
     51    gBrowser,
     52    "about:preferences#privacy-reports"
     53  );
     54  await gContentAPI.openPreferences("privacy-reports");
     55  let tab = await promiseTabOpened;
     56  await BrowserTestUtils.waitForEvent(gBrowser.selectedBrowser, "Initialized");
     57  let doc = gBrowser.selectedBrowser.contentDocument;
     58  is(
     59    doc.location.hash,
     60    "#privacy",
     61    "Should not display the reports subcategory in the location hash."
     62  );
     63  await TestUtils.waitForCondition(
     64    () => doc.querySelector(".spotlight"),
     65    "Wait for the reports section is spotlighted."
     66  );
     67  is(
     68    doc.querySelector(".spotlight").getAttribute("data-subcategory"),
     69    "reports",
     70    "The reports section is spotlighted."
     71  );
     72  BrowserTestUtils.removeTab(tab);
     73 });