7 document
.getElementById('console')
8 .appendChild(document
.createElement('div'))
9 .appendChild(document
.createTextNode(s
));
12 function onDragStart1(e
)
14 if (e
.target
.parentNode
.id
== 'drag1'
15 && e
.target
.nodeType
== Node
.TEXT_NODE
)
18 log('Test 1: FAIL: target element was ' + e
.target
);
21 function onDragStart2(e
)
23 if (e
.target
.id
== 'drag2')
26 log('Test 2: FAIL: target element was ' + e
.target
);
29 function onDragStart3(e
)
31 if (e
.target
.id
== 'dragImage')
34 log('Test 3: FAIL: target element was ' + e
.target
);
37 function dragAndDrop(n
)
39 var startX
= n
.offsetLeft
+ n
.offsetWidth
/ 2;
40 var startY
= n
.offsetTop
+ n
.offsetHeight
/ 2;
41 eventSender
.mouseMoveTo(startX
, startY
);
42 eventSender
.mouseDown();
43 eventSender
.leapForward(200);
44 eventSender
.mouseMoveTo(startX
+ 400, startY
);
45 eventSender
.mouseUp();
50 var drag1
= document
.getElementById('drag1');
51 var drag2
= document
.getElementById('drag2');
52 var drag3
= document
.getElementById('drag3');
54 drag1
.addEventListener('dragstart', onDragStart1
);
55 drag2
.addEventListener('dragstart', onDragStart2
);
56 drag3
.addEventListener('dragstart', onDragStart3
);
58 if (!window
.testRunner
)
60 testRunner
.dumpAsText();
62 var s
= window
.getSelection();
66 r
= document
.createRange();
77 r
= document
.createRange();
79 dragAndDrop(document
.getElementById('dragImage'));
83 <body onload=
"runTest()">
84 <p>Simple test that dragging and dropping a selection targets the right node.
85 <div id=
"drag1">Test
1: select this line and drag me.
</div>
86 <p>Test
2:
<input id=
"drag2" type=
"text" value=
"Select the text in this input and drag me"></input>
87 <div id=
"drag3">Test
3: select this line and
<img id=
"dragImage" src=
"../resources/abe.png"> drag me from the image.
</div>
88 <div id=
"console"></div>