summaryrefslogtreecommitdiffstats
path: root/toolkit/components/aboutconfig/test/browser/browser_warning.js
blob: d95e8f49eaa6bcb1263e4566567b3e2b537300e4 (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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

add_setup(async function () {
  await SpecialPowers.pushPrefEnv({
    set: [["browser.aboutConfig.showWarning", true]],
  });
});

add_task(async function test_showWarningNextTime() {
  for (let test of [
    { expectWarningPage: true, disableShowWarningNextTime: false },
    { expectWarningPage: true, disableShowWarningNextTime: true },
    { expectWarningPage: false },
  ]) {
    await AboutConfigTest.withNewTab(
      async function () {
        if (test.expectWarningPage) {
          this.assertWarningPage(true);
          Assert.ok(
            this.document.getElementById("showWarningNextTime").checked
          );
          if (test.disableShowWarningNextTime) {
            this.document.getElementById("showWarningNextTime").click();
          }
          this.bypassWarningButton.click();
        }

        // No results are shown after the warning page is dismissed or bypassed.
        this.assertWarningPage(false);
        Assert.ok(!this.prefsTable.firstElementChild);
        Assert.equal(this.document.activeElement, this.searchInput);

        // The show all button should be present and show all results immediately.
        this.showAll();
        Assert.ok(this.prefsTable.firstElementChild);
      },
      { dontBypassWarning: true }
    );
  }
});