5 body { font-family: serif; }
6 .testCase { border:
1px solid black; padding:
10px; margin:
10px; width:
100%; }
10 var log
= document
.getElementById('log');
11 log
.appendChild(document
.createTextNode(text
));
12 log
.appendChild(document
.createElement('br'));
15 function dragStartTest(e
) {
16 log("Test ID: " + e
.currentTarget
.id
);
17 log("text/plain: " + e
.dataTransfer
.getData("text/plain"));
18 log("text/url: " + e
.dataTransfer
.getData("text/url"));
19 log("text/html: " + e
.dataTransfer
.getData("text/html"));
22 function dragCenterOfRect(clientRect
) {
23 var x
= clientRect
.left
+ clientRect
.width
/ 2;
24 var y
= clientRect
.top
+ clientRect
.height
/ 2;
26 eventSender
.mouseMoveTo(x
, y
);
27 eventSender
.mouseDown();
28 eventSender
.leapForward(200);
29 eventSender
.mouseMoveTo(x
+ 100, y
+ 100);
30 eventSender
.mouseUp();
34 if (!window
.testRunner
)
36 testRunner
.dumpAsText();
38 var selection
= window
.getSelection();
39 selection
.selectAllChildren(document
.getElementById('selectionTest'));
40 dragCenterOfRect(selection
.getRangeAt(0).getBoundingClientRect());
41 dragCenterOfRect(document
.getElementById('imageTest').getBoundingClientRect());
42 dragCenterOfRect(document
.getElementById('linkTest').getBoundingClientRect());
46 <body onload=
"runTest()">
47 <p>Simple test that the dragstart event contains the default data in the event.
48 <div class=
"testCase" id=
"selectionTest" ondragstart=
"dragStartTest(event)">
49 <p>Select some text in this box and drag it.
51 <div class=
"testCase">
52 <p>Drag the image.
<img id=
"imageTest" src=
"data:image/png;base64,
53 iVBORw0KGgoAAAANSUhEUgAAAJYAAAA8CAIAAAAL5NQ9AAAACXBIWXMAAAsTAAALEwEAmpwY
54 AAAAB3RJTUUH2woaBQc4oLEFpAAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeB
55 DhcAAACMSURBVHja7dNBEYAgFEVRPhHMYgAzUIsmVnFvB/fsoQb+ObfBmzMvxneW1D1vzz2w
56 FiEUQiFEKIRCKIQIhVAIhRChEAqhECIUQiEUQoRCKIRCiFAIhVAIEep3xTWTLzzu5oVCKIRC
57 iFAIhVAIEQqhEAohQiEUQiFEKIRCKIQIhVAIhRChEAqhECLUZi3VEwcBMGr1NgAAAABJRU5E
58 rkJggg==" ondragstart=
"dragStartTest(event)">
60 <div class=
"testCase">
61 <p>Drag the link.
<a id=
"linkTest" href=
"http://www.example.com/" ondragstart=
"dragStartTest(event)">Link
</a>