diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/svg/linking/scripted/href-animate-element.html | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/svg/linking/scripted/href-animate-element.html')
-rw-r--r-- | testing/web-platform/tests/svg/linking/scripted/href-animate-element.html | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/testing/web-platform/tests/svg/linking/scripted/href-animate-element.html b/testing/web-platform/tests/svg/linking/scripted/href-animate-element.html new file mode 100644 index 0000000000..f0b99209a8 --- /dev/null +++ b/testing/web-platform/tests/svg/linking/scripted/href-animate-element.html @@ -0,0 +1,138 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<title>Href - animate element tests</title> +<script src='/resources/testharness.js'></script> +<script src='/resources/testharnessreport.js'></script> +<script src='testcommon.js'></script> +<body> +<div id='log'></div> +<svg id='svg' width='100' height='100' viewBox='0 0 100 100'></svg> +<script> +'use strict'; + +promise_test(function(t) { + var svg = document.getElementById('svg'); + var rect1 = createSVGElement(t, 'rect', svg, + { 'width': '10px', + 'height': '10px', + 'id': 'rect1' }); + var rect2 = createSVGElement(t, 'rect', svg, + { 'width': '10px', + 'height': '10px', + 'id': 'rect2' }); + var animate = createSVGElement(t, 'animate', svg, + { 'attributeName': 'x', + 'from': '0', + 'to': '100', + 'dur': '10s' }); + animate.setAttribute('href', '#rect1'); + animate.setAttributeNS(XLINKNS, 'xlink:href', '#rect2'); + assert_equals(animate.targetElement, rect1); + + return waitEvent(animate, 'begin').then(function() { + svg.pauseAnimations(); + svg.setCurrentTime(5); + assert_equals(rect1.x.animVal.value, 50); + assert_equals(rect2.x.animVal.value, 0); + }); +}, 'Test for animate element when setting both href and xlink:href'); + +promise_test(function(t) { + var svg = document.getElementById('svg'); + var rect1 = createSVGElement(t, 'rect', svg, + { 'width': '10px', + 'height': '10px', + 'id': 'rect1' }); + var rect2 = createSVGElement(t, 'rect', svg, + { 'width': '10px', + 'height': '10px', + 'id': 'rect2' }); + var transform = createSVGElement(t, 'animateTransform', svg, + { 'attributeName': 'transform', + 'type': 'translate', + 'from': '0', + 'to': '100', + 'dur': '10s' }); + + transform.setAttribute('href', '#rect1'); + transform.setAttributeNS(XLINKNS, 'xlink:href', '#rect2'); + assert_equals(transform.targetElement, rect1); + + return waitEvent(transform, 'begin').then(function() { + svg.pauseAnimations(); + svg.setCurrentTime(5); + assert_equals(rect1.getCTM().e, 50); + assert_equals(rect2.getCTM().e, 0); + }); +}, 'Test for animateTransform element when setting both href and xlink:href'); + +promise_test(function(t) { + var svg = document.getElementById('svg'); + var circle1 = createSVGElement(t, 'circle', svg, + { 'cx': '50', + 'cy': '50', + 'r': '40', + 'id': 'circle1' }); + var circle2 = createSVGElement(t, 'circle', svg, + { 'cx': '50', + 'cy': '50', + 'r': '40', + 'id': 'circle2' }); + var animate = createSVGElement(t, 'animate', svg, + { 'attributeName': 'cx', + 'from': '50', + 'to': '150', + 'dur': '10s' }); + animate.setAttribute('href', '#circle1'); + animate.setAttributeNS(XLINKNS, 'xlink:href', '#circle2'); + assert_equals(animate.targetElement, circle1); + + return waitEvent(animate, 'begin').then(function() { + svg.pauseAnimations(); + svg.setCurrentTime(5); + assert_equals(circle1.cx.animVal.value, 100); + assert_equals(circle2.cx.animVal.value, 50); + + animate.removeAttribute('href'); + assert_equals(animate.targetElement, circle2); + assert_equals(circle1.cx.animVal.value, 50); + assert_equals(circle2.cx.animVal.value, 100); + }); +}, 'Test for animate element when removing href but we still have xlink:href'); + +promise_test(function(t) { + var svg = document.getElementById('svg'); + var circle1 = createSVGElement(t, 'circle', svg, + { 'cx': '50', + 'cy': '50', + 'r': '40', + 'id': 'circle1' }); + var circle2 = createSVGElement(t, 'circle', svg, + { 'cx': '50', + 'cy': '50', + 'r': '40', + 'id': 'circle2' }); + var animate = createSVGElement(t, 'animate', svg, + { 'attributeName': 'cx', + 'from': '50', + 'to': '150', + 'dur': '10s' }); + animate.setAttribute('href', '#circle1'); + animate.setAttributeNS(XLINKNS, 'xlink:href', '#circle2'); + assert_equals(animate.targetElement, circle1); + + return waitEvent(animate, 'begin').then(function() { + svg.pauseAnimations(); + svg.setCurrentTime(5); + assert_equals(circle1.cx.animVal.value, 100); + assert_equals(circle2.cx.animVal.value, 50); + + animate.removeAttributeNS(XLINKNS, 'href'); + assert_equals(animate.targetElement, circle1); + assert_equals(circle1.cx.animVal.value, 100); + assert_equals(circle2.cx.animVal.value, 50); + }); +}, 'Test for animate element when removing xlink:href but we still have href'); + +</script> +</body> |