summaryrefslogtreecommitdiffstats
path: root/accessible/tests/mochitest/editabletext/test_1.html
blob: 693d4c8ee5cc86e4810d9464a9ce88007b85e9b8 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<!DOCTYPE html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=452161
-->
<head>
  <title>nsIAccessibleEditableText chrome tests</title>
  <link rel="stylesheet" type="text/css"
        href="chrome://mochikit/content/tests/SimpleTest/test.css" />

  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>

  <script type="application/javascript"
          src="../common.js"></script>
  <script type="application/javascript"
          src="../events.js"></script>
  <script type="application/javascript"
          src="editabletext.js"></script>

  <script type="application/javascript">
    // gA11yEventDumpToConsole = true;
    // enableLogging("tree,verbose"); // debug

    function addTestEditable(aID, aTestRun, aBeforeContent, aAfterContent) {
      var et = new editableTextTest(aID);
      var startOffset = aBeforeContent ? aBeforeContent.length : 0;
      // XXX afterContent currently is not used

      // ////////////////////////////////////////////////////////////////////////
      // setTextContents
      et.scheduleTest(et.setTextContents, "hello", startOffset);
      et.scheduleTest(et.setTextContents, "katze", startOffset);
      et.scheduleTest(et.setTextContents, "", startOffset);

      // ////////////////////////////////////////////////////////////////////////
      // insertText
      et.scheduleTest(et.insertText, "hello", startOffset, "hello");
      et.scheduleTest(et.insertText, "ma ", startOffset, "ma hello");
      et.scheduleTest(et.insertText, "ma", startOffset + 2, "mama hello");
      et.scheduleTest(et.insertText, " hello", startOffset + 10, "mama hello hello");

      // XXX: bug 452584

      // ////////////////////////////////////////////////////////////////////////
      // deleteText
//      et.deleteText(0, 5, "hello hello");
//      et.deleteText(5, 6, "hellohello");
//      et.deleteText(5, 10, "hello");
//      et.deleteText(0, 5, "");

      // ////////////////////////////////////////////////////////////////////////
      // copyNPasteText
//      et.copyNPasteText(0, 0, 0, "");
//      et.insertText("hello", 0, "hello");
//      et.copyNPasteText(0, 1, 0, "hhello");
//      et.copyNPasteText(5, 6, 6, "hhelloo");
//      et.copyNPasteText(3, 4, 1, "hehelloo");

      // ////////////////////////////////////////////////////////////////////////
//      // cutNPasteText
//      et.cutNPasteText(0, 1, 1, "ehhelloo");
//      et.cutNPasteText(1, 2, 0, "hehelloo");
//      et.cutNPasteText(7, 8, 8, "hehelloo");

      aTestRun.add(et);
    }

    // gA11yEventDumpToConsole = true; // debug stuff

    function runTest() {
      var testRun = new editableTextTestRun();

      addTestEditable("input", testRun);
      addTestEditable("div", testRun);
      addTestEditable("divb", testRun, "pseudo element", "");
      addTestEditable("diva", testRun, "", "pseudo element");
      addTestEditable("divba", testRun, "before", "after");
      addTestEditable(getNode("frame").contentDocument, testRun);

      testRun.run(); // Will call SimpleTest.finish();
    }

    function doTest() {
      // Prepare tested elements.

      // Design mode on/off triggers an editable state change event on
      // the document accessible.
      var frame = getNode("frame");
      waitForEvent(EVENT_STATE_CHANGE, frame.contentDocument, runTest);
      frame.contentDocument.designMode = "on";
    }

    SimpleTest.waitForExplicitFinish();
    addA11yLoadEvent(doTest);
  </script>
  <style>
    #divb::before,
    #diva::after {
      content: "pseudo element";
    }
    #divba::before {
      content: "before";
    }
    #divba::after {
      content: "after";
    }
  </style>
</head>
<body>

  <a target="_blank"
     title="nsIAccessibleEditableText chrome tests"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=452161">
    Bug 452161
  </a>
  <a target="_blank"
     title="Cache rendered text on a11y side"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=626660">
    Bug 626660
  </a>
  <a target="_blank"
     title="Pseudo element support test"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=1105611">
    Bug 1105611
  </a>
  <p id="display"></p>
  <div id="content" style="display: none"></div>
  <pre id="test">
  </pre>

  <input id="input"/>

  <div id="div" contenteditable="true"></div>
  <div id="divb" contenteditable="true"></div>
  <div id="diva" contenteditable="true"></div>
  <div id="divba" contenteditable="true"></div>

  <iframe id="frame"/>
</body>
</html>