|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=560780 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 560780</title> |
|
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
|
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
11 |
|
12 <script type="text/javascript"> |
|
13 function init() { |
|
14 var elem = document.getElementById('body'); |
|
15 elem.addEventListener('mousedown', mousedown, true); |
|
16 } |
|
17 var seen_mousedown = 0; |
|
18 function mousedown(event) { |
|
19 var doc = event.target.ownerDocument; |
|
20 var win = doc.defaultView; |
|
21 var elem = doc.getElementById('body'); |
|
22 var selection = win.getSelection(); |
|
23 if (selection.rangeCount>0) { |
|
24 var ragne = selection.getRangeAt(0); |
|
25 var rect = ragne.getBoundingClientRect(); |
|
26 var p = elem.parentNode.appendChild(doc.createElement('p')); |
|
27 p.textContent = "width: " + (rect.right -rect.left); |
|
28 } |
|
29 ++seen_mousedown; |
|
30 } |
|
31 </script> |
|
32 |
|
33 </head> |
|
34 <body id="body"> |
|
35 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=560780">Mozilla Bug 560780</a> |
|
36 <p id="display" style="margin:0;padding:0;border:0"><a id="testlink" href="#aaaaaaaaaaaaaaaaaaaaaa">abcdefghijklmnabcdefghijklmn</a></p> |
|
37 <div id="content" style="display: none"> |
|
38 |
|
39 </div> |
|
40 <pre id="test"> |
|
41 1.Start Minefield with New Profile. |
|
42 2.Select texts by alt + mouse dragging horizontaly from 'd' in the link above to far right of window. |
|
43 3.Click on the selected text |
|
44 4.Click empty area of page |
|
45 5.Repeat STEP 2 to 4 till browser crashes. (at least 5 times) |
|
46 |
|
47 <script type="application/javascript"> |
|
48 |
|
49 /** Test for Bug 560780 **/ |
|
50 |
|
51 function selectByMouseThenClick(elm,startx,starty) { |
|
52 // select some text |
|
53 var ctrl = navigator.platform.indexOf("Linux") ? true : false; |
|
54 var alt = true; |
|
55 var x = startx; |
|
56 synthesizeMouse(elm, x, starty, { type:"mousedown", ctrlKey:ctrl, altKey:alt }); |
|
57 synthesizeMouse(elm, x += 100, starty, { type:"mousemove", ctrlKey:ctrl, altKey:alt }); |
|
58 synthesizeMouse(elm, x += 100, starty, { type:"mousemove", ctrlKey:ctrl, altKey:alt }); |
|
59 synthesizeMouse(elm, x += 100, starty, { type:"mousemove", ctrlKey:ctrl, altKey:alt }); |
|
60 synthesizeMouse(elm, x += 100, starty, { type:"mousemove", ctrlKey:ctrl, altKey:alt }); |
|
61 synthesizeMouse(elm, x += 100, starty, { type:"mousemove", ctrlKey:ctrl, altKey:alt }); |
|
62 synthesizeMouse(elm, x += 100, starty, { type:"mousemove", ctrlKey:ctrl, altKey:alt }); |
|
63 synthesizeMouse(elm, x += 100, starty, { type:"mousemove", ctrlKey:ctrl, altKey:alt }); |
|
64 synthesizeMouse(elm, x += 100, starty, { type:"mousemove", ctrlKey:ctrl, altKey:alt }); |
|
65 synthesizeMouse(elm, x, starty, { type:"mouseup", ctrlKey:ctrl, altKey:alt }); |
|
66 |
|
67 // click on the selection |
|
68 synthesizeMouse(elm, startx + 10, starty + 1, {}); |
|
69 |
|
70 // click empty area of the page |
|
71 synthesizeMouse(document.getElementById('body'), 800, 800, {}); |
|
72 } |
|
73 |
|
74 function runTest() { |
|
75 var e = document.getElementById('testlink'); |
|
76 selectByMouseThenClick(e,110,5); |
|
77 selectByMouseThenClick(e,90,5); |
|
78 selectByMouseThenClick(e,70,5); |
|
79 selectByMouseThenClick(e,50,5); |
|
80 selectByMouseThenClick(e,30,5); |
|
81 selectByMouseThenClick(e,10,5); |
|
82 is(seen_mousedown, 12, "got the mousedown events"); |
|
83 SimpleTest.finish(); |
|
84 } |
|
85 |
|
86 function doTest() { |
|
87 init(); |
|
88 runTest(); |
|
89 } |
|
90 |
|
91 SimpleTest.waitForFocus(doTest, window); |
|
92 SimpleTest.waitForExplicitFinish(); |
|
93 |
|
94 |
|
95 |
|
96 </script> |
|
97 </pre> |
|
98 </body> |
|
99 </html> |