Closed Bug 344888 Opened 18 years ago Closed 17 years ago

Bogus assertion: "ASSERTION: invalid length type"

Categories

(Core :: SVG, defect)

PowerPC
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jruderman, Assigned: jruderman)

References

Details

(Keywords: assertion, testcase)

Attachments

(2 files)

###!!! ASSERTION: invalid length type: 'Error', file /Users/admin/trunk/mozilla/content/svg/content/src/nsSVGLength2.cpp, line 228

Invalid documents shouldn't cause assertions.
Attached image testcase (deleted) —
Attachment #229425 - Flags: superreview?(tor)
Attachment #229425 - Flags: review?(tor)
Blocks: 344905
I think we should log something to the Error Console in such circumstances. We do that with other content errors. 

Since we haven't done this up to now in the svg subsystem, perhaps some kind of note in the code saying we should do this at these points would be sufficient to remind when we implement console logging.
I prefer bugs to source code "todo" comments.
You could add something like this in nsSVGElement::ParseAttribute to report the error to the console...

     // Check for nsSVGLength2 attribute
     LengthAttributesInfo lengthInfo = GetLengthInfo();
     PRUint32 i;
     for (i = 0; i < lengthInfo.mLengthCount; i++) {
       if (aAttribute == *lengthInfo.mLengthInfo[i].mName) {
         nsresult rv = lengthInfo.mLengths[i].SetBaseValueString(aValue, this,
                                                                 PR_FALSE);
         if (NS_FAILED(rv)) {
+          nsAutoString attributeName;
+          aAttribute->ToString(attributeName);
+          const nsAFlatString& attributeValue = PromiseFlatString(aValue);
+          const PRUnichar *strings[] = { attributeName.get(), attributeValue.ge
t() };
+          nsSVGUtils::ReportToConsole(GetOwnerDoc(),
+                                      "AttributeParseWarning",
+                                      strings, NS_ARRAY_LENGTH(strings));
           return PR_FALSE;
         }
         aResult.SetTo(aValue);
         return PR_TRUE;
       }
     }

     // Check for nsSVGNumber2 attribute

and the same for nsSVGNumber2.
I've checked in logging code for nsSVGLength2 and nsSVGNumber2 so we will get console logging now. 

As far my 2c is worth the asserts can just go.
Since we don't have logging for nsSVGAngle, it would be better to make the assertion a warning in that instance rather than remove it I think. I also think when an attempt is made to set an invalid value, that value should be give it's default. Please open a new bug if that doesn't get resolved here.
Attachment #229425 - Flags: superreview?(tor)
Attachment #229425 - Flags: superreview+
Attachment #229425 - Flags: review?(tor)
Attachment #229425 - Flags: review+
Assignee: general → jruderman
jwatt, I think you'll have to file the bug about resetting when someone tries to set a length to an invalid value.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Thanks. I've filed bug 378860.
Crashtest checked in.
Flags: in-testsuite+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: