| <!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] --> |
| <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 id="test1"><attachment id='attachment'></attachment></div> |
| <div contenteditable=true id="target"></div> |
| <div id="console"></div> |
| |
| <script> |
| description('These tests dragging an attachment element into contenteditable'); |
| var jsTestIsAsync = true; |
| var target = document.getElementById('target'); |
| |
| function contentInserted() { |
| shouldBe('target.getElementsByTagName("attachment").length', '1'); |
| shouldBeEqualToString('target.getElementsByTagName("attachment")[0].file.name', 'apple.gif'); |
| finishJSTest(); |
| } |
| |
| function setupAttachment() { |
| if (window.internals) { |
| var attachment = document.getElementById('attachment'); |
| attachment.file = window.internals.createFile("resources/apple.gif"); |
| } |
| } |
| |
| function runTest() { |
| setupAttachment(); |
| target.addEventListener('DOMNodeInserted', contentInserted, false); |
| if (!window.testRunner) |
| return; |
| |
| e = document.getElementById("attachment"); |
| 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> |