2 .box { width:
100px; height:
90px; margin-bottom:
10px; background-color: lightblue; }
3 .drag-element { -webkit-user-drag: element; }
4 .drag-none { -webkit-user-drag: none; }
5 a { display: block; width:
80px; height:
80px; background-color: yellow; font-family: Ahem; font-size:
25px; }
6 a span { color: orange; }
7 a img { vertical-align: bottom; }
9 <div id=
"container" style=
"position: relative;">
10 <div class=
"box" expect=
"IMG nil">
11 <img src=
"resources/greenbox.png">
14 <div class=
"box" expect=
"nil nil">
15 <img class=
"drag-none" src=
"resources/greenbox.png">
18 <div class=
"box drag-element" expect=
"DIV DIV">
19 <img class=
"drag-none" src=
"resources/greenbox.png">
22 <div class=
"box" expect=
"IMG A A A nil">
23 <a href=
"#"><img src=
"resources/greenbox.png">x
<br><span>y
</span></a>
26 <div class=
"box" expect=
"IMG A A A nil">
27 <a href=
"#" class=
"drag-element"><img src=
"resources/greenbox.png">x
<br><span>y
</span></a>
30 <div class=
"box" expect=
"IMG nil nil nil nil">
31 <a href=
"#" class=
"drag-none"><img src=
"resources/greenbox.png">x
<br><span>y
</span></a>
34 <div class=
"box" expect=
"A A A A nil">
35 <a href=
"#"><img class=
"drag-none" src=
"resources/greenbox.png">x
<br><span>y
</span></a>
38 <div class=
"box" expect=
"A A A A nil">
39 <a href=
"#" class=
"drag-element"><img class=
"drag-none" src=
"resources/greenbox.png">x
<br><span>y
</span></a>
42 <div class=
"box drag-element" expect=
"IMG DIV DIV DIV DIV">
43 <a href=
"#" class=
"drag-none"><img src=
"resources/greenbox.png">x
<br><span>y
</span></a>
46 <div class=
"box drag-element" expect=
"A A A A DIV">
47 <a href=
"#"><img class=
"drag-none" src=
"resources/greenbox.png">x
<br><span>y
</span></a>
50 <div class=
"box drag-element" expect=
"A A A A DIV">
51 <a href=
"#" class=
"drag-element"><img class=
"drag-none" src=
"resources/greenbox.png">x
<br><span>y
</span></a>
54 <pre id=
"console"></pre>
58 document
.getElementById("console").appendChild(document
.createTextNode(message
+ "\n"));
61 onload
= window
.testRunner
? function()
63 testRunner
.dumpAsText();
65 var container
= document
.getElementById("container");
66 var y
= container
.getBoundingClientRect().top
;
67 for (var i
= 0; i
< container
.childElementCount
; ++i
) {
68 var listener = function(event
)
70 result
= event
.target
.nodeType
=== Node
.TEXT_NODE
? "text" : event
.target
.tagName
;
73 container
.addEventListener("dragstart", listener
);
75 var child
= container
.children
[i
];
78 var expectedResults
= child
.getAttribute("expect").split(" ");
83 if (expectedResults
.length
) {
84 getSelection().empty();
86 eventSender
.mouseMoveTo(h
, y
- scrollY
+ v
);
87 eventSender
.mouseDown();
88 eventSender
.mouseMoveTo(220, y
- scrollY
+ v
);
89 eventSender
.mouseUp();
90 var expected
= expectedResults
.shift();
91 log(result
=== expected
? "PASS" : "FAIL: expected " + expected
+ " but got " + result
);
101 container
.removeEventListener("dragstart", listener
);