summaryrefslogtreecommitdiffstats
path: root/browser/components/preferences/tests/browser_spotlight.js
blob: 4a1aae7ec1ae57fc795eab87fa8c94c8d7037be6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
add_task(async function test_openPreferences_spotlight() {
  for (let [arg, expectedPane, expectedHash, expectedSubcategory] of [
    ["privacy-reports", "panePrivacy", "#privacy", "reports"],
    ["privacy-address-autofill", "panePrivacy", "#privacy", "address-autofill"],
    [
      "privacy-credit-card-autofill",
      "panePrivacy",
      "#privacy",
      "credit-card-autofill",
    ],
    ["privacy-form-autofill", "panePrivacy", "#privacy", "form-autofill"],
    ["privacy-logins", "panePrivacy", "#privacy", "logins"],
    [
      "privacy-trackingprotection",
      "panePrivacy",
      "#privacy",
      "trackingprotection",
    ],
    [
      "privacy-permissions-block-popups",
      "panePrivacy",
      "#privacy",
      "permissions-block-popups",
    ],
  ]) {
    if (
      arg == "privacy-credit-card-autofill" &&
      Services.prefs.getCharPref(
        "extensions.formautofill.creditCards.supported"
      ) == "off"
    ) {
      continue;
    }
    if (
      arg == "privacy-address-autofill" &&
      Services.prefs.getCharPref(
        "extensions.formautofill.addresses.supported"
      ) == "off"
    ) {
      continue;
    }

    let prefs = await openPreferencesViaOpenPreferencesAPI(arg, {
      leaveOpen: true,
    });
    is(prefs.selectedPane, expectedPane, "The right pane is selected");
    let doc = gBrowser.contentDocument;
    is(
      doc.location.hash,
      expectedHash,
      "The subcategory should be removed from the URI"
    );
    await TestUtils.waitForCondition(
      () => doc.querySelector(".spotlight"),
      "Wait for the spotlight"
    );
    is(
      doc.querySelector(".spotlight").getAttribute("data-subcategory"),
      expectedSubcategory,
      "The right subcategory is spotlighted"
    );

    doc.defaultView.spotlight(null);
    is(
      doc.querySelector(".spotlight"),
      null,
      "The spotlighted section is cleared"
    );

    BrowserTestUtils.removeTab(gBrowser.selectedTab);
  }
});