Bug 679689. Allow empty string values to be associtated to enumerated attributes. r=sicking
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 31 Aug 2011 18:09:58 -0400
changeset 76353 b449db7a038b98f51792264b4e906be36f4d6e4f
parent 76352 ef216b965a04d5f16d121961972a780ceec36216
child 76354 89b87e96dc176cfc144d26e3140c52146e328feb
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewerssicking
bugs679689
milestone9.0a1
Bug 679689. Allow empty string values to be associtated to enumerated attributes. r=sicking
content/base/crashtests/679689-1.html
content/base/crashtests/crashtests.list
content/base/src/nsAttrValue.cpp
new file mode 100644
--- /dev/null
+++ b/content/base/crashtests/679689-1.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<img crossorigin>
--- a/content/base/crashtests/crashtests.list
+++ b/content/base/crashtests/crashtests.list
@@ -88,8 +88,9 @@ load 610571-1.html
 load 604262-1.html
 load 628599-1.html
 load 637214-1.svg
 load 637214-2.svg
 load 642022-1.html
 load 646184.html
 load 658845-1.svg
 load 667336-1.html
+load 679689-1.html
--- a/content/base/src/nsAttrValue.cpp
+++ b/content/base/src/nsAttrValue.cpp
@@ -1245,20 +1245,24 @@ nsAttrValue::ParseIntMarginValue(const n
 void
 nsAttrValue::SetMiscAtomOrString(const nsAString* aValue)
 {
   NS_ASSERTION(GetMiscContainer(), "Must have MiscContainer!");
   NS_ASSERTION(!GetMiscContainer()->mStringBits,
                "Trying to re-set atom or string!");
   if (aValue) {
     PRUint32 len = aValue->Length();
-    // We're allowing eCSSStyleRule attributes to store empty strings as it
-    // can be beneficial to store an empty style attribute as a parsed rule.
+    // * We're allowing eCSSStyleRule attributes to store empty strings as it
+    //   can be beneficial to store an empty style attribute as a parsed rule.
+    // * We're allowing enumerated values because sometimes the empty
+    //   string corresponds to a particular enumerated value, especially
+    //   for enumerated values that are not limited enumerated.
     // Add other types as needed.
-    NS_ASSERTION(len || Type() == eCSSStyleRule, "Empty string?");
+    NS_ASSERTION(len || Type() == eCSSStyleRule || Type() == eEnum,
+                 "Empty string?");
     MiscContainer* cont = GetMiscContainer();
     if (len <= NS_ATTRVALUE_MAX_STRINGLENGTH_ATOM) {
       nsIAtom* atom = NS_NewAtom(*aValue);
       if (atom) {
         cont->mStringBits = reinterpret_cast<PtrBits>(atom) | eAtomBase;
       }
     } else {
       nsStringBuffer* buf = GetStringBuffer(*aValue);