chromium/third_party/blink/web_tests/editing/pasteboard/drag-and-drop-inputimage-contenteditable.html

<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
<style>
#target {
    height: 200px;
    width: 220px;
    border: 5px solid blue;
}
</style>
</head>
<body onload="runTest()">
<p id="description"></p>
<div contenteditable=true id="target"></div>
<div><input type="image" id="source" src="resources/apple.gif" itemprop="somedata" arbitrary="green" draggable=true></div>
<div id="console"></div>

<script>
description('This test verify dragging an image in the page keeps its attributes. To test manually, drag the image and drop it in the rect with a blue border.');
var jsTestIsAsync = true;
var target = document.getElementById('target');

function contentInserted() {
    shouldBe('target.getElementsByTagName("input").length', '1');
    shouldBe('target.getElementsByTagName("input")[0].attributes.length', '6');
    shouldBeEqualToString('target.getElementsByTagName("input")[0].id', 'source');
    shouldBeEqualToString('target.getElementsByTagName("input")[0].type', 'image');
    shouldBeTrue('target.getElementsByTagName("input")[0].draggable');
    shouldBeEqualToString('target.getElementsByTagName("input")[0].attributes["itemprop"].value', 'somedata');
    shouldBeEqualToString('target.getElementsByTagName("input")[0].attributes["arbitrary"].value', 'green');

    finishJSTest();
}

function runTest() {
    target.addEventListener('DOMNodeInserted', contentInserted, false);
    if (!window.testRunner)
        return;

    testRunner.waitUntilDone();

    e = document.getElementById("source");
    x = e.offsetLeft + e.offsetWidth / 2;
    y = e.offsetTop + e.offsetHeight / 2;

    eventSender.mouseMoveTo(x, y);
    eventSender.mouseDown();
    eventSender.leapForward(100);
    e = document.getElementById("target");
    x = e.offsetLeft + e.offsetWidth / 2;
    y = e.offsetTop + e.offsetHeight / 2;

    eventSender.mouseMoveTo(x, y);
    eventSender.mouseUp();
}
</script>
</body>
</html>