зеркало из https://github.com/mozilla/gecko-dev.git
61 строка
2.2 KiB
HTML
61 строка
2.2 KiB
HTML
<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>
|
|
|
|
function runTests()
|
|
{
|
|
let dragService = SpecialPowers.Cc["@mozilla.org/widget/dragservice;1"].
|
|
getService(SpecialPowers.Ci.nsIDragService);
|
|
|
|
let iframe = document.createElement('iframe');
|
|
document.body.appendChild(iframe);
|
|
iframe.contentDocument.body.innerHTML = '<div id="outter"/>';
|
|
|
|
let iframeDoc = iframe.contentDocument;
|
|
let iframeWin = iframe.contentWindow;
|
|
|
|
let shadow = iframeDoc.querySelector('#outter').attachShadow({mode: 'open'});
|
|
let target = iframeDoc.createElement('a');
|
|
let linkText = iframeDoc.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(SpecialPowers.wrap(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!");
|
|
iframeWin.addEventListener("dragstart", trapDrag, true);
|
|
synthesizeMouse(target, 2, 2, { type: "mousedown" }, iframeWin);
|
|
synthesizeMouse(target, 11, 11, { type: "mousemove" }, iframeWin);
|
|
synthesizeMouse(target, 20, 20, { type: "mousemove" }, iframeWin);
|
|
iframeWin.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();
|
|
}
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
window.onload = () => {
|
|
SimpleTest.waitForFocus(runTests);
|
|
};
|
|
|
|
</script>
|
|
|
|
<body>
|
|
</body>
|
|
</html>
|