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 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
|
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1216483
-->
<meta charset="utf-8">
<title>Test for Bug 1216483</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1216483">Mozilla Bug 1216483</a>
<style>
.container {
border: 1px solid black;
margin-bottom: 1em;
}
.with-before {
counter-reset: cnt;
}
.with-before .container {
counter-increment: cnt;
}
td {
width: 100px;
}
.with-before td {
counter-increment: cnt;
}
.with-before .container::before {
content: counter(cnt) ")";
margin: 0 8px;
color: grey;
}
.with-before td::before {
content: counter(cnt) ")";
margin: 0 8px;
color: grey;
}
.block .container { display: block; }
.flex .container { display: flex; }
.grid .container { display: grid; }
</style>
<h1>Only editable content</h1>
<h2>display: block</h2>
<div class="editor block" contenteditable inputmode="none">
<div class="container">
<div class="first">PLACE CURSOR HERE, THEN PRESS DOWNARROW.</div>
</div>
<div class="container">
<div class="second">a<br>b<br>c</div>
</div>
</div>
<h2>display: flex</h2>
<div class="editor flex" contenteditable inputmode="none">
<div class="container">
<div class="first">PLACE CURSOR HERE, THEN PRESS DOWNARROW.</div>
</div>
<div class="container">
<div class="second">a<br>b<br>c</div>
</div>
</div>
<h2>display: grid</h2>
<div class="editor grid" contenteditable inputmode="none">
<div class="container">
<div class="first">PLACE CURSOR HERE, THEN PRESS DOWNARROW.</div>
</div>
<div class="container">
<div class="second">a<br>b<br>c</div>
</div>
</div>
<h2>Table</h2>
<div class="editor table" contenteditable inputmode="none">
<div class="first">PLACE CURSOR HERE, THEN PRESS DOWNARROW.</div>
<table border="1">
<tr><td class="second">a<br>b<br>c</td><td>d</td></tr>
<tr><td>k<br>l<br>m</td><td>n</td></tr>
</table>
</div>
<h2>Table with element inside</h2>
<div class="editor table" contenteditable inputmode="none">
<div class="first">PLACE CURSOR HERE, THEN PRESS DOWNARROW.</div>
<table border="1">
<tr><td><span class="second">a<br>b<br>c</span></td><td><span>d</span></td></tr>
<tr><td><span>k<br>l<br>m</span></td><td><span>n</span></td></tr>
</table>
</div>
<h2>Table in a flex container</h2>
<div class="editor flex table" contenteditable inputmode="none">
<div class="container">
<div class="first">PLACE CURSOR HERE, THEN PRESS DOWNARROW.</div>
</div>
<div class="container">
<table border="1">
<tr><td><span class="second">a<br>b<br>c</span></td><td><span>d</span></td></tr>
<tr><td><span>k<br>l<br>m</span></td><td><span>n</span></td></tr>
</table>
</div>
</div>
<h1>Some non-editable content involved and skipped</h1>
<h2>display: block</h2>
<div class="editor block with-before" contenteditable inputmode="none">
<div class="container">
<div class="first">PLACE CURSOR HERE, THEN PRESS DOWNARROW.</div>
</div>
<div class="container">
<div class="second">a<br>b<br>c</div>
</div>
</div>
<h2>display: flex</h2>
<div class="editor flex with-before" contenteditable inputmode="none">
<div class="container">
<div class="first">PLACE CURSOR HERE, THEN PRESS DOWNARROW.</div>
</div>
<div class="container">
<div class="second">a<br>b<br>c</div>
</div>
</div>
<h2>Flex with contenteditable="false"</h2>
<div class="editor flex" contenteditable inputmode="none">
<div class="container">
<div class="first">PLACE CURSOR HERE, THEN PRESS DOWNARROW.</div>
</div>
<div class="container">
<div contenteditable="false">X</div>
<div class="second">a<br>b<br>c</div>
</div>
</div>
<h2>display: grid</h2>
<div class="editor grid with-before" contenteditable inputmode="none">
<div class="container">
<div class="first">PLACE CURSOR HERE, THEN PRESS DOWNARROW.</div>
</div>
<div class="container">
<div class="second">a<br>b<br>c</div>
</div>
</div>
<h2>Table</h2>
<div class="editor table" contenteditable inputmode="none">
<div class="first">PLACE CURSOR HERE, THEN PRESS DOWNARROW.</div>
<table border="1">
<tr><td class="second">a<br>b<br>c</td><td>d</td></tr>
<tr><td>k<br>l<br>m</td><td>n</td></tr>
</table>
</div>
<h2>Table with element inside</h2>
<div class="editor table with-before" contenteditable inputmode="none">
<div class="first">PLACE CURSOR HERE, THEN PRESS DOWNARROW.</div>
<table border="1">
<tr><td><span class="second">a<br>b<br>c</span></td><td><span>d</span></td></tr>
<tr><td><span>k<br>l<br>m</span></td><td><span>n</span></td></tr>
</table>
</div>
<h2>Table in a flex container</h2>
<div class="editor flex table with-before" contenteditable inputmode="none">
<div class="container">
<div class="first">PLACE CURSOR HERE, THEN PRESS DOWNARROW.</div>
</div>
<div class="container">
<table border="1">
<tr><td><span class="second">a<br>b<br>c</span></td><td><span>d</span></td></tr>
<tr><td><span>k<br>l<br>m</span></td><td><span>n</span></td></tr>
</table>
</div>
</div>
<script>
const editors = document.querySelectorAll('.editor')
editors.forEach(function (editor) {
add_task(function() {
editor.focus();
const first = editor.querySelector('.first');
const second = editor.querySelector('.second')
document.getSelection().collapse(first.childNodes[0], 5);
sendKey('DOWN');
const sel = document.getSelection();
is(sel.anchorNode.textContent, "a", editor.className + ': Caret not at the correct text node in second block')
is(sel.anchorOffset, 1, editor.className + ': Caret not at the expected offset')
});
});
</script>
|