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/004.html - WPT Dashboard Interop Dashboard
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Removing input element during drag and drop of selection</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>
input {
width: 8ch;
}
div {
min-height: 100px;
width: 100px;
padding: 20px;
color: white;
background-color: navy;
}
</style>
<script>
function sourceDragStart(event) {
event.currentTarget.remove();
}
function targetDrop(event) {
const text = event.dataTransfer.getData('text/plain');
event.currentTarget.appendChild(
document.createTextNode(text === 'Drag me' ? 'PASS' : 'FAIL'));
}
</script>
</head>
<body onload="document.querySelector('input').select()">
<p><input value="Drag me" ondragstart="sourceDragStart(event)"></p>
<div ondragover="return false" ondrop="targetDrop(event)"></div>
<script>
const target = document.querySelector('div');
testDragSourceRemoval(document.querySelector('input'), target, {
dataType: 'text/plain',
expectedData: 'Drag me',
verifyDrop: () => {
assert_equals(
target.textContent, 'PASS', 'The drop handler receives the selection');
},
});
</script>
</body>
</html>