summaryrefslogtreecommitdiffstats
path: root/browser/components/firefoxview/tests/browser/browser_firefoxview_feature_callout_a11y.js
blob: 7386f109f5b931b6f1b2ad7c7eea678d218804a1 (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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

/**
 * Tests that are related to the accessibility of the feature callout
 */

/**
 * Ensure feature tour is accessible using a screen reader and with
 * keyboard navigation.
 */
add_task(async function feature_callout_is_accessible() {
  await SpecialPowers.pushPrefEnv({
    set: [["browser.firefox-view.feature-tour", getPrefValueByScreen(1)]],
  });

  await BrowserTestUtils.withNewTab(
    {
      gBrowser,
      url: "about:firefoxview",
    },
    async browser => {
      const { document } = browser.contentWindow;
      await waitForCalloutScreen(document, "FEATURE_CALLOUT_1");

      await BrowserTestUtils.waitForCondition(
        () => document.activeElement.value === "primary_button",
        `Feature Callout primary button is focused on page load}`
      );
      ok(true, "Feature Callout primary button was focused on page load");

      await BrowserTestUtils.waitForCondition(
        () =>
          document.querySelector(
            `${calloutSelector}[aria-describedby="#${calloutId} .welcome-text"]`
          ),
        "The callout container has an aria-describedby value equal to the screen welcome text"
      );
      ok(true, "The callout container has the correct aria-describedby value");

      // Advance to second screen
      clickPrimaryButton(document);
      await waitForCalloutScreen(document, "FEATURE_CALLOUT_2");

      ok(true, "FEATURE_CALLOUT_2 was successfully displayed");
      await BrowserTestUtils.waitForCondition(
        () => document.activeElement.value == "primary_button",
        "Feature Callout primary button is focused after advancing screens"
      );
      ok(true, "Feature Callout primary button was successfully focused");
    }
  );
});