4
#dropTarget, #dragMe { text-align: center; display: table-cell; vertical-align: middle }
5
#dropTarget {width: 256px; height: 256px; border: 1px dashed}
6
#dragMe {-webkit-user-drag: element; -webkit-user-select: none; background: #ff0000; width: 64px; height: 64px; color: white}
7
.pass { font-weight: bold; color: green; }
8
.fail { font-weight: bold; color: red; }
14
var defaultMessageElm;
17
var ALLOWED_EFFECTS = 'move';
18
var DROP_EFFECT = 'copy';
20
window.onload = function()
22
dragMe = document.getElementById("dragMe");
23
dropTarget = document.getElementById("dropTarget");
24
messageElm = document.getElementById("message");
25
defaultMessageElm = document.getElementById("default-message");
27
if (!dragMe || !dropTarget || !messageElm || !defaultMessageElm)
30
dragMe.ondragstart = dragStart;
31
dragMe.ondragend = dragEnd;
33
dropTarget.ondragenter = dragEntered;
34
dropTarget.ondragover = dragOver;
35
dropTarget.ondrop = drop;
41
e.dataTransfer.effectAllowed = ALLOWED_EFFECTS;
42
e.dataTransfer.setData('Text', e.target.textContent);
47
messageElm.style.visibility = "hidden";
48
defaultMessageElm.style.visibility = "visible";
52
function dragEntered(e)
54
messageElm.style.visibility = "visible";
55
defaultMessageElm.style.visibility = "hidden";
56
dragEnteredAndUpdated(e);
61
dragEnteredAndUpdated(e);
64
function dragEnteredAndUpdated(e)
67
e.dataTransfer.dropEffect = DROP_EFFECT;
76
function cancelDrag(e)
81
// Assume this script is executing within Internet Explorer
82
e.returnValue = false;
88
<p id="description">This test can be used to verify that the not-allowed cursor is shown during an invalid drag-and-drop operation.
89
In particular, if the effectAllowed is <code><script>document.write(ALLOWED_EFFECTS)</script></code> and the dropEffect of the
90
drop target is <code><script>document.write(DROP_EFFECT)</script></code> then the drop is not allowed and the cursor should
91
change to the not-allowed cursor. Note, this test only pertains to the Windows build since the Mac build does not show a drop cursor
92
for a not-allowed drop operation (see bug #25925).
94
Drag the red square over the drop target (demarcated by the dashed boundary). While hovering over the drop target, if the cursor
95
is <img alt="not-allowed" src="data:image/gif;base64,R0lGODlhEgASAIAAAAAAAP///yH5BAAAAAAALAAAAAASABIAAAIvjA+px6ifmnmM1ijDmlbuuHmAhoWXaTqYKq7sObZw3HwgXd8cPr8yDGxBXEJioAAAOw=="> then the test <span class="pass">PASSED</span>. Otherwise, the test <span class="fail">FAILED</span>.</p>
96
<div id="test-container">
97
<label for="effectAllowed">effectAllowed:</label> <code><script>document.write(ALLOWED_EFFECTS)</script></code>
100
<div id="default-message">Drag the red square over me.<br/><br/>
101
<label for="dropEffect">Expects dropEffect:</label> <code><script>document.write(DROP_EFFECT)</script></code>
103
<div id="message" style="visibility:hidden">The cursor should be <img alt="not-allowed" src="data:image/gif;base64,R0lGODlhEgASAIAAAAAAAP///yH5BAAAAAAALAAAAAASABIAAAIvjA+px6ifmnmM1ijDmlbuuHmAhoWXaTqYKq7sObZw3HwgXd8cPr8yDGxBXEJioAAAOw==">. Is it?</div>
106
<p>Items that can be dragged to the drop target:</p>
107
<div id="dragMe" draggable="true">Square</div>