Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Reload during SVG image drag and drop roundtrip</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="support/drag-reload-test.js"></script>
<style>
body { margin: 20px; }
</style>
<script>
function sourceDragStart(event) {
event.dataTransfer.effectAllowed = 'copy';
location.reload();
}
function targetDrop(event) {
event.preventDefault();
const data = event.dataTransfer.getData('text/uri-list').replace(/\r\n$/, '');
const image = document.createElement('img');
image.id = 'dropped-image';
image.src = data;
event.currentTarget.after(image);
}
</script>
</head>
<body>
<img id="source" alt="SVG circle" width="100" height="100"
src="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%22100%22%20height%3D%22100%22%3E%3Ccircle%20cx%3D%2250%22%20cy%3D%2250%22%20r%3D%2250%22%20fill%3D%22green%22/%3E%3C/svg%3E"
ondragstart="sourceDragStart(event)" ondragenter="event.preventDefault()"
ondragover="event.preventDefault()" ondrop="targetDrop(event)">
<script>
testDragAcrossReload({
dataType: 'text/uri-list',
getExpectedData: source => source.src,
verifyDrop: async (target, expectedData) => {
const image = target.ownerDocument.getElementById('dropped-image');
assert_not_equals(image, null, 'The drop handler duplicates the image');
assert_equals(image.src, expectedData, 'The duplicate has the original URL');
await image.decode();
},
});
</script>
</body>
</html>