layout/reftests/text-overflow/selection.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/reftests/text-overflow/selection.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,112 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<!--
     1.6 +    Any copyright is dedicated to the Public Domain.
     1.7 +    http://creativecommons.org/licenses/publicdomain/
     1.8 +
     1.9 +    Test: Selected text, background, decorations
    1.10 +-->
    1.11 +<html class="reftest-wait"><head>
    1.12 +<title>text-overflow: Selected text, background, decorations</title>
    1.13 +<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    1.14 +<style type="text/css">
    1.15 +@font-face {
    1.16 +  font-family: DejaVuSansMono;
    1.17 +  src: url(../fonts/DejaVuSansMono.woff);
    1.18 +}
    1.19 +@font-face {
    1.20 +  font-family: TestEllipsisFallback;
    1.21 +  src: url(TestEllipsisFallback.woff);
    1.22 +}
    1.23 +html,body {
    1.24 +    color:black; background-color:white; font-size:16px; padding:0; margin:0; font-family:DejaVuSansMono;
    1.25 +}
    1.26 +
    1.27 +.test {
    1.28 +  overflow:auto;
    1.29 +  text-overflow:ellipsis ellipsis;
    1.30 +  white-space:nowrap;
    1.31 +  width: 5em;
    1.32 +  position:relative;
    1.33 +  margin-top:1em;
    1.34 +  padding-left: 0.9em;
    1.35 +  padding-right: 1.3em;
    1.36 +}
    1.37 +
    1.38 +.hidden {
    1.39 +  overflow:hidden;
    1.40 +  width: 4.4em;
    1.41 +}
    1.42 +
    1.43 +.rlo {
    1.44 +  unicode-bidi: bidi-override; direction: rtl;
    1.45 +}
    1.46 +.lro {
    1.47 +  unicode-bidi: bidi-override; direction: ltr;
    1.48 +}
    1.49 +.rtl {
    1.50 +  direction:rtl;
    1.51 +}
    1.52 +x {font-family:DejaVuSansMono;}
    1.53 +</style>
    1.54 +<script>
    1.55 +function getTextNode(elm) {
    1.56 +  if (elm.nodeType != 3)
    1.57 +    return getTextNode(elm.firstChild);
    1.58 +  return elm;
    1.59 +}
    1.60 +function addRange(elm) {
    1.61 +try {
    1.62 +  var sel = window.getSelection();
    1.63 +  var range = document.createRange();
    1.64 +  var startNode = elm.getAttribute('startNode');
    1.65 +  if (startNode == null)
    1.66 +    startNode = getTextNode(elm);
    1.67 +  else
    1.68 +    startNode = getTextNode(elm.childNodes[startNode])
    1.69 +  var start = elm.getAttribute('start');
    1.70 +  if (start == null) start = 2;
    1.71 +  var endNode = elm.getAttribute('endNode');
    1.72 +  if (endNode == null)
    1.73 +    endNode = startNode;
    1.74 +  else
    1.75 +    endNode = getTextNode(elm.childNodes[endNode])
    1.76 +  var end = elm.getAttribute('end');
    1.77 +  if (end == null) end = endNode.textContent.length;
    1.78 +  if (startNode==endNode && start > end) return;
    1.79 +  if (startNode==null) return;
    1.80 +  range.setStart(startNode, start);
    1.81 +  range.setEnd(endNode, end);
    1.82 +  sel.addRange(range);
    1.83 +} catch (e) {
    1.84 +alert(e+'\n'+elm.id+'\n'+t)
    1.85 +}
    1.86 +}
    1.87 +function selectText() {
    1.88 + var divs = document.getElementsByTagName('div');
    1.89 +  for (i = 0; i < divs.length; ++i) {
    1.90 +    addRange(divs[i]);
    1.91 +  }
    1.92 +  document.body.offsetHeight;
    1.93 +  setTimeout(function(){document.documentElement.removeAttribute('class')},2000);
    1.94 +}
    1.95 +</script>
    1.96 +</head><body onload="selectText();">
    1.97 +
    1.98 +
    1.99 +<!-- LTR overflow:hidden -->
   1.100 +<div contenteditable="true" spellcheck="true" class="test ltr hidden">Mispe|led word</div>
   1.101 +<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">
   1.102 +<div contenteditable="true" spellcheck="true" class="test ltr hidden"><span class="rlo">Mispelled word</span></div>
   1.103 +<div contenteditable="true" spellcheck="true" class="test ltr hidden"><span class="rlo">Mispelled</span><span class="rlo"> word</span></div>
   1.104 +<div contenteditable="true" spellcheck="true" class="test ltr hidden"><span class="rlo">Mis</span><span class="rlo">pelled word</div>
   1.105 +<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>
   1.106 +
   1.107 +<!-- RTL overflow:hidden -->
   1.108 +<div contenteditable="true" spellcheck="true" class="test rtl hidden">Mispelled word</div>
   1.109 +<div contenteditable="true" spellcheck="true" class="test rtl hidden" end="2"><span class="lro">Mispelled word</span></div>
   1.110 +<div contenteditable="true" spellcheck="true" class="test rtl hidden"><span class="lro">Mispelled</span><span class="rlo"> word</span></div>
   1.111 +<div contenteditable="true" spellcheck="true" class="test rtl hidden"><span class="rlo">Mis</span><span class="rlo">pelled word</div>
   1.112 +<div contenteditable="true" spellcheck="true" class="test rtl hidden"><span class="rlo">Mis</span><span class="rlo">pelled          word</div>
   1.113 +<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>
   1.114 +
   1.115 +</body></html>

mercurial