blob: 089b9d0047547f17dda92f77c336f38e63730918 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../fast/js/resources/js-test-pre.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.layoutTestController)
return;
layoutTestController.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>
<script src="../../fast/js/resources/js-test-post.js"></script>
</body>
</html>