dynamic-pattern-01.svg 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <!--
  2. Any copyright is dedicated to the Public Domain.
  3. http://creativecommons.org/publicdomain/zero/1.0/
  4. -->
  5. <svg xmlns="http://www.w3.org/2000/svg" version="1.1" class="reftest-wait"
  6. xmlns:xlink="http://www.w3.org/1999/xlink" onload="startTest()">
  7. <title>Testing that dynamic changes to the element for a given ID are reflected in patterns</title>
  8. <rect id="u1" x="10%" width="11%" height="100%" fill="url(#r1)"/>
  9. <script>
  10. // force frame construction; test that parsing "r1" after frame construction
  11. // is still bound to "u1" eventually
  12. var rect = document.getElementById("u1").getBoundingClientRect();
  13. </script>
  14. <pattern id="r1" width="100%" height="100%" patternUnits="userSpaceOnUse">
  15. <rect width="100%" height="100%" fill="lime"/>
  16. </pattern>
  17. <pattern id="x" width="100%" height="100%" patternUnits="userSpaceOnUse">
  18. <rect width="100%" height="100%" fill="lime"/>
  19. </pattern>
  20. <rect id="u2" x="20%" width="11%" height="100%" fill="url(#r2)"/>
  21. <pattern id="r3" width="100%" height="100%" patternUnits="userSpaceOnUse">
  22. <rect width="100%" height="100%" fill="red"/>
  23. </pattern>
  24. <pattern id="r3" width="100%" height="100%" patternUnits="userSpaceOnUse">
  25. <rect width="100%" height="100%" fill="lime"/>
  26. </pattern>
  27. <rect id="u3" x="30%" width="11%" height="100%" fill="url(#r3)"/>
  28. <pattern id="r4" width="100%" height="100%" patternUnits="userSpaceOnUse">
  29. <rect width="100%" height="100%" fill="red"/>
  30. </pattern>
  31. <pattern id="r4" width="100%" height="100%" patternUnits="userSpaceOnUse">
  32. <rect width="100%" height="100%" fill="lime"/>
  33. </pattern>
  34. <rect id="u4" x="40%" width="11%" height="100%" fill="url(#r4)"/>
  35. <pattern id="r5" width="100%" height="100%" patternUnits="userSpaceOnUse">
  36. <rect width="100%" height="100%" fill="red"/>
  37. </pattern>
  38. <rect id="u5" x="50%" width="11%" height="100%" fill="url(#r5)"/>
  39. <pattern id="r6" width="100%" height="100%" patternUnits="userSpaceOnUse">
  40. <rect width="100%" height="100%" fill="red"/>
  41. </pattern>
  42. <pattern id="r6-2" width="100%" height="100%" patternUnits="userSpaceOnUse">
  43. <rect width="100%" height="100%" fill="lime"/>
  44. </pattern>
  45. <rect id="u6" x="60%" width="11%" height="100%" fill="url(#r6)"/>
  46. <pattern id="r7" width="100%" height="100%" patternUnits="userSpaceOnUse">
  47. <rect width="100%" height="100%" fill="lime"/>
  48. </pattern>
  49. <pattern id="r7-2" width="100%" height="100%" patternUnits="userSpaceOnUse">
  50. <rect width="100%" height="100%" fill="red"/>
  51. </pattern>
  52. <rect id="u7" x="70%" width="11%" height="100%" fill="url(#r7)"/>
  53. <pattern id="r8-2" width="100%" height="100%" patternUnits="userSpaceOnUse">
  54. <rect width="100%" height="100%" fill="lime"/>
  55. </pattern>
  56. <pattern id="r8" width="100%" height="100%" patternUnits="userSpaceOnUse">
  57. <rect width="100%" height="100%" fill="red"/>
  58. </pattern>
  59. <rect id="u8" x="80%" width="11%" height="100%" fill="url(#r8)"/>
  60. <rect width="11%" height="100%" fill="lime"/>
  61. <rect x="90%" width="11%" height="100%" fill="lime"/>
  62. <script>
  63. function startTest() {
  64. document.addEventListener("MozReftestInvalidate", doTest, false);
  65. setTimeout(doTest, 4000); // fallback for running outside reftest
  66. }
  67. function doTest() {
  68. // check that changing an id to "r2" lets u2 find it
  69. var r2 = document.getElementById("x");
  70. r2.setAttribute("id", "r2");
  71. var rect = document.getElementById("u3").getBoundingClientRect();
  72. // check that removing the bad r3 lets u3 find the good one
  73. var r3 = document.getElementById("r3");
  74. r3.parentNode.removeChild(r3);
  75. // check that renaming the bad r4 lets u4 find the good one
  76. var r4 = document.getElementById("r4");
  77. r4.removeAttribute("id");
  78. // check that changing u5's reference works
  79. var u5 = document.getElementById("u5");
  80. u5.setAttribute("fill", "url(#r1)");
  81. // check that inserting a good element before the bad r6 works
  82. var r6 = document.getElementById("r6-2");
  83. r6.parentNode.removeChild(r6);
  84. r6.setAttribute("id", "r6");
  85. document.documentElement.insertBefore(r6, document.documentElement.firstChild);
  86. // check that inserting a bad element after a good one doesn't break anything
  87. var r7 = document.getElementById("r7-2");
  88. r7.parentNode.removeChild(r7);
  89. r7.setAttribute("id", "r7");
  90. document.documentElement.appendChild(r7);
  91. // check that renaming a good element to r8 works
  92. var r8 = document.getElementById("r8-2");
  93. r8.setAttribute("id", "r8");
  94. document.documentElement.removeAttribute("class");
  95. }
  96. </script>
  97. </svg>