Add DOM Range test with non-contiguous selection rectangles in mixed directional text. Bug 525788
authorSimon Montagu <smontagu@smontagu.org>
Sun, 03 Jan 2010 00:46:48 -0800
changeset 36827 26672e99e0087c0e1057f160f7a302d49f2abbbd
parent 36826 1b0db40fe73ba603e0d10a90cea69e8579269d91
child 36828 185144a15419d1d6faaa87710e4c80d40012552a
push id11000
push usersmontagu@mozilla.com
push dateSun, 03 Jan 2010 08:53:48 +0000
treeherdermozilla-central@26672e99e008 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs525788
milestone1.9.3a1pre
Add DOM Range test with non-contiguous selection rectangles in mixed directional text. Bug 525788
content/base/test/test_range_bounds.html
--- a/content/base/test/test_range_bounds.html
+++ b/content/base/test/test_range_bounds.html
@@ -8,20 +8,21 @@ https://bugzilla.mozilla.org/show_bug.cg
   <meta http-equiv="content-type" content="text/html; charset=UTF-8">
   <script type="text/javascript" src="/MochiKit/packed.js"></script>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=396392">Mozilla Bug Range getClientRects and getBoundingClientRect</a>
-<div id="content" style="font-face:monospace;font-size:12px;width:100px">
+<div id="content" style="font-family:monospace;font-size:12px;width:100px">
 <p>000000<span>0</span></p><div>00000<span>0</span></div><p>0000<span>0000</span>0000</p><div><span>000000000000 00000000000000 000000</span></div><div>000000000000 00000000000003 100305</div>
 </div>
-<div id="mixeddir" style="font-face:monospace;font-size:12px;width:100px"><span>english <bdo dir="rtl">rtl-overide english</bdo> word</span></div>
+<div id="mixeddir" style="font-family:monospace;font-size:12px;width:100px"><span>english <bdo id="bdo" dir="rtl">rtl-overide english</bdo> word</span></div>
+<div id="mixeddir2" style="font-family:monospace;font-size:12px"><span>english <bdo id="bdo2" dir="rtl">rtl-override english</bdo> word</span></div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 var isLTR=true;
 function isEmptyRect(rect, name) {
   name = (isLTR ? 'isLTR ' : 'isRTL ') + name;
   is(rect.left, 0, name+'empty rect should have left = 0');
   is(rect.right, 0, name+'empty rect should have right = 0');
@@ -220,16 +221,38 @@ function doTest(){
   directionDependentTestcases.forEach(runATest);
 }
 function testMixedDir(){
   var root = document.getElementById('mixeddir');
   var firstSpan = root.firstElementChild, firstSpanRect=firstSpan.getBoundingClientRect(),
       firstSpanRectList = firstSpan.getClientRects();
   runATest({name:'mixeddir',range:[firstSpan.firstChild,0,firstSpan.lastChild,firstSpan.lastChild.length],
              rect: firstSpanRect, rectList:firstSpanRectList});
+
+  root = document.getElementById('mixeddir2');
+  firstSpan = root.firstElementChild;
+  firstSpanRect = firstSpan.getBoundingClientRect();
+  bdo = document.getElementById('bdo2');
+  bdoRect=bdo.getBoundingClientRect();
+  var widthPerChar = bdoRect.width / bdo.firstChild.length;
+  runATest({name:'mixeddirPartial', range:[firstSpan.firstChild, 3, 
+					   bdo.firstChild, 7],
+	rect: [firstSpanRect.left + 3*widthPerChar, bdoRect.right,
+	       bdoRect.top, bdoRect.bottom,
+	       (firstSpan.firstChild.length + bdo.firstChild.length - 3) *
+	        widthPerChar,
+	       bdoRect.height],
+	rectList:[[firstSpanRect.left + 3*widthPerChar,
+		   bdoRect.left,
+		   firstSpanRect.top, firstSpanRect.bottom,
+		   (firstSpan.firstChild.length - 3) * widthPerChar,
+		   firstSpanRect.height],
+		  [bdoRect.right - 7 * widthPerChar, bdoRect.right,
+		   bdoRect.top, bdoRect.bottom,
+		   7*widthPerChar, bdoRect.height]]});
 }
 function test(){
   //test ltr
   doTest();
   testMixedDir();
 
   isLTR = false;
   var root = document.getElementById('content');