summaryrefslogtreecommitdiffstats
path: root/layout/base/tests/multi-range-user-select-ref.html
blob: 00d7d412691a3070bdbf3f7c2e7995de400b82de (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
<!DOCTYPE HTML>
<html class="reftest-wait"><head>
    <meta charset="utf-8">
    <title>Testcase #1 for bug 1129078</title>
    <script src="/tests/SimpleTest/SimpleTest.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>

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

function setupSelectionNext3() {
  addChildRanges([[0,10,0,15], [0,65,0,70], [0,150,0,160]], e);
}
function setupSelectionNext2() {
  addChildRanges([[0,10,0,15], [0,65,0,70]], e);
}
function setupSelectionNext2b() {
  addChildRanges([[0,15,0,80], [0,150,0,160]], e);
}
function setupSelectionNext1() {
  addChildRanges([[0,10,0,15]], e);
}
function setupSelectionNext1b() {
  addChildRanges([[0,15,0,170]], e);
}
function setupSelectionNext1c() {
  addChildRanges([[0,150,0,160]], e);
}

function runTest() {
  sel = window.getSelection();
  sel.removeAllRanges();
  document.body.offsetHeight;
  var hash = window.location.hash
  var op = hash.substring(6,8);
  var test = hash.substring(0,6);
  if (hash.substring(0,5) == "#prev") {
    if (test == "#prev1") {
      setupSelectionPrev3();
      if (op == "SL") {
        sel.extend(e.firstChild, 8);
      } else if (op == "SR") {
        sel.extend(e.firstChild, 12);
      } else if (op == "AD") {
        addChildRanges([[0,1,0,2]], e);
      } else {
        sel.extend(e.firstChild, 1);
      }
    } else if (test == "#prev2") {
      setupSelectionPrev3();
      sel.extend(e.firstChild, 14); // now eDirNext
      sel.extend(e.firstChild, 13); // now eDirPrevious again
    } else if (test == "#prev3") {
      setupSelectionPrev2();
      sel.extend(e.firstChild, 20);
    } else if (test == "#prev4") {
      setupSelectionPrev2();
      sel.extend(e.firstChild, 68); // now eDirNext
      sel.extend(e.firstChild, 67); // now eDirPrevious again
    } else if (test == "#prev5") {
      setupSelectionPrev1();
      sel.extend(e.firstChild, 80);
    } else if (test == "#prev6") {
      setupSelectionPrev1();
      sel.extend(e.firstChild, 153); // now eDirNext
      sel.extend(e.firstChild, 152); // now eDirPrevious again
    } else if (test == "#prev7") {
      if (op == "AD") {
        setupSelectionPrev3();
        addChildRanges([[0,168,0,170]], e);
      } else {
        addChildRanges([[0,160,0,170]], e);
      }
    } else if (test == "#prev8") {
      if (op == "AD") {
        addChildRanges([[0,150,0,155], [0,68,0,70]], e);
      }
    }
  } else {
    if (test == "#next1") {
      if (op == "SL") {
        setupSelectionNext3();
        sel.extend(e.firstChild, 158);
      } else if (op == "SR") {
        setupSelectionNext3();
        sel.extend(e.firstChild, 162);
      } else if (op == "AD") {
        setupSelectionNext3();
        addChildRanges([[0,1,0,2]], e);
      } else {
        setupSelectionNext1();
        sel.extend(e.firstChild, 1);
      }
    } else if (test == "#next2") {
      setupSelectionNext1();
      sel.extend(e.firstChild, 13);
    } else if (test == "#next3") {
      setupSelectionNext1();
      sel.extend(e.firstChild, 20);
    } else if (test == "#next4") {
      setupSelectionNext2();
      sel.extend(e.firstChild, 67);
    } else if (test == "#next5") {
      setupSelectionNext2();
      sel.extend(e.firstChild, 80);
    } else if (test == "#next6") {
      setupSelectionNext3();
      sel.extend(e.firstChild, 152);
    } else if (test == "#next7") {
      setupSelectionNext3();
      if (op == "AD") {
        addChildRanges([[0,168,0,170]], e);
      } else {
        sel.extend(e.firstChild, 170);
      }
    } else if (test == "#next8") {
      if (op == "AD") {
        addChildRanges([[0,68,0,70], [0,150,0,155]], e);
      }
    }
  }
  document.documentElement.removeAttribute("class");
}

SimpleTest.waitForFocus(function(){setTimeout(runTest,0)});

</script>

</body>
</html>