Bug 580796 - "ASSERTION: Returning unknown unit type" regression from bug 515116. r=longsonr a=roc
authorJonathan Watt <jwatt@jwatt.org>
Sun, 05 Dec 2010 20:28:08 +0000
changeset 58639 50985e5fa3e383b7e6ae5389f22f07aee1c58e9e
parent 58638 0ec22e77aefc7a690cf6a96f466f9d0056fc2f39
child 58640 b1a4d82fb98ad6f094e3b3e84615a48cc62fac1a
push idunknown
push userunknown
push dateunknown
reviewerslongsonr, roc
bugs580796, 515116
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 580796 - "ASSERTION: Returning unknown unit type" regression from bug 515116. r=longsonr a=roc
content/svg/content/src/SVGLength.cpp
content/svg/content/test/Makefile.in
content/svg/content/test/test_SVGLengthList.xhtml
--- a/content/svg/content/src/SVGLength.cpp
+++ b/content/svg/content/src/SVGLength.cpp
@@ -81,16 +81,20 @@ SVGLength::SetValueFromString(const nsAS
   if (unit != str && NS_FloatIsFinite(tmpValue)) {
     char *theRest = unit;
     if (*unit != '\0' && !IsSVGWhitespace(*unit)) {
       while (*theRest != '\0' && !IsSVGWhitespace(*theRest)) {
         ++theRest;
       }
       nsCAutoString unitStr(unit, theRest - unit);
       tmpUnit = GetUnitTypeForString(unitStr.get());
+      if (tmpUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_UNKNOWN) {
+        // nsSVGUtils::ReportToConsole
+        return PR_FALSE;
+      }
     } else {
       tmpUnit = nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER;
     }
     while (*theRest && IsSVGWhitespace(*theRest)) {
       ++theRest;
     }
     if (!*theRest) {
       mValue = tmpValue;
@@ -267,13 +271,12 @@ GetUnitTypeForString(const char* unitStr
 
   nsCOMPtr<nsIAtom> unitAtom = do_GetAtom(unitStr);
 
   for (PRUint32 i = 1 ; i < NS_ARRAY_LENGTH(unitMap) ; i++) {
     if (unitMap[i] && *unitMap[i] == unitAtom) {
       return i;
     }
   }
-  NS_NOTREACHED("Returning unknown unit type");
   return nsIDOMSVGLength::SVG_LENGTHTYPE_UNKNOWN;
 }
 
 } // namespace mozilla
--- a/content/svg/content/test/Makefile.in
+++ b/content/svg/content/test/Makefile.in
@@ -63,16 +63,17 @@ include $(topsrcdir)/config/rules.mk
 		test_getSubStringLength.xhtml \
 		getSubStringLength-helper.svg \
 		test_isSupported.xhtml \
 		test_nonAnimStrings.xhtml \
 		test_pathSeg.xhtml \
 		test_pointer-events.xhtml \
 		test_scientific.html \
 		scientific-helper.svg \
+		test_SVGLengthList.xhtml \
 		test_SVGPathSegList.xhtml \
 		test_SVGStyleElement.xhtml \
 		test_SVGxxxList.xhtml \
 		test_switch.xhtml \
 		switch-helper.svg \
 		test_text.html \
 		text-helper.svg \
 		test_transform.xhtml \
new file mode 100644
--- /dev/null
+++ b/content/svg/content/test/test_SVGLengthList.xhtml
@@ -0,0 +1,55 @@
+<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="/MochiKit/packed.js"></script>
+  <script type="text/javascript" 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=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"/>
+</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');
+
+/*
+  is(lengths.numberOfItems, 2, 'Checking numberOfItems');
+  is(lengths.getItem(1).valueInSpecifiedUnits == 20, 'Checking the value of the second length');
+  is(lengths.getItem(1).unitType == SVGLength.SVG_LENGTHTYPE_CM, 'Checking the unit of the second length');
+*/
+
+  SimpleTest.finish();
+}
+
+window.addEventListener("load", run_tests, false);
+
+]]>
+</script>
+</pre>
+</body>
+</html>