summaryrefslogtreecommitdiffstats
path: root/accessible/tests/mochitest/events/test_textselchange.html
blob: 92ac30423d7cd75150f785b39894ff9e5419e610 (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
<html>

<head>
  <title>Accessible text selection change events testing</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 type="application/javascript"
          src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>

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

  <script type="application/javascript">
    var gQueue = null;

    // gA11yEventDumpID = "eventdump"; // debug stuff
    //gA11yEventDumpToConsole = true;

    function getOnclickSeq(aID)
    {
      return [
        new caretMoveChecker(0, aID), 
        new unexpectedInvokerChecker(EVENT_TEXT_SELECTION_CHANGED, aID)
      ];
    }

    function doTests()
    {
      // test caret move events and caret offsets
      gQueue = new eventQueue();

      gQueue.push(new synthClick("c1_p1", getOnclickSeq("c1_p1")));
      gQueue.push(new synthDownKey("c1", new textSelectionChecker("c1", 0, 1), { shiftKey: true }));
      gQueue.push(new synthDownKey("c1", new textSelectionChecker("c1", 0, 2), { shiftKey: true }));

      gQueue.push(new synthClick("ta1", getOnclickSeq("ta1")));
      gQueue.push(new synthRightKey("ta1",
                                    new textSelectionChecker("ta1", 0, 1),
                                    { shiftKey: true }));
      gQueue.push(new synthLeftKey("ta1",
                                    [new textSelectionChecker("ta1", 0, 0),
                                     new caretMoveChecker(0, "ta1")]));

      gQueue.invoke(); // Will call SimpleTest.finish();
    }

    SimpleTest.waitForExplicitFinish();
    addA11yLoadEvent(doTests);
  </script>
</head>

<body>

  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=762934"
     title="Text selection change event has a wrong target when selection is spanned through several objects">
    Bug 762934
  </a>
  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=956032"
     title="Text selection change event missed when selected text becomes unselected">
    Bug 956032
  </a>
  <p id="display"></p>
  <div id="content" style="display: none"></div>
  <pre id="test">
  </pre>

  <div id="c1" contentEditable="true">
    <p id="c1_p1">paragraph</p>
    <p id="c1_p2">paragraph</p>
  </div>

  <textarea id="ta1">Hello world</textarea>

  <div id="eventdump"></div>
</body>
</html>