summaryrefslogtreecommitdiffstats
path: root/layout/base/tests/multi-range-script-select.html
blob: b9bcaeab886be40b48fe8596b76fbdc51b4284b0 (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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<!DOCTYPE HTML>
<html class="reftest-wait"><head>
    <meta charset="utf-8">
    <title>Testcase #1 for bug 1129078</title>
    <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    <script src="selection-utils.js"></script>

<style type="text/css">
@font-face {
  font-family: Ahem;
  src: url("Ahem.ttf");
}
html,body { margin:0; padding: 0; }
body,pre { font-family: Ahem; font-size: 20px; }
</style>
</head>
<body>

<pre id="select">
2af45494-ak7e-11e4-a0c6-a7e7
38222880-bj6d-11e4-8064-fb7b
3d649ae4-ci5c-11e4-995d-17b2
434351bc-dh4b-11e4-9971-4fc8
4dc0e0b4-eg4a-11e4-8c28-5319
a96319c8-ad7d-11e4-b312-039c
</pre>

<pre id="log" style="border:1px solid green"></pre>

<script>
window.info = parent.info;
window.is = parent.is;
window.isnot = parent.isnot;
window.ok = parent.ok;

function setupPrevSelection() {
  var sel = window.getSelection();
  var e = document.querySelector('#select');
  addChildRanges([[0,150,0,160], [0,65,0,70], [0,15,0,15]], e);
  sel.extend(e.firstChild, 10);  // to get eDirPrevious direction
}

function setupNextSelection() {
  var sel = window.getSelection();
  var e = document.querySelector('#select');
  addChildRanges([[0,10,0,15], [0,65,0,70], [0,150,0,160]], e);
}

var ops = {
  S_ : shiftClick,
  SA : shiftAccelClick,
  AD : accelDragSelect,
  SL : keyLeft,
  SR : keyRight
}

function runTest() {
  var e = document.querySelector('#select');
  var hash = window.location.hash
  if (hash.substring(0,5)=="#prev")
    setupPrevSelection();
  else
    setupNextSelection();
  var op = hash.substring(6,8);
  var action = ops[op];
  var test = hash.substring(0,6);
  if (hash.substring(0,5) == "#prev") {
    if (test == "#prev1") {
      if (action == keyLeft) {
        keyLeft({shiftKey:true}, 2)
        checkRanges([[0,8,0,15], [0,65,0,70], [0,150,0,160]], e);
      } else if (action == keyRight) {
        keyRight({shiftKey:true}, 2)
        checkRanges([[0,12,0,15], [0,65,0,70], [0,150,0,160]], e);
      } else if (action == accelDragSelect) {
        accelDragSelect(e, 30, 50);
        checkRanges([[0,1,0,2], [0,10,0,15], [0,65,0,70], [0,150,0,160]], e);
      } else {
        action(e, 30);
        checkRanges([[0,1,0,15], [0,65,0,70], [0,150,0,160]], e);
      }
    } else if (test == "#prev2") {
      action(e, 260);
      checkRanges([[0,13,0,15], [0,65,0,70], [0,150,0,160]], e);
    } else if (test == "#prev3") {
      action(e, 400);
      if (action == shiftClick)
        checkRanges([[0,15,0,20], [0,65,0,70], [0,150,0,160]], e);
      else if (action == shiftAccelClick)
        checkRanges([[0,15,0,20], [0,65,0,70], [0,150,0,160]], e);
    } else if (test == "#prev4") {
      action(e, 180, 65);
      if (action == shiftClick)
        checkRanges([[0,15,0,67], [0,67,0,70], [0,150,0,160]], e);
      else if (action == shiftAccelClick)
        checkRanges([[0,15,0,67], [0,67,0,70], [0,150,0,160]], e); 
     } else if (test == "#prev5") {
      action(e, 440, 65);
      if (action == shiftClick)
        checkRanges([[0,15,0,80], [0,150,0,160]], e);
      else if (action == shiftAccelClick)
        checkRanges([[0,15,0,80], [0,150,0,160]], e);
    } else if (test == "#prev6") {
      action(e, 140, 125);
      if (action == shiftClick)
        checkRanges([[0,15,0,152], [0,152,0,160]], e);
      else if (action == shiftAccelClick)
        checkRanges([[0,15,0,152], [0,152,0,160]], e);
    } else if (test == "#prev7") {
      if (action == accelDragSelect) {
        accelDragSelect(e, 460, 500, 125);
        checkRanges([[0,10,0,15], [0,65,0,70], [0,150,0,160], [0,168,0,170]], e);
      } else if (action == shiftClick) {
        action(e, 500, 125);
        checkRanges([[0,15,0,170]], e);
      } else if (action == shiftAccelClick) {
        action(e, 500, 125);
        checkRanges([[0,15,0,170]], e);
      }
    }
  } else {
    if (test == "#next1") {
      if (action == keyLeft) {
        keyLeft({shiftKey:true}, 2)
        checkRanges([[0,10,0,15], [0,65,0,70], [0,150,0,158]], e);
      } else if (action == keyRight) {
        keyRight({shiftKey:true}, 2)
        checkRanges([[0,10,0,15], [0,65,0,70], [0,150,0,162]], e);
      } else if (action == accelDragSelect) {
        accelDragSelect(e, 30, 50);
        checkRanges([[0,1,0,2], [0,10,0,15], [0,65,0,70], [0,150,0,160]], e);
      } else {
        action(e, 30);
        checkRanges([[0,1,0,150]], e);
      }
    } else if (test == "#next2") {
      action(e, 260);
      checkRanges([[0,10,0,13], [0,13,0,150]], e);
    } else if (test == "#next3") {
      action(e, 400);
      if (action == shiftClick)
        checkRanges([[0,10,0,15], [0,20,0,150]], e);
      else if (action == shiftAccelClick)
        checkRanges([[0,10,0,15], [0,20,0,150]], e);
    } else if (test == "#next4") {
      action(e, 180, 65);
      if (action == shiftClick)
        checkRanges([[0,10,0,15], [0,65,0,67], [0,67,0,150]], e);
      else if (action == shiftAccelClick)
        checkRanges([[0,10,0,15], [0,65,0,67], [0,67,0,150]], e);
     } else if (test == "#next5") {
      action(e, 440, 65);
      if (action == shiftClick)
        checkRanges([[0,10,0,15], [0,65,0,70], [0,80,0,150]], e);
      else if (action == shiftAccelClick)
        checkRanges([[0,10,0,15], [0,65,0,70], [0,80,0,150]], e);
    } else if (test == "#next6") {
      action(e, 140, 125);
      if (action == shiftClick)
        checkRanges([[0,10,0,15], [0,65,0,70], [0,150,0,152]], e);
      else if (action == shiftAccelClick)
        checkRanges([[0,10,0,15], [0,65,0,70], [0,150,0,152]], e);
    } else if (test == "#next7") {
      if (action == accelDragSelect) {
        accelDragSelect(e, 460, 500, 125);
        checkRanges([[0,10,0,15], [0,65,0,70], [0,150,0,160], [0,168,0,170]], e);
      } else if (action == shiftClick) {
        action(e, 500, 125);
        checkRanges([[0,10,0,15], [0,65,0,70], [0,150,0,170]], e);
      } else if (action == shiftAccelClick) {
        action(e, 500, 125);
        checkRanges([[0,10,0,15], [0,65,0,70], [0,150,0,170]], e);
      }
    }
  }
  document.documentElement.removeAttribute("class");
}

SimpleTest.waitForFocus(runTest);

</script>

</body>
</html>