1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
<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 src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script>
async function runTests()
{
let dragService = SpecialPowers.Cc["@mozilla.org/widget/dragservice;1"].
getService(SpecialPowers.Ci.nsIDragService);
let iframe = document.querySelector("iframe");
let iframeDoc = iframe.contentDocument;
let iframeWin = iframe.contentWindow;
let shadow = iframeDoc.querySelector('#outer').attachShadow({mode: 'open'});
let target = iframeDoc.createElement('a');
target.textContent = "Drag me if you can!";
const URL = "http://www.mozilla.org/";
target.href = URL;
shadow.appendChild(target);
// Some of the drag data we don't actually care about for this test,
// so we'll use this comparator function to ignore them.
function ignoreFunc(actualData, expectedData) {
return true;
}
const EXPECTED_DRAG_DATA = [[{
type: "text/x-moz-url",
data: "",
eqTest: ignoreFunc,
}, {
type: "text/x-moz-url-data",
data: "",
eqTest: ignoreFunc,
}, {
type: "text/x-moz-url-desc",
data: "",
eqTest: ignoreFunc,
}, {
type: "text/uri-list",
data: URL,
}, {
type: "text/_moz_htmlinfo",
data: "",
eqTest: ignoreFunc,
}, {
type: "text/html",
data: "",
eqTest: ignoreFunc,
}, {
type: "text/plain",
data: URL,
}]];
let result = await synthesizePlainDragAndCancel(
{
srcElement: target,
srcWindow: iframeWin,
finalY: -10, // Avoid clicking the link
},
EXPECTED_DRAG_DATA);
ok(result === true, "Should have gotten the expected drag data.");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
window.onload = () => {
SimpleTest.waitForFocus(runTests);
};
</script>
<body>
<iframe srcdoc='<div id="outer"/>'></iframe>
</body>
</html>
|