layout/reftests/text-overflow/selection.html

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <!--
michael@0 3 Any copyright is dedicated to the Public Domain.
michael@0 4 http://creativecommons.org/licenses/publicdomain/
michael@0 5
michael@0 6 Test: Selected text, background, decorations
michael@0 7 -->
michael@0 8 <html class="reftest-wait"><head>
michael@0 9 <title>text-overflow: Selected text, background, decorations</title>
michael@0 10 <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
michael@0 11 <style type="text/css">
michael@0 12 @font-face {
michael@0 13 font-family: DejaVuSansMono;
michael@0 14 src: url(../fonts/DejaVuSansMono.woff);
michael@0 15 }
michael@0 16 @font-face {
michael@0 17 font-family: TestEllipsisFallback;
michael@0 18 src: url(TestEllipsisFallback.woff);
michael@0 19 }
michael@0 20 html,body {
michael@0 21 color:black; background-color:white; font-size:16px; padding:0; margin:0; font-family:DejaVuSansMono;
michael@0 22 }
michael@0 23
michael@0 24 .test {
michael@0 25 overflow:auto;
michael@0 26 text-overflow:ellipsis ellipsis;
michael@0 27 white-space:nowrap;
michael@0 28 width: 5em;
michael@0 29 position:relative;
michael@0 30 margin-top:1em;
michael@0 31 padding-left: 0.9em;
michael@0 32 padding-right: 1.3em;
michael@0 33 }
michael@0 34
michael@0 35 .hidden {
michael@0 36 overflow:hidden;
michael@0 37 width: 4.4em;
michael@0 38 }
michael@0 39
michael@0 40 .rlo {
michael@0 41 unicode-bidi: bidi-override; direction: rtl;
michael@0 42 }
michael@0 43 .lro {
michael@0 44 unicode-bidi: bidi-override; direction: ltr;
michael@0 45 }
michael@0 46 .rtl {
michael@0 47 direction:rtl;
michael@0 48 }
michael@0 49 x {font-family:DejaVuSansMono;}
michael@0 50 </style>
michael@0 51 <script>
michael@0 52 function getTextNode(elm) {
michael@0 53 if (elm.nodeType != 3)
michael@0 54 return getTextNode(elm.firstChild);
michael@0 55 return elm;
michael@0 56 }
michael@0 57 function addRange(elm) {
michael@0 58 try {
michael@0 59 var sel = window.getSelection();
michael@0 60 var range = document.createRange();
michael@0 61 var startNode = elm.getAttribute('startNode');
michael@0 62 if (startNode == null)
michael@0 63 startNode = getTextNode(elm);
michael@0 64 else
michael@0 65 startNode = getTextNode(elm.childNodes[startNode])
michael@0 66 var start = elm.getAttribute('start');
michael@0 67 if (start == null) start = 2;
michael@0 68 var endNode = elm.getAttribute('endNode');
michael@0 69 if (endNode == null)
michael@0 70 endNode = startNode;
michael@0 71 else
michael@0 72 endNode = getTextNode(elm.childNodes[endNode])
michael@0 73 var end = elm.getAttribute('end');
michael@0 74 if (end == null) end = endNode.textContent.length;
michael@0 75 if (startNode==endNode && start > end) return;
michael@0 76 if (startNode==null) return;
michael@0 77 range.setStart(startNode, start);
michael@0 78 range.setEnd(endNode, end);
michael@0 79 sel.addRange(range);
michael@0 80 } catch (e) {
michael@0 81 alert(e+'\n'+elm.id+'\n'+t)
michael@0 82 }
michael@0 83 }
michael@0 84 function selectText() {
michael@0 85 var divs = document.getElementsByTagName('div');
michael@0 86 for (i = 0; i < divs.length; ++i) {
michael@0 87 addRange(divs[i]);
michael@0 88 }
michael@0 89 document.body.offsetHeight;
michael@0 90 setTimeout(function(){document.documentElement.removeAttribute('class')},2000);
michael@0 91 }
michael@0 92 </script>
michael@0 93 </head><body onload="selectText();">
michael@0 94
michael@0 95
michael@0 96 <!-- LTR overflow:hidden -->
michael@0 97 <div contenteditable="true" spellcheck="true" class="test ltr hidden">Mispe|led word</div>
michael@0 98 <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">
michael@0 99 <div contenteditable="true" spellcheck="true" class="test ltr hidden"><span class="rlo">Mispelled word</span></div>
michael@0 100 <div contenteditable="true" spellcheck="true" class="test ltr hidden"><span class="rlo">Mispelled</span><span class="rlo"> word</span></div>
michael@0 101 <div contenteditable="true" spellcheck="true" class="test ltr hidden"><span class="rlo">Mis</span><span class="rlo">pelled word</div>
michael@0 102 <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>
michael@0 103
michael@0 104 <!-- RTL overflow:hidden -->
michael@0 105 <div contenteditable="true" spellcheck="true" class="test rtl hidden">Mispelled word</div>
michael@0 106 <div contenteditable="true" spellcheck="true" class="test rtl hidden" end="2"><span class="lro">Mispelled word</span></div>
michael@0 107 <div contenteditable="true" spellcheck="true" class="test rtl hidden"><span class="lro">Mispelled</span><span class="rlo"> word</span></div>
michael@0 108 <div contenteditable="true" spellcheck="true" class="test rtl hidden"><span class="rlo">Mis</span><span class="rlo">pelled word</div>
michael@0 109 <div contenteditable="true" spellcheck="true" class="test rtl hidden"><span class="rlo">Mis</span><span class="rlo">pelled word</div>
michael@0 110 <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>
michael@0 111
michael@0 112 </body></html>

mercurial