1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/generic/test/test_bug392746.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,71 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=392746 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 392746</title> 1.11 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.13 + <style> 1.14 + </style> 1.15 +</head> 1.16 +<body> 1.17 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=392746">Mozilla Bug 392746</a> 1.18 +<div id="content"> 1.19 +text text text text text <span id="d">ddd text text </span>text text text <br> 1.20 +text <span id="c">ccc text</span> text text <span id="e">eee text</span> text text text <span id="b">bbb text</span><br> 1.21 + text text text text text text <span id="a">aaa text</span> text text text <br> 1.22 +</div> 1.23 +<pre id="test"> 1.24 +<script class="testbody" type="text/javascript"> 1.25 + var wu = SpecialPowers.getDOMWindowUtils(window); 1.26 + 1.27 +function ctrlselect(aX,aY, aX2, aY2) { 1.28 + var modifyers = (navigator.platform.indexOf("Mac") >= 0) ? 8 : 2; 1.29 + wu.sendMouseEvent('mousedown', aX, aY, 0, 1, modifyers); 1.30 + wu.sendMouseEvent('mousemove', aX2, aY2, 0, 0, modifyers); 1.31 + wu.sendMouseEvent('mouseup', aX2, aY2, 0, 1, modifyers); 1.32 +} 1.33 + 1.34 + function test() { 1.35 + var sel = window.getSelection(); 1.36 + sel.removeAllRanges(); 1.37 + 1.38 + var a=document.getElementById('a').getBoundingClientRect(); 1.39 + ctrlselect(a.left+1, a.top+1, a.right-1, a.top+1); 1.40 + var b=document.getElementById('b').getBoundingClientRect(); 1.41 + ctrlselect(b.left+1, b.top+1, b.right-1, b.top+1); 1.42 + var c=document.getElementById('c').getBoundingClientRect(); 1.43 + ctrlselect(c.left+1, c.top+1, c.right-1, c.top+1); 1.44 + var d=document.getElementById('d').getBoundingClientRect(); 1.45 + ctrlselect(d.left+1, d.top+1, d.right-1, d.top+1); 1.46 + var e=document.getElementById('e').getBoundingClientRect(); 1.47 + ctrlselect(e.right-1, e.top+1, e.left+1, e.top+1); 1.48 + 1.49 + ok(sel.getRangeAt(0).toString() == 'ddd text text ', 'First selection range should be "ddd text text "'); 1.50 + ok(sel.getRangeAt(1).toString() == 'ccc text', 'First selection range should be "ccc text"'); 1.51 + ok(sel.getRangeAt(2).toString() == 'eee text', 'First selection range should be "eee text"'); 1.52 + ok(sel.getRangeAt(3).toString() == 'bbb text', 'First selection range should be "bbb text"'); 1.53 + ok(sel.getRangeAt(4).toString() == 'aaa text', 'First selection range should be "aaa text"'); 1.54 + 1.55 + ok(sel.focusNode == sel.anchorNode, 'focusNode and anchorNode should be the same'); 1.56 + ok(sel.focusNode.parentNode == document.getElementById('e'), 'focusNode.parentNode should be the same as the node with id=e'); 1.57 + ok(sel.focusOffset == 0, 'focusOffset should be 0'); 1.58 + ok(sel.anchorOffset == 8, 'anchorOffset should be 8'); 1.59 + 1.60 + wu.sendMouseEvent('mousedown', 0, 0, 0, 1, 0); 1.61 + wu.sendMouseEvent('mousemove', 0, 0, 0, 0, 0); 1.62 + wu.sendMouseEvent('mouseup', 0, 0, 0, 1, 0); 1.63 + 1.64 + SimpleTest.finish(); 1.65 +} 1.66 + 1.67 + window.onload=function() { 1.68 + SimpleTest.waitForExplicitFinish(); 1.69 + setTimeout(test, 0); 1.70 + }; 1.71 +</script> 1.72 +</pre> 1.73 +</body> 1.74 +</html>