summaryrefslogtreecommitdiffstats
path: root/layout/reftests/svg/dynamic-clipPath-01.svg
blob: 1d1e86ebb8617cc2e8e839c0974ac88e2e6c0440 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<!--
     Any copyright is dedicated to the Public Domain.
     http://creativecommons.org/publicdomain/zero/1.0/
-->
<svg xmlns="http://www.w3.org/2000/svg" version="1.1"
     class="reftest-wait"
     onload="startTest()"
     xmlns:xlink="http://www.w3.org/1999/xlink">
  <title>Testing that dynamic changes to the element for a given ID are reflected in clip-path</title>
  <defs>
    <svg id="d">
      <rect width="100%" height="50%" fill="lime"/>
      <rect y="50%" width="100%" height="50%" fill="red"/>
    </svg>
  </defs>

  <rect y="30%" width="100%" height="70%" fill="lime"/>

  <use xlink:href="#d" id="u1" x="10%" width="11%" height="100%" clip-path="url(#r1)"/>
  <script>
    // force frame construction; test that parsing "r1" after frame construction
    // is still bound to "u1" eventually
    var rect = document.getElementById("u1").getBoundingClientRect();
  </script>
  <clipPath id="r1">
    <rect width="100%" height="40%"/>
  </clipPath>

  <clipPath id="x">
    <rect width="100%" height="40%"/>
  </clipPath>
  <use xlink:href="#d" id="u2" x="20%" width="11%" height="100%" clip-path="url(#r2)"/>

  <clipPath id="r3">
    <rect width="100%" height="100%"/>
  </clipPath>
  <clipPath id="r3">
    <rect width="100%" height="40%"/>
  </clipPath>
  <use xlink:href="#d" id="u3" x="30%" width="11%" height="100%" clip-path="url(#r3)"/>

  <clipPath id="r4">
    <rect width="100%" height="100%"/>
  </clipPath>
  <clipPath id="r4">
    <rect width="100%" height="40%"/>
  </clipPath>
  <use xlink:href="#d" id="u4" x="40%" width="11%" height="100%" clip-path="url(#r4)"/>

  <clipPath id="r5">
    <rect width="100%" height="100%"/>
  </clipPath>
  <use xlink:href="#d" id="u5" x="50%" width="11%" height="100%" clip-path="url(#r5)"/>

  <clipPath id="r6">
    <rect width="100%" height="100%"/>
  </clipPath>
  <clipPath id="r6-2">
    <rect width="100%" height="40%"/>
  </clipPath>
  <use xlink:href="#d" id="u6" x="60%" width="11%" height="100%" clip-path="url(#r6)"/>

  <clipPath id="r7">
    <rect width="100%" height="40%"/>
  </clipPath>
  <clipPath id="r7-2">
    <rect width="100%" height="100%"/>
  </clipPath>
  <use xlink:href="#d" id="u7" x="70%" width="11%" height="100%" clip-path="url(#r7)"/>

  <clipPath id="r8-2">
    <rect width="100%" height="40%"/>
  </clipPath>
  <clipPath id="r8">
    <rect width="100%" height="100%"/>
  </clipPath>
  <use xlink:href="#d" id="u8" x="80%" width="11%" height="100%" clip-path="url(#r8)"/>

  <rect width="11%" height="100%" fill="lime"/>
  <rect x="90%" width="11%" height="100%" fill="lime"/>

  <script>
  function startTest() {
    document.addEventListener("MozReftestInvalidate", doTest, false);
    setTimeout(doTest, 4000); // fallback for running outside reftest
  }

  function doTest() {
    // check that changing an id to "r2" lets u2 find it
    var r2 = document.getElementById("x");
    r2.setAttribute("id", "r2");

    var rect = document.getElementById("u3").getBoundingClientRect();
    // check that removing the bad r3 lets u3 find the good one
    var r3 = document.getElementById("r3");
    r3.parentNode.removeChild(r3);

    // check that renaming the bad r4 lets u4 find the good one
    var r4 = document.getElementById("r4");
    r4.removeAttribute("id");

    // check that changing u5's reference works
    var u5 = document.getElementById("u5");
    u5.setAttribute("clip-path", "url(#r1)");

    // check that inserting a good element before the bad r6 works
    var r6 = document.getElementById("r6-2");
    r6.parentNode.removeChild(r6);
    r6.setAttribute("id", "r6");
    document.documentElement.insertBefore(r6, document.documentElement.firstChild);

    // check that inserting a bad element after a good one doesn't break anything
    var r7 = document.getElementById("r7-2");
    r7.parentNode.removeChild(r7);
    r7.setAttribute("id", "r7");
    document.documentElement.appendChild(r7);

    // check that renaming a good element to r8 works
    var r8 = document.getElementById("r8-2");
    r8.setAttribute("id", "r8");

    document.documentElement.removeAttribute("class");
  }
  </script>
</svg>