summaryrefslogtreecommitdiffstats
path: root/accessible/tests/mochitest/aom/test_general.html
blob: 5812ac55f5f41cbd7ac70bbca1d5ce75b0579308 (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
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Accessibility API: generic</title>
  <link rel="stylesheet" type="text/css"
        href="chrome://mochikit/content/tests/SimpleTest/test.css">
  <script type="application/javascript"
          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  <script>
  'use strict';

  SimpleTest.waitForExplicitFinish();
  const finish = SimpleTest.finish.bind(SimpleTest);
  enablePref()
    .then(createIframe)
    .then(checkImplementation)
    .catch(err => {
      dump(`${err}: ${err.stack}`);
      finish();
    });

  function enablePref() {
    const ops = {
      "set": [
        [ "accessibility.AOM.enabled", true ],
      ],
    };
    return SpecialPowers.pushPrefEnv(ops);
  }

  // WebIDL conditional annotations for an interface are evaluated once per
  // global, so we need to create an iframe to see the effects of calling
  // enablePref().
  function createIframe() {
    return new Promise((resolve) => {
      let iframe = document.createElement("iframe");
      iframe.src = "about:blank";
      iframe.onload = () => resolve(iframe.contentDocument);
      document.body.appendChild(iframe);
    });
  }

  // Check that the WebIDL is as expected.
  function checkImplementation(ifrDoc) {
    let anode = ifrDoc.accessibleNode;
    ok(anode, "DOM document has accessible node");

    is(anode.role, 'document', 'correct role of a document accessible node');
    is(anode.DOMNode, ifrDoc, 'correct DOM Node of a document accessible node');

    finish();
  }
  </script>
</head>