5 <script src=
"../../../resources/js-test.js"></script>
8 <p id=
"description">This tests hit testing on relative positioned children. To manually test, select text by a mouse drag
9 starting in the blue box but outside red boxes and ending inside a red box.
</p>
10 <div id=
"tests" style=
"margin-bottom: 200px; width: 300px; border: solid 5px #ccf;">
11 <div style=
"position: relative; left: 50px; width: 200px; border: solid 5px #f66;">
16 <div style=
"position: relative; left: 300px; width: 200px; border: solid 5px #f66;">
21 <div style=
"position: relative; left: 250px; width: 200px; border: solid 5px #f66;">
26 <div class=
"testVerticalSelection" style=
"position: relative; top: 4em; width: 200px; border: solid 5px #f66;">
32 <div id=
"console"></div>
35 function runTest(boxName
, testDiv
) {
36 var testVerticalSelection
= testDiv
.className
== 'testVerticalSelection';
38 var expectedString
= [null, "first line", "second line", "third line"];
39 for (var line
= 1; line
<= 3; line
++) {
40 var y
= testDiv
.offsetTop
+ testDiv
.offsetHeight
* (line
- 1) / 3 + 5;
41 if (testVerticalSelection
)
42 eventSender
.mouseMoveTo(testDiv
.offsetLeft
, y
- 20);
44 eventSender
.mouseMoveTo(testDiv
.offsetLeft
- 10, y
);
45 eventSender
.mouseDown();
47 eventSender
.leapForward(200);
49 eventSender
.mouseMoveTo(testDiv
.offsetLeft
+ testDiv
.offsetWidth
- 20, y
);
50 eventSender
.mouseUp();
52 var actual
= window
.getSelection().toString();
53 var action
= "Selecting line " + line
+ ' of ' + boxName
+ ' selected "' + actual
+ '"';
54 if (actual
== expectedString
[line
])
57 testFailed(action
+ ', expected "' + expectedString
[line
] + '"')
59 if (testVerticalSelection
)
64 if (window
.testRunner
) {
65 var tests
= document
.getElementById('tests').getElementsByTagName('div');
66 for (var i
= 0; i
< tests
.length
; i
++)
67 runTest("box " + (i
+ 1), tests
[i
]);
68 document
.getElementById('tests').style
.display
= 'none';