dom/events/test/test_bug591249.xul

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 <?xml version="1.0"?>
michael@0 2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
michael@0 3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
michael@0 4 <!--
michael@0 5 https://bugzilla.mozilla.org/show_bug.cgi?id=591249
michael@0 6 -->
michael@0 7 <window title="Mozilla Bug 591249" onload="RunTest()"
michael@0 8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
michael@0 9
michael@0 10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
michael@0 11 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
michael@0 12
michael@0 13 <body xmlns="http://www.w3.org/1999/xhtml">
michael@0 14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=591249">Mozilla Bug 591249</a>
michael@0 15 <img id="image"
michael@0 16 src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAAG0lEQVR42mP8z0A%2BYKJA76jmUc2jmkc1U0EzACKcASfOgGoMAAAAAElFTkSuQmCC"
michael@0 17 ondragstart="event.preventDefault();"/>
michael@0 18 <iframe id="iframe" src="chrome://mochitests/content/chrome/dom/events/test/bug591249_iframe.xul" style="height: 300px; width: 100%;"></iframe>
michael@0 19 </body>
michael@0 20
michael@0 21 <script class="testbody" type="application/javascript;version=1.8"><![CDATA[
michael@0 22 /** Test for Bug 591249 **/
michael@0 23
michael@0 24 SimpleTest.waitForExplicitFinish();
michael@0 25
michael@0 26 function completeTest(aBox) {
michael@0 27 ok(window.getComputedStyle(aBox).backgroundColor == "rgb(255, 0, 0)", "The -moz-drag-over style should be removed.");
michael@0 28 SimpleTest.finish();
michael@0 29 }
michael@0 30
michael@0 31 function fireEvent(target, event) {
michael@0 32 var win = target.ownerDocument.defaultView;
michael@0 33 var utils =
michael@0 34 win.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
michael@0 35 getInterface(Components.interfaces.nsIDOMWindowUtils);
michael@0 36 utils.dispatchDOMEventViaPresShell(target, event, true);
michael@0 37 }
michael@0 38
michael@0 39 function RunTest() {
michael@0 40 var image = document.getElementById("image");
michael@0 41 var iframe = document.getElementById("iframe");
michael@0 42 var iBox = iframe.contentDocument.getElementById("drop-target");
michael@0 43 var insideBoxX = iBox.offsetWidth + 10;
michael@0 44 var insideBoxY = iBox.offsetHeight + 10;
michael@0 45
michael@0 46 var dataTransfer;
michael@0 47 var trapDrag = function(event) {
michael@0 48 dataTransfer = event.dataTransfer;
michael@0 49 dataTransfer.setData("text/plain", "Hello");
michael@0 50 dataTransfer.dropEffect = "move";
michael@0 51 event.preventDefault();
michael@0 52 event.stopPropagation();
michael@0 53 }
michael@0 54
michael@0 55 // need to use real mouse action to get the dataTransfer
michael@0 56 window.addEventListener("dragstart", trapDrag, true);
michael@0 57 synthesizeMouse(image, 2, 2, { type: "mousedown" });
michael@0 58 synthesizeMouse(image, 11, 11, { type: "mousemove" });
michael@0 59 synthesizeMouse(image, 20, 20, { type: "mousemove" });
michael@0 60 window.removeEventListener("dragstart", trapDrag, true);
michael@0 61 synthesizeMouse(image, 20, 20, { type: "mouseup" });
michael@0 62
michael@0 63 var event = document.createEvent("DragEvents");
michael@0 64 event.initDragEvent("dragover", true, true, iBox.ownerDocument.defaultView, 0, 0, 0, 0, 0, false, false, false, false, 0, iBox, dataTransfer);
michael@0 65 fireEvent(iBox, event);
michael@0 66 synthesizeMouse(image, 3, 3, { type: "mousedown" });
michael@0 67 synthesizeMouse(image, 23, 23, { type: "mousemove" });
michael@0 68 synthesizeMouse(iBox, insideBoxX, insideBoxY, { type: "mousemove" });
michael@0 69 ok(window.getComputedStyle(iBox).backgroundColor == "rgb(255, 255, 0)", "The -moz-drag-over style should be applied.");
michael@0 70 synthesizeMouse(iBox, insideBoxX, insideBoxY, { type: "mouseup" });
michael@0 71 window.setTimeout(function () { completeTest(iBox); }, 40);
michael@0 72 }
michael@0 73 ]]></script>
michael@0 74
michael@0 75 </window>

mercurial