Index: third_party/WebKit/LayoutTests/virtual/pointerevent/fast/events/pointerevents/mouse-pointer-capture-transition-events.html |
diff --git a/third_party/WebKit/LayoutTests/virtual/pointerevent/fast/events/pointerevents/mouse-pointer-capture-transition-events.html b/third_party/WebKit/LayoutTests/virtual/pointerevent/fast/events/pointerevents/mouse-pointer-capture-transition-events.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ab6f5eab8a5af544621f67c138f55600112c0c70 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/virtual/pointerevent/fast/events/pointerevents/mouse-pointer-capture-transition-events.html |
@@ -0,0 +1,112 @@ |
+<!DOCTYPE HTML> |
+<script src="../../../../../resources/js-test.js"></script> |
+<style> |
+div.box { |
+ margin: 5px; |
+ padding: 20px; |
+ float: left; |
+} |
+</style> |
+ |
+<div id="grey" class="box" style="background-color:grey;"> |
+ <div id="green" class="box" style="background-color:green;"> |
+ </div> |
+ <div id="blue" class="box" style="background-color:blue;"> |
+ </div> |
+</div> |
+ |
+<div id="console"></div> |
+ |
+<script> |
+description("Verifies that trasition events are correctly fired in different pointer capture scenarios for mouse."); |
+ |
+var testSet = [ |
+ { firstCapturing: 'none', secondCapturing: 'blue' }, |
+ { firstCapturing: 'none', secondCapturing: 'green' }, |
+ { firstCapturing: 'blue', secondCapturing: 'none' }, |
+ { firstCapturing: 'green', secondCapturing: 'none' }, |
+ { firstCapturing: 'blue', secondCapturing: 'green' }, |
+ { firstCapturing: 'green', secondCapturing: 'blue' }, |
+]; |
+ |
+var mousePointerId = 1; |
+ |
+var rect = document.getElementById("green").getBoundingClientRect(); |
+var x1 = rect.left + 5; |
+var y1 = rect.top + 5; |
+ |
+var rect = document.getElementById("blue").getBoundingClientRect(); |
+var x2 = rect.left + 5; |
+var y2 = rect.top + 5; |
+ |
+function init() { |
+ var eventList = ["mouseenter", "mouseleave", "mouseover", "mouseout", "mousemove", |
+ "pointerenter", "pointerleave", "pointerover", "pointerout", "pointermove", |
+ "gotpointercapture", "lostpointercapture"]; |
+ |
+ ["grey", "green", "blue"].forEach(function(id) { |
+ var targetDiv = document.getElementById(id); |
+ eventList.forEach(function(eventName) { |
+ targetDiv.addEventListener(eventName, function(event) { |
+ if (event.eventPhase == Event.AT_TARGET) { |
+ debug(id + " received " + event.type); |
+ } |
+ }); |
+ }); |
+ }); |
+} |
+ |
+function testScenario(testcase, borderCross) { |
+ debug(" ==== '" + testcase.firstCapturing + "' is capturing and then '" + testcase.secondCapturing + "' will capture" + (borderCross ? "; will move pointer to 'blue'" : "") + " ===="); |
+ |
+ debug(" **** Move mouse to green and press *****"); |
+ eventSender.mouseMoveTo(x1, y1); |
+ eventSender.mouseDown(1); |
+ |
+ debug(" **** Set initial capturing and jiggle mouse in green *****"); |
+ if (testcase.firstCapturing != "none") { |
+ debug("--- Set pointercapture for " + testcase.firstCapturing + " ---"); |
+ document.getElementById(testcase.firstCapturing).setPointerCapture(mousePointerId); |
+ } |
+ eventSender.mouseMoveTo(x1+1, y1+1); |
+ if (testcase.secondCapturing != "none") { |
+ debug("--- Set pointercapture for " + testcase.secondCapturing + " ---"); |
+ document.getElementById(testcase.secondCapturing).setPointerCapture(mousePointerId); |
+ } else if(testcase.firstCapturing != "none") { |
+ debug("--- Release pointercapture for " + testcase.firstCapturing + " ---"); |
+ document.getElementById(testcase.firstCapturing).releasePointerCapture(mousePointerId); |
+ } |
+ |
+ if (borderCross) { |
+ debug(" **** Move to blue box *****"); |
+ eventSender.mouseMoveTo(x2, y2); |
+ } else { |
+ debug(" **** Jiggle mouse in green *****"); |
+ eventSender.mouseMoveTo(x1, y1); |
+ } |
+ |
+ debug(" **** Move out of grey, then release *****"); |
+ eventSender.mouseMoveTo(0, 0); |
+ eventSender.mouseUp(1); |
+ eventSender.mouseDown(0); |
+ eventSender.mouseUp(0); |
+ eventSender.leapForward(500); |
+ debug(""); |
+} |
+ |
+function runTests() { |
+ for (var i = 0; i < testSet.length; i++) { |
+ testScenario(testSet[i], true); |
+ } |
+ for (var i = 0; i < testSet.length; i++) { |
+ testScenario(testSet[i], false); |
+ } |
+} |
+ |
+init(); |
+if (window.eventSender) |
+ runTests(); |
+else |
+ debug("This test requires eventSender"); |
+ |
+</script> |