|
1 | 1 | <?xml version="1.0" encoding="utf-8"?>
|
2 | 2 | <html xmlns="http://www.w3.org/1999/xhtml">
|
3 |
| -<script src="/resources/testharness.js"></script> |
4 |
| -<script src="/resources/testharnessreport.js"></script> |
5 |
| -<script src="/resources/testdriver.js"></script> |
6 |
| -<script src="/resources/testdriver-vendor.js"></script> |
7 |
| -<script src="/resources/testdriver-actions.js"></script> |
8 |
| -<script src="../resources/test-helper.js"></script> |
9 | 3 | <head>
|
10 |
| - <title>dropEffect is correctly set when it matches effectAllowed</title> |
11 |
| - <style type="text/css"> |
12 |
| - div { |
13 |
| - display: inline-block; |
14 |
| - vertical-align: top; |
15 |
| - background-color: olive; |
16 |
| - color: white; |
17 |
| - padding: 20px; |
18 |
| - width: 100px; |
19 |
| - height: 100px; |
20 |
| - } |
21 |
| - |
22 |
| - div:nth-child(2) { |
23 |
| - background-color: green; |
24 |
| - } |
25 |
| - |
26 |
| - div:nth-child(3) { |
27 |
| - background-color: teal; |
28 |
| - } |
29 |
| - |
30 |
| - </style> |
| 4 | +<title>Selection drag and drop: allowed effects 'copy','move','link'</title> |
| 5 | +<style type="text/css"> |
| 6 | +div |
| 7 | + {display:inline-block; |
| 8 | + vertical-align:top; |
| 9 | + background-color:olive; |
| 10 | + color:white; |
| 11 | + padding:20px; |
| 12 | + width:100px; |
| 13 | + height:100px;} |
| 14 | +div:nth-child(2) |
| 15 | + {background-color:green;} |
| 16 | +div:nth-child(3) |
| 17 | + {background-color:teal;} |
| 18 | +</style> |
| 19 | +<script type="application/ecmascript"> |
| 20 | +var effects = ['copy','move','link'], i = 0; |
| 21 | +function selectText() |
| 22 | + {window.getSelection().selectAllChildren(document.querySelector('p'))} |
| 23 | +function dropSelection(event) |
| 24 | + {event.target.appendChild(document.createTextNode((event.dataTransfer.dropEffect == effects[i] && event.dataTransfer.effectAllowed == effects[i])?' PASS ':' FAIL ')); |
| 25 | + i = (i + 1)%3; |
| 26 | + selectText();} |
| 27 | +function start(event) |
| 28 | + {event.dataTransfer.effectAllowed = effects[i]} |
| 29 | +</script> |
31 | 30 | </head>
|
32 |
| -<body> |
33 |
| - <p> |
34 |
| - Drag these boxes. Each box has a different effectAllowed. |
35 |
| - </p> |
36 |
| - <p> |
37 |
| - <div id="copy-drag" draggable="true" |
38 |
| - ondragstart="event.dataTransfer.effectAllowed = 'copy'">copy</div> |
39 |
| - <div id="move-drag" draggable="true" |
40 |
| - ondragstart="event.dataTransfer.effectAllowed = 'move'">move</div> |
41 |
| - <div id="link-drag" draggable="true" |
42 |
| - ondragstart="event.dataTransfer.effectAllowed = 'link'">link</div> |
43 |
| - </p> |
44 |
| - <p> |
45 |
| - Drop on these boxes. Each box has a different dropEffect. |
46 |
| - </p> |
47 |
| - <p> |
48 |
| - <div id="copy-drop" ondragover="onDragOver(event, 'copy')">copy</div> |
49 |
| - <div id="move-drop" ondragover="onDragOver(event, 'move')">move</div> |
50 |
| - <div id="link-drop" ondragover="onDragOver(event, 'link')">link</div> |
51 |
| - </p> |
| 31 | +<body onload="selectText()"> |
| 32 | +<p ondragstart="start(event)">Drag me</p> |
| 33 | +<div ondragenter="event.preventDefault()" ondragover="return false" ondrop="dropSelection(event)"/> |
| 34 | +<div ondragenter="event.preventDefault()" ondragover="return false" ondrop="dropSelection(event)"/> |
| 35 | +<div ondragenter="event.preventDefault()" ondragover="return false" ondrop="dropSelection(event)"/> |
| 36 | +<p>You should be able to drag selection and drop it onto any of the green boxes.</p> |
52 | 37 | </body>
|
53 |
| -<script> |
54 |
| - function onDragOver(event, effectAllowed) { |
55 |
| - event.preventDefault(); |
56 |
| - event.dataTransfer.dropEffect = effectAllowed; |
57 |
| - } |
58 |
| - |
59 |
| - async function test() { |
60 |
| - await new Promise(loaded => window.addEventListener("load", loaded)); |
61 |
| - |
62 |
| - function onDropCallBack(event) { |
63 |
| - assert_equals(event.target.textContent, event.dataTransfer.dropEffect); |
64 |
| - assert_equals(event.target.textContent, event.dataTransfer |
65 |
| - .effectAllowed); |
66 |
| - return true; |
67 |
| - } |
68 |
| - for (const effect of ['copy', 'move', 'link']) { |
69 |
| - const dragDiv = document.getElementById(effect + '-drag'); |
70 |
| - const dropDiv = document.getElementById(effect + '-drop'); |
71 |
| - dragDropTest( |
72 |
| - dragDiv, dropDiv, onDropCallBack, |
73 |
| - 'dropEffect should match effectAllowed on drop for ' + effect); |
74 |
| - } |
75 |
| - } |
76 |
| - test(); |
77 |
| -</script> |
78 | 38 | </html>
|
0 commit comments