Commit 23f833fd authored by bryner%brianryner.com's avatar bryner%brianryner.com
Browse files

Generate 'true' and 'false' for boolean values, rather than '1' and '0' (bug 329304). r=marria,

parent ad2b3aee
Loading
Loading
Loading
Loading
+20 −4
Original line number Diff line number Diff line
@@ -125,12 +125,28 @@ nsMetricsService::LogEvent(const nsAString &eventNS,
      continue;
    }

    // If the type is boolean, we want to use the strings "true" and "false",
    // rather than "1" and "0" which is what nsVariant generates on its own.
    PRUint16 dataType;
    value->GetDataType(&dataType);

    nsAutoString valueString;
    if (dataType == nsIDataType::VTYPE_BOOL) {
      PRBool valueBool;
      rv = value->GetAsBool(&valueBool);
      if (NS_FAILED(rv)) {
        NS_WARNING("Variant has bool type but couldn't get bool value");
        continue;
      }
      valueString = valueBool ? NS_LITERAL_STRING("true")
        : NS_LITERAL_STRING("false");
    } else {
      rv = value->GetAsDOMString(valueString);
      if (NS_FAILED(rv)) {
        NS_WARNING("Failed to convert property value to string");
        continue;
      }
    }

    rv = eventElement->SetAttribute(name, valueString);
    if (NS_FAILED(rv)) {