diff options
Diffstat (limited to 'dom/events/test/test_bug1264380.html')
-rw-r--r-- | dom/events/test/test_bug1264380.html | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/dom/events/test/test_bug1264380.html b/dom/events/test/test_bug1264380.html new file mode 100644 index 000000000..76b9fb46b --- /dev/null +++ b/dom/events/test/test_bug1264380.html @@ -0,0 +1,54 @@ +<html> +<head> + <title>Test the dragstart event on the anchor in side shadow DOM</title> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"> + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script> +<script> + +SimpleTest.waitForExplicitFinish(); + +SpecialPowers.pushPrefEnv({"set": [ + ["dom.webcomponents.enabled", true] +]}); + +function runTests() +{ + let dragService = SpecialPowers.Cc["@mozilla.org/widget/dragservice;1"]. + getService(SpecialPowers.Ci.nsIDragService); + + let shadow = document.querySelector('#outter').createShadowRoot(); + let target = document.createElement('a'); + let linkText = document.createTextNode("Drag me if you can!"); + target.appendChild(linkText); + target.href = "http://www.mozilla.org/"; + shadow.appendChild(target); + + let dataTransfer; + let trapDrag = function(event) { + ok(true, "Got dragstart event"); + dataTransfer = event.dataTransfer; + ok(dataTransfer, "DataTransfer object is available."); + is(dataTransfer.mozItemCount, 1, "initial link item count"); + is(dataTransfer.getData("text/uri-list"), "http://www.mozilla.org/", "link text/uri-list"); + is(dataTransfer.getData("text/plain"), "http://www.mozilla.org/", "link text/plain"); + } + + ok(!dragService.getCurrentSession(), "There shouldn't be a drag session!"); + window.addEventListener("dragstart", trapDrag, true); + synthesizeMouse(target, 2, 2, { type: "mousedown" }); + synthesizeMouse(target, 11, 11, { type: "mousemove" }); + synthesizeMouse(target, 20, 20, { type: "mousemove" }); + window.removeEventListener("dragstart", trapDrag, true); + ok(dragService.getCurrentSession(), "Drag session is available."); + dragService.endDragSession(false); + ok(!dragService.getCurrentSession(), "There shouldn't be a drag session anymore!"); + SimpleTest.finish(); +} + +</script> + +<body onload="window.setTimeout(runTests, 0);"> +<div id="outter"/> +</body> +</html> |