blob: 088219ecbe5a5ba6003738f350cc569612dc1d67 [file] [log] [blame]
<!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><img id="source" src="resources/apple.gif" alt="alt-text" itemprop="somedata" arbitrary="green"></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("img").length', '1');
shouldBe('target.getElementsByTagName("img")[0].attributes.length', '5');
shouldBeEqualToString('target.getElementsByTagName("img")[0].id', 'source');
shouldBeEqualToString('target.getElementsByTagName("img")[0].alt', 'alt-text');
shouldBeEqualToString('target.getElementsByTagName("img")[0].attributes["itemprop"].value', 'somedata');
shouldBeEqualToString('target.getElementsByTagName("img")[0].attributes["arbitrary"].value', 'green');
finishJSTest();
}
function runTest() {
target.addEventListener('DOMNodeInserted', contentInserted, false);
if (!window.testRunner)
return;
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>