| <head> |
| <script> |
| function log(msg) |
| { |
| document.getElementById("log").appendChild(document.createTextNode(msg + "\n")); |
| } |
| |
| function testDragEventBubbling(dragTargetId, dragTargetParentId) |
| { |
| var dragTargetParent = document.getElementById(dragTargetParentId); |
| dragTargetParent.ondragenter = function() { |
| log("ondragenter"); |
| } |
| dragTargetParent.ondragover = function() { |
| log("ondragover"); |
| event.dataTransfer.dropEffect = "copy"; |
| event.preventDefault(); // Cancel the drag, so we get the drop. |
| } |
| dragTargetParent.ondragleave = function() { |
| log("ondragleave"); |
| } |
| dragTargetParent.ondrop = function() { |
| log("ondrop"); |
| } |
| |
| var abe = document.getElementById("abe"); |
| var dragTarget = document.getElementById(dragTargetId); |
| |
| eventSender.mouseMoveTo(abe.offsetLeft + 50, abe.offsetTop + 50); |
| eventSender.mouseDown(); |
| eventSender.mouseUp(); |
| eventSender.mouseDown(); |
| eventSender.mouseUp(); |
| // Leap forward so that the next mouseDown doesn't trigger a triple click. |
| eventSender.leapForward(1200); |
| |
| eventSender.mouseDown(); |
| // Leap forward so that the mouse movement causes a drag instead of selection creation. |
| eventSender.leapForward(500); |
| |
| eventSender.mouseMoveTo(dragTarget.offsetLeft + 1, dragTarget.offsetTop + 1); |
| eventSender.mouseUp(); |
| } |
| |
| window.onload = function () |
| { |
| if (window.testRunner) |
| testRunner.dumpAsText(); |
| |
| log("Tests that we don't bubble up the events if we drag something to an iframe that has an invalid source"); |
| testDragEventBubbling("invalidIframeDragTargetParent", "invalidIframeDragTarget"); |
| |
| log("Tests that we don't bubble up the events if we drag something to an iframe that has a valid source"); |
| testDragEventBubbling("validIframeDragTargetParent", "validIframeDragTarget"); |
| |
| log("Tests that we bubble up the events if we drag something to a non-iframe target"); |
| testDragEventBubbling("validSpanDragTargetParent", "validSpanDragTarget"); |
| |
| testRunner.notifyDone(); |
| } |
| </script> |
| </head> |
| |
| <p>This page tests the drag event bubbling with valid and invalid targets.</p> |
| <img id="abe" src="http://127.0.0.1:8000/security/resources/abe.png"> |
| <div id="invalidIframeDragTargetParent"> |
| <iframe id="invalidIframeDragTarget" src="file:"></iframe> |
| </div> |
| <div id="validIframeDragTargetParent"> |
| <iframe id="validIframeDragTarget" src="data:text/html,<body>Working</body>"></iframe> |
| </div> |
| <div contentEditable id="validSpanDragTargetParent"> |
| <span id="validSpanDragTarget">Drag here.</span> |
| </div> |
| <pre id="log"></pre> |