blob: 1d51a98356565d98c1e50e83de682eb242ba429c [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><object id="source" data="resources/apple.gif" type="image/png" itemprop="somedata" arbitrary="green" draggable=true></object></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("object").length', '1');
shouldBe('target.getElementsByTagName("object")[0].attributes.length', '6');
shouldBeEqualToString('target.getElementsByTagName("object")[0].id', 'source');
shouldBeEqualToString('target.getElementsByTagName("object")[0].type', 'image/png');
shouldBeTrue('target.getElementsByTagName("object")[0].draggable');
shouldBeEqualToString('target.getElementsByTagName("object")[0].attributes["itemprop"].value', 'somedata');
shouldBeEqualToString('target.getElementsByTagName("object")[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>