test_transitions_dynamic_changes.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=525530
  5. -->
  6. <head>
  7. <title>Test for Bug 525530</title>
  8. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  9. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  10. </head>
  11. <body>
  12. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=525530">Mozilla Bug 525530</a>
  13. <p id="display" style="text-indent: 100px"></p>
  14. <pre id="test">
  15. <script type="application/javascript">
  16. /** Test for Bug 525530 **/
  17. var p = document.getElementById("display");
  18. var cs = getComputedStyle(p, "");
  19. var utils = SpecialPowers.DOMWindowUtils;
  20. p.style.transitionProperty = "all";
  21. p.style.transitionDuration = "4s";
  22. p.style.transitionDelay = "-2s";
  23. p.style.transitionTimingFunction = "linear";
  24. is(cs.textIndent, "100px", "initial value");
  25. p.style.textIndent = "0";
  26. is(cs.textIndent, "50px", "transition is halfway");
  27. p.style.transitionDuration = "0s";
  28. is(cs.textIndent, "50px", "changing duration doesn't change transitioning");
  29. p.style.transitionDelay = "0s";
  30. is(cs.textIndent, "50px", "changing delay doesn't change transitioning");
  31. p.style.transitionProperty = "text-indent";
  32. is(cs.textIndent, "50px",
  33. "irrelevant change to transition property doesn't change transitioning");
  34. p.style.transitionProperty = "font";
  35. is(cs.textIndent, "0px",
  36. "relevant change to transition property does change transitioning");
  37. /** Test for Bug 522643 */
  38. p.style.transitionDuration = "4s";
  39. p.style.transitionDelay = "-2s";
  40. p.style.transitionProperty = "text-indent";
  41. p.style.textIndent = "100px";
  42. is(cs.textIndent, "50px", "transition is halfway");
  43. p.style.transitionDuration = "0s";
  44. p.style.transitionDelay = "0s";
  45. is(cs.textIndent, "50px",
  46. "changing duration and delay doesn't change transitioning");
  47. p.style.textIndent = "0px";
  48. is(cs.textIndent, "0px",
  49. "changing property after changing duration and delay stops transition");
  50. /** Test for Bug 1133375 */
  51. p.style.transitionDuration = "1s";
  52. p.style.transitionDelay = "-1s";
  53. p.style.transitionProperty = "text-indent";
  54. var endCount = 0;
  55. function incrementEndCount(event) { ++endCount; }
  56. p.addEventListener("transitionend", incrementEndCount, false);
  57. utils.advanceTimeAndRefresh(0);
  58. p.style.textIndent = "100px";
  59. is(cs.textIndent, "100px", "value should now be 100px");
  60. utils.advanceTimeAndRefresh(10);
  61. is(endCount, 0, "should not have started transition when combined duration less than or equal to 0");
  62. p.style.transitionDelay = "-2s";
  63. p.style.textIndent = "0";
  64. is(cs.textIndent, "0px", "value should now be 0px");
  65. utils.advanceTimeAndRefresh(10);
  66. is(endCount, 0, "should not have started transition when combined duration less than or equal to 0");
  67. utils.restoreNormalRefresh();
  68. p.style.textIndent = "";
  69. /** Test for bug 1144410 */
  70. utils.advanceTimeAndRefresh(0);
  71. p.style.transition = "opacity 200ms linear";
  72. p.style.opacity = "1";
  73. is(cs.opacity, "1", "bug 1144410 test - initial opacity");
  74. p.style.opacity = "0";
  75. is(cs.opacity, "1", "bug 1144410 test - opacity after starting transition");
  76. utils.advanceTimeAndRefresh(100);
  77. is(cs.opacity, "0.5", "bug 1144410 test - opacity during transition");
  78. utils.advanceTimeAndRefresh(200);
  79. is(cs.opacity, "0", "bug 1144410 test - opacity after transition");
  80. document.body.style.display = "none";
  81. is(cs.opacity, "0", "bug 1144410 test - opacity after display:none");
  82. p.style.opacity = "1";
  83. document.body.style.display = "";
  84. is(cs.opacity, "1", "bug 1144410 test - second transition, initial opacity");
  85. p.style.opacity = "0";
  86. is(cs.opacity, "1", "bug 1144410 test - opacity after starting second transition");
  87. utils.advanceTimeAndRefresh(100);
  88. is(cs.opacity, "0.5", "bug 1144410 test - opacity during second transition");
  89. utils.advanceTimeAndRefresh(200);
  90. is(cs.opacity, "0", "bug 1144410 test - opacity after second transition");
  91. utils.restoreNormalRefresh();
  92. p.style.opacity = "";
  93. p.style.transition = "";
  94. </script>
  95. </pre>
  96. </body>
  97. </html>