3 testRunner
.dumpEditingCallbacks();
5 <div>This test checks that links dragged into editable regions preserve their title and URL.
</div>
7 <div contenteditable=
"true" id=
"destination">Hello
</div>
8 <div contenteditable=
"true" id=
"destination2">Goodbye
</div>
10 <div><a href=
"http://apple.com" id=
"grabme">This is a link
</a></div>
11 <div><a href=
"http://apple.com" id=
"grabme2">This
</a
><a
href=
"http://webkit.org/">is another link
</a></div>
13 <ul id=
"console"></ul>
15 <div>To run this test manually, drag the first link into the box with 'Hello' in it,
16 drag the second link into the box with 'Goodbye' in it, and then click on the button.
<br><input type=
"button" value=
"Verify" onClick=
"verifier()"></div>
20 function log(message
) {
21 var console
= document
.getElementById("console");
22 var li
= document
.createElement("li");
23 var pre
= document
.createElement("pre");
24 pre
.appendChild(document
.createTextNode(message
));
26 console
.appendChild(li
);
30 if (!window
.testRunner
)
32 testRunner
.dumpAsText();
34 dragLink('grabme', 'destination');
35 dragLink('grabme2', 'destination2');
40 function dragLink(srcId
, targetId
)
42 var anchorToDrag
= document
.getElementById(srcId
);
43 window
.getSelection().setBaseAndExtent(anchorToDrag
, 0, anchorToDrag
, 0);
45 var x
= anchorToDrag
.offsetLeft
+ anchorToDrag
.offsetWidth
/ 2;
46 var y
= anchorToDrag
.offsetTop
+ anchorToDrag
.offsetHeight
/ 2;
48 eventSender
.mouseMoveTo(x
, y
);
50 eventSender
.mouseDown();
51 // Wait a moment so that the mouseDown will kick off a drag instead of navigating to the link
52 eventSender
.leapForward(400);
54 var destinationObject
= document
.getElementById(targetId
);
55 var x
= destinationObject
.offsetLeft
+ destinationObject
.offsetWidth
/ 2;
56 var y
= destinationObject
.offsetTop
+ destinationObject
.offsetHeight
/ 2;
58 eventSender
.mouseMoveTo(x
, y
);
59 eventSender
.mouseUp();
63 var anchorToDrag
= document
.getElementById("grabme");
64 var anchorToDrag2
= document
.getElementById("grabme2");
66 var passed
= verifyLink('grabme', 0) && verifyLink('grabme2', 1);
68 var anchors
= document
.getElementsByTagName("a");
69 if (anchors
.length
!= 2) {
70 log("Failure, incorrect number of anchor tags present");
78 function verifyLink(linkId
, linkNumber
)
80 var anchorToDrag
= document
.getElementById(linkId
);
82 var originalTarget
= anchorToDrag
.href
;
83 var originalText
= anchorToDrag
.innerText
;
84 var anchorParent
= anchorToDrag
.parentNode
;
85 anchorParent
.removeChild(anchorToDrag
);
87 var anchors
= document
.getElementsByTagName("a");
88 if (!anchors
[linkNumber
]) {
89 log("Link " + linkNumber
+ " not found");
92 log("Link is " + anchors
[linkNumber
].href
);
94 if (anchors
[linkNumber
].href
!= originalTarget
) {
95 log("Failure! Link targets differ");
98 if (anchors
[linkNumber
].innerText
!= originalText
) {
99 log("Failure! Link texts differ");