Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=392746 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 392746</title> |
michael@0 | 8 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 10 | <style> |
michael@0 | 11 | </style> |
michael@0 | 12 | </head> |
michael@0 | 13 | <body> |
michael@0 | 14 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=392746">Mozilla Bug 392746</a> |
michael@0 | 15 | <div id="content"> |
michael@0 | 16 | text text text text text <span id="d">ddd text text </span>text text text <br> |
michael@0 | 17 | 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> |
michael@0 | 18 | text text text text text text <span id="a">aaa text</span> text text text <br> |
michael@0 | 19 | </div> |
michael@0 | 20 | <pre id="test"> |
michael@0 | 21 | <script class="testbody" type="text/javascript"> |
michael@0 | 22 | var wu = SpecialPowers.getDOMWindowUtils(window); |
michael@0 | 23 | |
michael@0 | 24 | function ctrlselect(aX,aY, aX2, aY2) { |
michael@0 | 25 | var modifyers = (navigator.platform.indexOf("Mac") >= 0) ? 8 : 2; |
michael@0 | 26 | wu.sendMouseEvent('mousedown', aX, aY, 0, 1, modifyers); |
michael@0 | 27 | wu.sendMouseEvent('mousemove', aX2, aY2, 0, 0, modifyers); |
michael@0 | 28 | wu.sendMouseEvent('mouseup', aX2, aY2, 0, 1, modifyers); |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | function test() { |
michael@0 | 32 | var sel = window.getSelection(); |
michael@0 | 33 | sel.removeAllRanges(); |
michael@0 | 34 | |
michael@0 | 35 | var a=document.getElementById('a').getBoundingClientRect(); |
michael@0 | 36 | ctrlselect(a.left+1, a.top+1, a.right-1, a.top+1); |
michael@0 | 37 | var b=document.getElementById('b').getBoundingClientRect(); |
michael@0 | 38 | ctrlselect(b.left+1, b.top+1, b.right-1, b.top+1); |
michael@0 | 39 | var c=document.getElementById('c').getBoundingClientRect(); |
michael@0 | 40 | ctrlselect(c.left+1, c.top+1, c.right-1, c.top+1); |
michael@0 | 41 | var d=document.getElementById('d').getBoundingClientRect(); |
michael@0 | 42 | ctrlselect(d.left+1, d.top+1, d.right-1, d.top+1); |
michael@0 | 43 | var e=document.getElementById('e').getBoundingClientRect(); |
michael@0 | 44 | ctrlselect(e.right-1, e.top+1, e.left+1, e.top+1); |
michael@0 | 45 | |
michael@0 | 46 | ok(sel.getRangeAt(0).toString() == 'ddd text text ', 'First selection range should be "ddd text text "'); |
michael@0 | 47 | ok(sel.getRangeAt(1).toString() == 'ccc text', 'First selection range should be "ccc text"'); |
michael@0 | 48 | ok(sel.getRangeAt(2).toString() == 'eee text', 'First selection range should be "eee text"'); |
michael@0 | 49 | ok(sel.getRangeAt(3).toString() == 'bbb text', 'First selection range should be "bbb text"'); |
michael@0 | 50 | ok(sel.getRangeAt(4).toString() == 'aaa text', 'First selection range should be "aaa text"'); |
michael@0 | 51 | |
michael@0 | 52 | ok(sel.focusNode == sel.anchorNode, 'focusNode and anchorNode should be the same'); |
michael@0 | 53 | ok(sel.focusNode.parentNode == document.getElementById('e'), 'focusNode.parentNode should be the same as the node with id=e'); |
michael@0 | 54 | ok(sel.focusOffset == 0, 'focusOffset should be 0'); |
michael@0 | 55 | ok(sel.anchorOffset == 8, 'anchorOffset should be 8'); |
michael@0 | 56 | |
michael@0 | 57 | wu.sendMouseEvent('mousedown', 0, 0, 0, 1, 0); |
michael@0 | 58 | wu.sendMouseEvent('mousemove', 0, 0, 0, 0, 0); |
michael@0 | 59 | wu.sendMouseEvent('mouseup', 0, 0, 0, 1, 0); |
michael@0 | 60 | |
michael@0 | 61 | SimpleTest.finish(); |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | window.onload=function() { |
michael@0 | 65 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 66 | setTimeout(test, 0); |
michael@0 | 67 | }; |
michael@0 | 68 | </script> |
michael@0 | 69 | </pre> |
michael@0 | 70 | </body> |
michael@0 | 71 | </html> |