Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / pasteboard / drop-link.html
blobe0cdad37f204d5165520e5547c6de9e9ddd20976
1 <script>
2 if (window.testRunner)
3 testRunner.dumpEditingCallbacks();
4 </script>
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 &lt;/a&gt;&lt;a href="http://webkit.org/"&gt;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>
18 <script>
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));
25 li.appendChild(pre);
26 console.appendChild(li);
29 function runTest() {
30 if (!window.testRunner)
31 return;
32 testRunner.dumpAsText();
34 dragLink('grabme', 'destination');
35 dragLink('grabme2', 'destination2');
37 verifier();
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();
62 function verifier() {
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");
71 passed = false;
74 if (passed)
75 log("Success!");
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");
90 passed = false;
91 } else {
92 log("Link is " + anchors[linkNumber].href);
93 var passed = true;
94 if (anchors[linkNumber].href != originalTarget) {
95 log("Failure! Link targets differ");
96 passed = false;
98 if (anchors[linkNumber].innerText != originalText) {
99 log("Failure! Link texts differ");
100 passed = false;
103 return passed;
106 runTest();
107 </script>