test_hover_quirk.html 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <html>
  2. <!--
  3. https://bugzilla.mozilla.org/show_bug.cgi?id=783213
  4. -->
  5. <head>
  6. <meta charset="utf-8">
  7. <title>Test for the :active and :hover quirk</title>
  8. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
  9. <style type="text/css">
  10. /* Should apply to all elements: */
  11. #content :hover:first-of-type {
  12. color: rgb(255, 0, 0);
  13. }
  14. #content :-moz-any(:hover) {
  15. text-transform: lowercase;
  16. }
  17. #content :hover::after {
  18. content: "any element";
  19. }
  20. #content :hover:first-of-type .child::after {
  21. content: "any child";
  22. }
  23. /* Should apply only to links: */
  24. #content :hover {
  25. color: rgb(0, 255, 0) !important;
  26. text-transform: uppercase !important;
  27. }
  28. #content :hover .child::after {
  29. content: "link child" !important;
  30. }
  31. </style>
  32. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  33. <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
  34. <script type="application/javascript">
  35. /** Test for the :active and :hover quirk **/
  36. function test(element, isLink) {
  37. if (!isLink)
  38. var styles = {color: "rgb(255, 0, 0)", textTransform: "lowercase",
  39. childContent: '"any child"'};
  40. else
  41. var styles = {color: "rgb(0, 255, 0)", textTransform: "uppercase",
  42. childContent: '"link child"'};
  43. // Trigger the :hover pseudo-class.
  44. synthesizeMouseAtCenter(element, {type: "mousemove"});
  45. var computedStyle = getComputedStyle(element);
  46. is(computedStyle.color, styles.color, "Unexpected color value");
  47. is(computedStyle.textTransform, styles.textTransform,
  48. "Unexpected text-transform value");
  49. computedStyle = getComputedStyle(element, "::after");
  50. is(computedStyle.content, '"any element"',
  51. "Unexpected pseudo-element content");
  52. computedStyle = getComputedStyle(
  53. element.getElementsByClassName("child")[0], "::after");
  54. is(computedStyle.content, styles.childContent,
  55. "Unexpected pseudo-element content for child");
  56. }
  57. SimpleTest.waitForExplicitFinish();
  58. SimpleTest.waitForFocus(function() {
  59. test(document.getElementById("span"), false);
  60. test(document.getElementById("label"), false);
  61. test(document.getElementById("link"), true);
  62. SimpleTest.finish();
  63. });
  64. </script>
  65. </head>
  66. <body>
  67. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=783213">Mozilla Bug 783213</a>
  68. <p id="display"></p>
  69. <div id="content">
  70. <span id="span">Span<span class="child"></span></span><br>
  71. <label id="label">Label<span class="child"></span></label><br>
  72. <a id="link" href="#">Link<span class="child"></span></a>
  73. </div>
  74. <pre id="test"></pre>
  75. </body>
  76. </html>