Last active
February 22, 2019 22:07
-
-
Save jimevans/2ffcbb0a0ec6b11251bc2bafe3c9b63a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <meta charset="utf-8"> | |
| <title>TestDriver actions: pointer move with origin pointer</title> | |
| <style> | |
| div.solidborder { | |
| border-style: solid; | |
| border-width: 1px; | |
| position: absolute; | |
| top: 80px | |
| left: 10px; | |
| width: 100px; | |
| height: 400px; | |
| padding: 0px; | |
| } | |
| </style> | |
| <h2 id="status"> | |
| 0,0 | |
| </h2> | |
| <div id="mousetracker" class="solidborder"> | |
| Move mouse here | |
| </div> | |
| <script> | |
| let xPos = 0; | |
| let yPos = 0; | |
| async_test(t => { | |
| let tracker = document.getElementById("mousetracker"); | |
| let status = document.getElementById("status"); | |
| document.getElementById("mousetracker").addEventListener("mousemove", | |
| e => { xPos = Math.round(e.pageX - e.target.getBoundingClientRect().left); | |
| yPos = Math.round(e.pageY - e.target.getBoundingClientRect().top); | |
| document.getElementById("status").innerHTML = xPos + "," + yPos; }); | |
| let actions = new test_driver.Actions() | |
| .pointerMove(0, 0, {origin: tracker}); | |
| actions.send() | |
| .then(t.step_func_done(() => assert_equals(xPos, 50); assert_equals(yPos, 200))) | |
| .catch(e => t.step_func(() => assert_unreached("Actions sequence failed " + e))); | |
| actions = new test_driver.Actions() | |
| .pointerMove(10, 20, {origin: "pointer"}); | |
| actions.send() | |
| .then(t.step_func_done(() => assert_equals(xPos, 60); assert_equals(yPos, 220))) | |
| .catch(e => t.step_func(() => assert_unreached("Actions sequence failed " + e))); | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment