Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/editing/dnd/remove/006.html - WPT Dashboard Interop Dashboard
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Removing a element during drag and drop of link</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="../resources/test-helper.js"></script>
<script src="support/drag-source-removal.js"></script>
<style>
div {
min-height: 100px;
width: 100px;
padding: 20px;
color: white;
background-color: navy;
}
</style>
<script>
function sourceDragStart(event) {
event.dataTransfer.effectAllowed = 'copy';
event.currentTarget.remove();
}
function targetDrop(event) {
const url = event.dataTransfer.getData('text/uri-list').replace(/\r\n$/, '');
event.currentTarget.appendChild(
document.createTextNode(url === 'data:text/plain,1' ? 'PASS' : 'FAIL'));
}
</script>
</head>
<body>
<p><a href="data:text/plain,1" ondragstart="sourceDragStart(event)">Drag me</a></p>
<div ondragover="return false" ondrop="targetDrop(event)"></div>
<script>
const source = document.querySelector('a');
const target = document.querySelector('div');
testDragSourceRemoval(source, target, {
dataType: 'text/uri-list',
expectedData: source.href,
verifyDrop: () => {
assert_equals(
target.textContent, 'PASS', 'The drop handler receives the link URL');
},
});
</script>
</body>
</html>