Followup(r230063): Add test a layout test for https://bugs.webkit.org/show_bug.cgi...
authorsaid@apple.com <said@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Apr 2018 19:42:18 +0000 (19:42 +0000)
committersaid@apple.com <said@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Apr 2018 19:42:18 +0000 (19:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184162

Reviewed by Daniel Bates.

Without r230063, running run-webkit-tests -g for this test will crash.

* svg/dom/animated-tearoff-list-remove-target-expected.txt: Added.
* svg/dom/animated-tearoff-list-remove-target.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230172 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/svg/dom/animated-tearoff-list-remove-target-expected.txt [new file with mode: 0644]
LayoutTests/svg/dom/animated-tearoff-list-remove-target.html [new file with mode: 0644]

index 2dbde75..89a527c 100644 (file)
@@ -1,3 +1,15 @@
+2018-04-02  Said Abou-Hallawa  <sabouhallawa@apple.com>
+
+        Followup(r230063): Add test a layout test for https://bugs.webkit.org/show_bug.cgi?id=183972
+        https://bugs.webkit.org/show_bug.cgi?id=184162
+
+        Reviewed by Daniel Bates.
+
+        Without r230063, running run-webkit-tests -g for this test will crash.
+
+        * svg/dom/animated-tearoff-list-remove-target-expected.txt: Added.
+        * svg/dom/animated-tearoff-list-remove-target.html: Added.
+
 2018-04-02  Jer Noble  <jer.noble@apple.com>
 
         AudioBufferSourceNode start method causes OfflineAudioContext to start running
diff --git a/LayoutTests/svg/dom/animated-tearoff-list-remove-target-expected.txt b/LayoutTests/svg/dom/animated-tearoff-list-remove-target-expected.txt
new file mode 100644 (file)
index 0000000..722f2d9
--- /dev/null
@@ -0,0 +1,4 @@
+Removing the target of an animate element should detach the wrappers of the attributes from their animated properties.
+
+PASS.
+
diff --git a/LayoutTests/svg/dom/animated-tearoff-list-remove-target.html b/LayoutTests/svg/dom/animated-tearoff-list-remove-target.html
new file mode 100644 (file)
index 0000000..782de7e
--- /dev/null
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<body>
+    <div>Removing the target of an animate element should detach the wrappers of the attributes from their animated properties.</div>
+    <svg>
+        <text x="15" y="40">
+            <tspan id="first-tspan">First tspan.</tspan> 
+        </text>
+        <text x="15" y="60">
+            <tspan id="second-tspan">Second tspan</tspan> 
+        </text>
+        <animate id="animate" xlink:href="#first-tspan" attributeType="XML" attributeName="x" from="0" to="100" dur="10s" repeatCount="indefinite"/>
+    </svg>
+    <script>
+        function gc() {
+            if (window.GCController)
+                return GCController.collect();
+
+            // Force garbage collection.
+            for (var i = 0; i < 10000; i++)
+                var s = new String("abc");
+        }
+
+        (function() {
+            if (window.testRunner)  {
+                testRunner.dumpAsText();
+                testRunner.waitUntilDone();
+            }
+
+            setTimeout(() => {
+                // The target of the <animate> element is the "first-tspan".
+                var tspanElement = document.getElementById("first-tspan");
+
+                // animItem is a reference (not a copy) to the first item in the x animated list.
+                var animList = tspanElement.x.animVal;
+                var animItem = animList.getItem(0);
+
+                // Now change the target of the <animate> element to be the "second-tspan".
+                var animateElement = document.getElementById("animate");
+                animateElement.setAttributeNS("http://www.w3.org/1999/xlink", "href", "second-tspan");
+
+                // By now animItem should be detached from the animated animList and has its own copy
+                // of an SVGLength. animItem should not be affected if garbage collection is forced.
+                gc();
+                if (animItem.valueAsString == "0") {
+                    document.querySelector("div").innerHTML += "<br><br>PASS."
+                    document.querySelector("svg").remove();
+                }
+
+                if (window.testRunner)
+                    testRunner.notifyDone();
+            }, 0);
+        })();
+    </script>
+</body>