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

mercurial