Backed out changeset f89c9403564e (bug 1913161) for causing multiple failures. CLOSED...
[gecko.git] / layout / reftests / text-overflow / selection.html
blob9727d1288123d77952ab1d905d02a2c71fffb2c8
1 <!DOCTYPE HTML>
2 <!--
3 Any copyright is dedicated to the Public Domain.
4 http://creativecommons.org/licenses/publicdomain/
6 Test: Selected text, background, decorations
7 -->
8 <html class="reftest-wait"><head>
9 <title>text-overflow: Selected text, background, decorations</title>
10 <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
11 <style type="text/css">
12 @font-face {
13 font-family: DejaVuSansMono;
14 src: url(../fonts/DejaVuSansMono.woff);
16 @font-face {
17 font-family: TestEllipsisFallback;
18 src: url(TestEllipsisFallback.woff);
20 html,body {
21 color:black; background-color:white; font-size:16px; padding:0; margin:0; font-family:DejaVuSansMono;
24 .test {
25 overflow:auto;
26 text-overflow:ellipsis ellipsis;
27 white-space:nowrap;
28 width: 5em;
29 position:relative;
30 margin-top:1em;
31 padding-left: 0.9em;
32 padding-right: 1.3em;
35 .hidden {
36 overflow:hidden;
37 width: 4.4em;
40 .rlo {
41 unicode-bidi: bidi-override; direction: rtl;
43 .lro {
44 unicode-bidi: bidi-override; direction: ltr;
46 .rtl {
47 direction:rtl;
49 x {font-family:DejaVuSansMono;}
50 </style>
51 <script>
52 function getTextNode(elm) {
53 if (elm.nodeType != 3)
54 return getTextNode(elm.firstChild);
55 return elm;
57 function addRange(elm) {
58 try {
59 var sel = window.getSelection();
60 var range = document.createRange();
61 var startNode = elm.getAttribute('startNode');
62 if (startNode == null)
63 startNode = getTextNode(elm);
64 else
65 startNode = getTextNode(elm.childNodes[startNode])
66 var start = elm.getAttribute('start');
67 if (start == null) start = 2;
68 var endNode = elm.getAttribute('endNode');
69 if (endNode == null)
70 endNode = startNode;
71 else
72 endNode = getTextNode(elm.childNodes[endNode])
73 var end = elm.getAttribute('end');
74 if (end == null) end = endNode.textContent.length;
75 if (startNode==endNode && start > end) return;
76 if (startNode==null) return;
77 range.setStart(startNode, start);
78 range.setEnd(endNode, end);
79 sel.addRange(range);
80 } catch (e) {
81 alert(e+'\n'+elm.id+'\n'+t)
84 function selectText() {
85 // For putting selection ranges to multiple editing hosts, we need to put
86 // a range outside all editable elements first, then, selection's ancestor
87 // limiter won't be set to an editing host.
88 getSelection().collapse(document.body, document.body.childNodes.length);
89 var divs = document.getElementsByTagName('div');
90 for (i = 0; i < divs.length; ++i) {
91 addRange(divs[i]);
93 document.body.offsetHeight;
94 setTimeout(function(){document.documentElement.removeAttribute('class')},2000);
96 </script>
97 </head><body onload="selectText();">
100 <!-- LTR overflow:hidden -->
101 <div contenteditable="true" spellcheck="true" class="test ltr hidden">Mispe|led word</div>
102 <span style="display:block;width:15em"><div contenteditable="true" spellcheck="true" class="test ltr hidden" style="width:auto; float:right; font-family:TestEllipsisFallback; text-indent:-1em; " start=0 end=9><x>M ispeled word</x></div></span><br clear="all">
103 <div contenteditable="true" spellcheck="true" class="test ltr hidden"><span class="rlo">Mispelled word</span></div>
104 <div contenteditable="true" spellcheck="true" class="test ltr hidden"><span class="rlo">Mispelled</span><span class="rlo"> word</span></div>
105 <div contenteditable="true" spellcheck="true" class="test ltr hidden"><span class="rlo">Mis</span><span class="rlo">pelled word</div>
106 <div contenteditable="true" spellcheck="true" class="test ltr hidden" endNode="1" style="text-indent:-0.2em"><span>Mis</span><span>pe|led</span><span> word</span></div>
108 <!-- RTL overflow:hidden -->
109 <div contenteditable="true" spellcheck="true" class="test rtl hidden">Mispelled word</div>
110 <div contenteditable="true" spellcheck="true" class="test rtl hidden" end="2"><span class="lro">Mispelled word</span></div>
111 <div contenteditable="true" spellcheck="true" class="test rtl hidden"><span class="lro">Mispelled</span><span class="rlo"> word</span></div>
112 <div contenteditable="true" spellcheck="true" class="test rtl hidden"><span class="rlo">Mis</span><span class="rlo">pelled word</div>
113 <div contenteditable="true" spellcheck="true" class="test rtl hidden"><span class="rlo">Mis</span><span class="rlo">pelled word</div>
114 <div contenteditable="true" spellcheck="true" class="test rtl hidden"><span class="rlo" style="margin-right:-0.2em">Mis</span><span class="rlo">pelled</span><span class="rlo"> word</span></div>
116 </body></html>