Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE HTML> | |
| 2 <script src="../../../../../resources/js-test.js"></script> | |
| 3 <style> | |
| 4 div.box { | |
| 5 margin: 5px; | |
| 6 padding: 20px; | |
| 7 float: left; | |
| 8 } | |
| 9 </style> | |
| 10 | |
| 11 <div id="grey" class="box" style="background-color:grey;"> | |
| 12 <div id="green" class="box" style="background-color:green;"> | |
| 13 </div> | |
| 14 <div id="blue" class="box" style="background-color:blue;"> | |
| 15 </div> | |
| 16 </div> | |
| 17 | |
| 18 <div id="console"></div> | |
| 19 | |
| 20 <script> | |
| 21 description("Verifies that trasition events are correctly fired in different poi nter capture scenarios for mouse."); | |
| 22 | |
| 23 var testSet = [ | |
| 24 { firstCapturing: 'none', secondCapturing: 'blue' }, | |
| 25 { firstCapturing: 'none', secondCapturing: 'green' }, | |
| 26 { firstCapturing: 'blue', secondCapturing: 'none' }, | |
| 27 { firstCapturing: 'green', secondCapturing: 'none' }, | |
| 28 { firstCapturing: 'blue', secondCapturing: 'green' }, | |
| 29 { firstCapturing: 'green', secondCapturing: 'blue' }, | |
| 30 ]; | |
| 31 | |
| 32 var mousePointerId = 1; | |
| 33 var loggingEnabled = true; | |
| 34 | |
| 35 var rect = document.getElementById("green").getBoundingClientRect(); | |
| 36 var x1 = rect.left + 5; | |
| 37 var y1 = rect.top + 5; | |
| 38 | |
| 39 var rect = document.getElementById("blue").getBoundingClientRect(); | |
| 40 var x2 = rect.left + 5; | |
| 41 var y2 = rect.top + 5; | |
| 42 | |
| 43 function init() { | |
| 44 var eventList = ["mouseenter", "mouseleave", "mouseover", "mouseout", "mousemo ve", | |
| 45 "pointerenter", "pointerleave", "pointerover", "pointerout", "pointermove", | |
| 46 "gotpointercapture", "lostpointercapture"]; | |
| 47 | |
| 48 document.addEventListener("lostpointercapture", function(event) { | |
|
mustaq
2016/03/22 15:28:43
We want to make sure |document| doesn't receive re
Navid Zolghadr
2016/03/22 18:00:24
Actually, as I copied this test from the other tes
| |
| 49 if (event.eventPhase == Event.AT_TARGET) { | |
| 50 debug("document received " + event.type); | |
| 51 } | |
| 52 }); | |
| 53 ["grey", "green", "blue"].forEach(function(id) { | |
| 54 var targetDiv = document.getElementById(id); | |
| 55 eventList.forEach(function(eventName) { | |
| 56 targetDiv.addEventListener(eventName, function(event) { | |
| 57 if (loggingEnabled && event.eventPhase == Event.AT_TARGET) { | |
| 58 debug(id + " received " + event.type); | |
| 59 } | |
| 60 }); | |
| 61 }); | |
| 62 }); | |
| 63 } | |
| 64 | |
| 65 function testScenario(testcase) { | |
| 66 debug(" ==== '" + testcase.firstCapturing + "' is capturing and then '" + t estcase.secondCapturing + "' will capture ===="); | |
| 67 loggingEnabled = false; | |
| 68 | |
| 69 // Initialize the position of the mouse | |
| 70 eventSender.mouseMoveTo(x1, y1); | |
| 71 eventSender.mouseDown(1); | |
| 72 | |
| 73 loggingEnabled = true; | |
| 74 | |
| 75 debug(" **** Set initial capturing and jiggle mouse in green *****"); | |
| 76 if (testcase.firstCapturing != "none") { | |
| 77 debug("--- Set pointercapture for " + testcase.firstCapturing + " ---"); | |
| 78 document.getElementById(testcase.firstCapturing).setPointerCapture(mousePoin terId); | |
| 79 } | |
| 80 eventSender.mouseMoveTo(x1+1, y1+1); | |
| 81 if (testcase.secondCapturing != "none") { | |
| 82 debug("--- Set pointercapture for " + testcase.secondCapturing + " ---"); | |
| 83 document.getElementById(testcase.secondCapturing).setPointerCapture(mousePoi nterId); | |
| 84 } else if(testcase.firstCapturing != "none") { | |
| 85 debug("--- Release pointercapture for " + testcase.firstCapturing + " ---"); | |
| 86 document.getElementById(testcase.firstCapturing).releasePointerCapture(mouse PointerId); | |
| 87 } | |
| 88 | |
| 89 debug(" **** Move to blue box *****"); | |
| 90 eventSender.mouseMoveTo(x2, y2); | |
| 91 | |
| 92 loggingEnabled = false; | |
| 93 // Reset the state | |
| 94 eventSender.mouseMoveTo(0, 0); | |
| 95 eventSender.mouseUp(1); | |
|
mustaq
2016/03/22 15:28:43
Please include the implicit-release-triggered-even
Navid Zolghadr
2016/03/22 18:00:24
I will log all the events so this case is covered
| |
| 96 eventSender.mouseDown(0); | |
| 97 eventSender.mouseUp(0); | |
| 98 eventSender.leapForward(500); | |
|
mustaq
2016/03/22 15:28:43
Why do you need these 3 lines (down, up, leapForwa
Navid Zolghadr
2016/03/22 18:00:24
I got it from my other test. IIRC without them Win
| |
| 99 debug(""); | |
| 100 } | |
| 101 | |
| 102 function runTests() { | |
| 103 for (var i = 0; i < testSet.length; i++) { | |
| 104 testScenario(testSet[i]); | |
| 105 } | |
| 106 } | |
| 107 | |
| 108 init(); | |
| 109 if (window.eventSender) | |
| 110 runTests(); | |
| 111 else | |
| 112 debug("This test requires eventSender"); | |
| 113 | |
| 114 </script> | |
| OLD | NEW |