3 <script src=
"../../resources/js-test.js"></script>
5 #dropTarget, #dragMe { text-align: center; display: table-cell; vertical-align: middle }
6 #dropTarget {width:
256px; height:
256px; border:
1px dashed}
7 #dragMe {-webkit-user-drag: element; -webkit-user-select: none; background: #ff0000; width:
64px; height:
64px; color: white}
12 var effectAllowedElem
;
17 window
.onload = function()
19 dragMe
= document
.getElementById("dragMe");
20 dropTarget
= document
.getElementById("dropTarget");
21 consoleElm
= document
.getElementById("console");
23 if (!dragMe
|| !dropTarget
|| !consoleElm
)
26 dragMe
.ondragstart
= dragStart
;
27 dragMe
.ondragend
= dragEnd
;
29 dropTarget
.ondragenter
= dragEntered
;
30 dropTarget
.ondragover
= dragOver
;
31 dropTarget
.ondrop
= drop
;
38 var validEffectAllowedList
= ["all", "copy", "copyLink", "copyMove", "link", "linkMove", "move", "none", "uninitialized"];
39 var effectAllowedListToTest
= ["all", "copy", "bogus", "copyLink", "wrong", "copyMove", "linkCopyMove", "link",
40 "linkMove", "move", "none", "uninitialized", "dummy", "bogus", "fake", "illegal", null, undefined , ""];
44 for (var i
= 0; i
< effectAllowedListToTest
.length
; i
++) {
45 var effectAllowedBefore
= e
.dataTransfer
.effectAllowed
;
46 e
.dataTransfer
.effectAllowed
= effectAllowedListToTest
[i
];
47 if (validEffectAllowedList
.indexOf(effectAllowedListToTest
[i
]) != -1)
48 shouldBeEqualToString("event.dataTransfer.effectAllowed", effectAllowedListToTest
[i
]);
50 shouldBeEqualToString("event.dataTransfer.effectAllowed", effectAllowedBefore
);
53 e
.dataTransfer
.setData('Text', e
.target
.textContent
);
61 function dragEntered(e
)
63 dragEnteredAndUpdated(e
);
68 dragEnteredAndUpdated(e
);
71 function dragEnteredAndUpdated(e
)
73 var validDropEffectList
= ["none", "copy", "link", "move", "link"];
74 var dropEffectListToTest
= ["all", "copy", "bogus", "copyLink", "wrong", "copyMove", "linkCopyMove", "link",
75 "linkMove", "move", "none", "uninitialized", "dummy", "bogus", "fake", "illegal", null, undefined , ""];
79 for (var i
= 0; i
< dropEffectListToTest
.length
; i
++) {
80 var dropEffectBefore
= e
.dataTransfer
.dropEffect
;
81 e
.dataTransfer
.dropEffect
= dropEffectListToTest
[i
];
83 if (validDropEffectList
.indexOf(dropEffectListToTest
[i
]) != -1)
84 shouldBeEqualToString("event.dataTransfer.dropEffect", dropEffectListToTest
[i
]);
86 shouldBeEqualToString("event.dataTransfer.dropEffect", dropEffectBefore
);
98 function cancelDrag(e
)
105 if (!window
.eventSender
)
108 if (window
.testRunner
)
109 testRunner
.dumpAsText();
111 var startX
= dragMe
.offsetLeft
+ 10;
112 var startY
= dragMe
.offsetTop
+ dragMe
.offsetHeight
/ 2;
113 var endX
= dropTarget
.offsetLeft
+ 10;
114 var endY
= dropTarget
.offsetTop
+ dropTarget
.offsetHeight
/ 2;
116 eventSender
.mouseMoveTo(startX
, startY
);
117 eventSender
.mouseDown();
118 eventSender
.leapForward(100);
119 eventSender
.mouseMoveTo(endX
, endY
);
120 eventSender
.mouseUp();
122 var testContainer
= document
.getElementById("test-container");
124 document
.body
.removeChild(testContainer
);
125 debug('<br /><span class="pass">TEST COMPLETE</span>');
130 <p id=
"description"></p>
131 <div id=
"test-container">
133 <div id=
"dropTarget">Drop the red square onto me.
<br/><br/></div>
135 <p>Items that can be dragged to the drop target:
</p>
136 <div id=
"dragMe" draggable=
"true">Square
</div>
139 <div id=
"console"></div>
141 description("This test checks that effectAllowed and dropEffect cannot be set to values that aren't defined in the spec");