diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/svg/test/test_SVGLengthList.xhtml | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/svg/test/test_SVGLengthList.xhtml')
-rw-r--r-- | dom/svg/test/test_SVGLengthList.xhtml | 159 |
1 files changed, 159 insertions, 0 deletions
diff --git a/dom/svg/test/test_SVGLengthList.xhtml b/dom/svg/test/test_SVGLengthList.xhtml new file mode 100644 index 000000000..3e0dab736 --- /dev/null +++ b/dom/svg/test/test_SVGLengthList.xhtml @@ -0,0 +1,159 @@ +<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 type="text/javascript" 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 + 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, false); + +]]> +</script> +</pre> +</body> +</html> |