file_animations_styles_on_event.html 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script type="application/javascript"
  5. src="/tests/SimpleTest/EventUtils.js"></script>
  6. <script type="application/javascript"
  7. src="/tests/SimpleTest/paint_listener.js"></script>
  8. <script type="application/javascript"
  9. src="animation_utils.js"></script>
  10. <style type="text/css">
  11. @keyframes anim {
  12. 0% { transform: translateX(0px) }
  13. 100% { transform: translateX(100px) }
  14. }
  15. .target {
  16. /* The animation target needs geometry in order to qualify for OMTA */
  17. width: 100px;
  18. height: 100px;
  19. background-color: white;
  20. }
  21. </style>
  22. <script>
  23. var is = opener.is.bind(opener);
  24. var ok = opener.ok.bind(opener);
  25. var todo = opener.todo.bind(opener);
  26. function finish() {
  27. var o = opener;
  28. self.close();
  29. o.SimpleTest.finish();
  30. }
  31. </script>
  32. </head>
  33. <body>
  34. <div id="display"></div>
  35. <script type="application/javascript">
  36. window.onload = function () {
  37. // To avoid the effect that newly created element's styles are
  38. // not updated immediately, we need to add an element without
  39. // animation properties first.
  40. var [ div ] = new_div("");
  41. div.setAttribute("id", "bug1228137");
  42. waitForPaints().then(function() {
  43. var initialRect = div.getBoundingClientRect();
  44. // Now we can set animation properties.
  45. div.style.animation = "anim 100s linear forwards";
  46. div.addEventListener("mousemove", function(event) {
  47. is(event.target.id, "bug1228137",
  48. "The target of the animation should receive the mouse move event " +
  49. "on the position of the animation's effect end.");
  50. done_div();
  51. finish();
  52. }, false);
  53. var animation = div.getAnimations()[0];
  54. animation.finish();
  55. // Mouse over where the animation is positioned at finished state.
  56. // We can't use synthesizeMouse here since synthesizeMouse causes
  57. // layout flush. We need to check the position without explicit flushes.
  58. synthesizeMouseAtPoint(initialRect.left + initialRect.width / 2 + 100,
  59. initialRect.top + initialRect.height / 2,
  60. { type: "mousemove" }, window);
  61. });
  62. };
  63. </script>
  64. </body>
  65. </html>