diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /dom/svg/test/test_SVGLengthList.xhtml | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/svg/test/test_SVGLengthList.xhtml')
-rw-r--r-- | dom/svg/test/test_SVGLengthList.xhtml | 158 |
1 files changed, 158 insertions, 0 deletions
diff --git a/dom/svg/test/test_SVGLengthList.xhtml b/dom/svg/test/test_SVGLengthList.xhtml new file mode 100644 index 0000000000..87b5c40d6b --- /dev/null +++ b/dom/svg/test/test_SVGLengthList.xhtml @@ -0,0 +1,158 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=515116 +--> +<head> + <title>Tests specific to SVGLengthList</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <script type="text/javascript" src="MutationEventChecker.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=515116">Mozilla Bug 515116</a> +<p id="display"></p> +<div id="content" style="display:none;"> +<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="100" height="100"> + <text id="text" x="10cm 20cm 30mc"/> + <rect id="rect" x="40" y="50"/> + <text id="text2" x="60"/> +</svg> +</div> +<pre id="test"> +<script class="testbody" type="text/javascript"> +<![CDATA[ + +SimpleTest.waitForExplicitFinish(); + +/* +This file runs a series of SVGLengthList specific tests. Generic SVGXxxList +tests can be found in test_SVGxxxList.xhtml. Anything that can be generalized +to other list types belongs there. +*/ + +function run_tests() { + document.getElementById("svg").pauseAnimations(); + + var text = document.getElementById("text"); + var lengths = text.x.baseVal; + + is(lengths.numberOfItems, 0, "Checking numberOfItems"); + + // Test mutation events + // --- Initialization + var eventChecker = new MutationEventChecker; + eventChecker.watchAttr(text, "x"); + eventChecker.expect("modify"); + text.textContent = "abc"; + text.setAttribute("x", "10 20 30"); + is(lengths.numberOfItems, 3, "Checking numberOfItems"); + // -- Actual changes + eventChecker.expect("modify modify modify modify modify"); + lengths[0].value = 8; + lengths[0].valueInSpecifiedUnits = 9; + lengths[0].valueAsString = "10"; + lengths[0].convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_CM); + lengths[0].newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_MM, 11); + // -- Redundant changes + eventChecker.expect("modify"); + lengths[0].valueAsString = "10"; + eventChecker.expect(""); + lengths[0].value = 10; + lengths[0].valueInSpecifiedUnits = 10; + lengths[0].valueAsString = "10"; + lengths[0].convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_NUMBER); + lengths[0].newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_NUMBER, 10); + // -- Invalid attribute + eventChecker.expect("modify"); + text.setAttribute("x", ",20"); + is(lengths.numberOfItems, 0, "Checking that parsing stops at invalid token"); + // -- Attribute removal + eventChecker.expect("remove"); + text.removeAttribute("x"); + // -- Non-existent attribute removal + eventChecker.expect(""); + text.removeAttribute("x"); + text.removeAttributeNS(null, "x"); + eventChecker.finish(); + + // Test that the addition of an owned SVGLength to an SVGLengthList creates a + // copy of the SVGLength, and an unowned SVGLength does not make a copy + var text2 = document.getElementById("text2"); + var rect = document.getElementById("rect"); + var subtests = [ + function initialize(aItem) { + text.removeAttribute("x"); + return lengths.initialize(aItem); + }, + function insertItemBefore(aItem) { + text.removeAttribute("x"); + return lengths.insertItemBefore(aItem, 0); + }, + function replaceItem(aItem) { + text.setAttribute("x", "10"); + return lengths.replaceItem(aItem, 0); + }, + function appendItem(aItem) { + text.removeAttribute("x"); + return lengths.appendItem(aItem); + }, + ]; + subtests.forEach(function(aFunction) { + // -- Adding an unowned SVGLength + var name = aFunction.name; + var existingItem = document.getElementById("svg").createSVGLength(); + var newItem = aFunction(existingItem); + is(newItem, lengths.getItem(0), name + " return value is correct when passed an unowned object"); + is(newItem, existingItem, name + " did not make a copy when passed an unowned object"); + }); + subtests.forEach(function(aFunction) { + // -- Adding an SVGLength that is a baseVal + var name = aFunction.name; + var existingItem = rect.x.baseVal; + var newItem = aFunction(existingItem); + is(newItem, lengths.getItem(0), name + " return value is correct when passed a baseVal"); + isnot(newItem, existingItem, name + " made a copy when passed a baseVal"); + is(newItem.value, existingItem.value, name + " made a copy with the right values when passed a baseVal"); + is(rect.x.baseVal, existingItem, name + " left the original object alone when passed a baseVal"); + }); + subtests.forEach(function(aFunction) { + // -- Adding an SVGLength that is an animVal + var name = aFunction.name; + var existingItem = rect.x.animVal; + var newItem = aFunction(existingItem); + is(newItem, lengths.getItem(0), name + " return value is correct when passed an animVal"); + isnot(newItem, existingItem, name + " made a copy when passed an animVal"); + is(newItem.value, existingItem.value, name + " made a copy with the right values when passed an animVal"); + is(rect.x.animVal, existingItem, name + " left the original object alone when passed an animVal"); + }); + subtests.forEach(function(aFunction) { + // -- Adding an SVGLength that is in a baseVal list + var name = aFunction.name; + var existingItem = text2.x.baseVal.getItem(0); + var newItem = aFunction(existingItem); + is(newItem, lengths.getItem(0), name + " return value is correct when passed a baseVal list item"); + isnot(newItem, existingItem, name + " made a copy when passed a baseVal list item"); + is(newItem.value, existingItem.value, name + " made a copy with the right values when passed a baseVal list item"); + is(text2.x.baseVal.getItem(0), existingItem, name + " left the original object alone when passed a baseVal list item"); + }); + subtests.forEach(function(aFunction) { + // -- Adding an SVGLength that is in a animVal list + var name = aFunction.name; + var existingItem = text2.x.animVal.getItem(0); + var newItem = aFunction(existingItem); + is(newItem, lengths.getItem(0), name + " return value is correct when passed a animVal list item"); + isnot(newItem, existingItem, name + " made a copy when passed a animVal list item"); + is(newItem.value, existingItem.value, name + " made a copy with the right values when passed a animVal list item"); + is(text2.x.animVal.getItem(0), existingItem, name + " left the original object alone when passed a animVal list item"); + }); + + SimpleTest.finish(); +} + +window.addEventListener("load", run_tests); + +]]> +</script> +</pre> +</body> +</html> |