summaryrefslogtreecommitdiffstats
path: root/dom/svg/test/test_animLengthObjectIdentity.xhtml
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /dom/svg/test/test_animLengthObjectIdentity.xhtml
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/svg/test/test_animLengthObjectIdentity.xhtml')
-rw-r--r--dom/svg/test/test_animLengthObjectIdentity.xhtml86
1 files changed, 86 insertions, 0 deletions
diff --git a/dom/svg/test/test_animLengthObjectIdentity.xhtml b/dom/svg/test/test_animLengthObjectIdentity.xhtml
new file mode 100644
index 0000000000..b4bce755b9
--- /dev/null
+++ b/dom/svg/test/test_animLengthObjectIdentity.xhtml
@@ -0,0 +1,86 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=508496
+-->
+<head>
+ <title>Test for object identity of SVG animated lengths</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=506856">Mozilla Bug 508496</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="120px" height="120px"
+ onload="this.pauseAnimations()">
+ <circle cx="-100" cy="-100" r="15" fill="blue" id="circle">
+ <animate attributeName="cx" from="0" to="100" dur="4s" begin="1s; 10s"
+ fill="freeze" id="animate"/>
+ </circle>
+</svg>
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+<![CDATA[
+/** Test object identity of animated lengths **/
+
+/* Global Variables */
+const svgns = "http://www.w3.org/2000/svg";
+var svg = document.getElementById("svg");
+var circle = document.getElementById("circle");
+
+SimpleTest.waitForExplicitFinish();
+
+function main() {
+ ok(svg.animationsPaused(), "should be paused by <svg> load handler");
+ is(svg.getCurrentTime(), 0, "should be paused at 0 in <svg> load handler");
+
+ var animLength = circle.cx;
+ ok(animLength === circle.cx,
+ "Got different SVGAnimatedLength objects at startup");
+
+ var baseVal = circle.cx.baseVal;
+ ok(baseVal === circle.cx.baseVal,
+ "Got different baseVal SVGLength objects at startup");
+
+ var animVal = circle.cx.animVal;
+ ok(animVal === circle.cx.animVal,
+ "Got different animVal SVGLength objects at startup");
+
+ var animate = document.getElementById("animate");
+ if (animate && animate.targetElement) {
+ // Sample mid-way through the animation
+ svg.setCurrentTime(5);
+
+ ok(animLength === circle.cx,
+ "Got different SVGAnimatedLength objects during animation");
+ ok(baseVal === circle.cx.baseVal,
+ "Got different baseVal SVGLength objects during animation");
+ ok(animVal === circle.cx.animVal,
+ "Got different animVal SVGLength objects during animation");
+ }
+
+ // Drop all references to the tear off objects
+ var oldValue = circle.cx.animVal.value; // Just a float, not an object ref
+ animLength = null;
+ baseVal = null;
+ animVal = null;
+ SpecialPowers.gc();
+
+ // The tearoff objects should no longer exist and we should create new ones.
+ // If somehow, the tearoff objects have died and yet not been removed from the
+ // hashmap we'll end up in all sorts of trouble when we try to access them.
+ // So in the following, we're not really interested in the value, just that we
+ // don't crash.
+ is(circle.cx.animVal.value, oldValue,
+ "Unexpected result accessing new(?) length object.");
+
+ SimpleTest.finish();
+}
+
+window.addEventListener("load", main);
+]]>
+</script>
+</pre>
+</body>
+</html>