|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=417418 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 417418</title> |
|
8 <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> |
|
9 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
10 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
|
11 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
12 </head> |
|
13 <body> |
|
14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=417418">Mozilla Bug 417418</a> |
|
15 <div id="display" contenteditable="true"> |
|
16 <p id="coin">first paragraph</p> |
|
17 <p>second paragraph. <img id="img" src="green.png"></p> |
|
18 </div> |
|
19 <div id="content" style="display: none"> |
|
20 |
|
21 </div> |
|
22 <pre id="test"> |
|
23 <script class="testbody" type="text/javascript"> |
|
24 |
|
25 /** Test for Bug 417418 **/ |
|
26 SimpleTest.waitForExplicitFinish(); |
|
27 SimpleTest.waitForFocus(runTest); |
|
28 |
|
29 function resetSelection() { |
|
30 window.getSelection().collapse(document.getElementById("coin"), 0); |
|
31 } |
|
32 |
|
33 function runTest() { |
|
34 var rightClick = {type: 'mousedown', button: 2}, |
|
35 singleClick = {type: 'mousedown', button: 0}; |
|
36 var selection = window.getSelection(); |
|
37 |
|
38 var div = document.getElementById('display'); |
|
39 var img = document.getElementById('img'); |
|
40 var divRect = div.getBoundingClientRect(); |
|
41 var imgselected; |
|
42 |
|
43 resetSelection(); |
|
44 synthesizeMouse(div, divRect.width - 1, divRect.height - 1, rightClick); |
|
45 ok(selection.isCollapsed, "selection is not collapsed"); |
|
46 |
|
47 resetSelection(); |
|
48 synthesizeMouse(div, divRect.width - 1, divRect.height - 1, singleClick); |
|
49 ok(selection.isCollapsed, "selection is not collapsed"); |
|
50 |
|
51 resetSelection(); |
|
52 synthesizeMouseAtCenter(img, rightClick); |
|
53 imgselected = selection.anchorNode == img.parentNode && |
|
54 selection.anchorOffset === 1 && |
|
55 selection.rangeCount === 1; |
|
56 ok(imgselected, "image is not selected"); |
|
57 |
|
58 resetSelection(); |
|
59 synthesizeMouseAtCenter(img, singleClick); |
|
60 imgselected = selection.anchorNode == img.parentNode && |
|
61 selection.anchorOffset === 1 && |
|
62 selection.rangeCount === 1; |
|
63 ok(imgselected, "image is not selected"); |
|
64 |
|
65 SimpleTest.finish(); |
|
66 } |
|
67 |
|
68 |
|
69 </script> |
|
70 </pre> |
|
71 </body> |
|
72 </html> |