PRUnichar* str = NS_REINTERPRET_CAST(PRUnichar *, JS_GetStringChars(JS_ValueToString(aContext, aID)));
jschar* str = JS_GetStringChars(JS_ValueToString(aContext, aID));
nsHTMLFormElement::Resolve(JSContext *aContext, JSObject *aObj, jsval aID,                           PRBool *aDidDefineProperty){  if (!JSVAL_IS_STRING(aID)) {    return PR_TRUE;  }  PRBool ret;  JSObject* obj;  PRUnichar* str = NS_REINTERPRET_CAST(PRUnichar *, JS_GetStringChars(JS_ValueToString(aContext, aID)));  size_t str_len = JS_GetStringLength(JS_ValueToString(aContext, aID));  nsCOMPtr<nsIScriptContext> scriptContext;  nsresult rv = NS_OK;  rv = nsLayoutUtils::GetStaticScriptContext(aContext, aObj,                                             getter_AddRefs(scriptContext));  // If we can't get a script context, there's nothing we can do  if (!scriptContext || NS_FAILED(rv)) {    return PR_FALSE;  }  rv = mControls->GetNamedObject(aContext, aID, &obj);  if (NS_FAILED(rv)) {    return PR_FALSE;  }  if (!obj && mDocument) {    nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(mDocument));    if (htmlDoc) {      nsCOMPtr<nsIDOMNodeList> list;      rv = htmlDoc->GetElementsByName(nsLiteralString(str, str_len),                                      getter_AddRefs(list));      if (NS_FAILED(rv)) {        return PR_FALSE;      }      if (list) {        PRUint32 count;        list->GetLength(&count);        if (count > 0) {          nsCOMPtr<nsIDOMNode> node;          rv = list->Item(0, getter_AddRefs(node));          if (NS_FAILED(rv)) {            return PR_FALSE;          }          nsCOMPtr<nsIFormControl> formControl(do_QueryInterface(node));          // If htmlDoc->GetElementsByName() found a formcontrol we          // check to see if the formcontrol is part of this form, if          // it's not we don't define the property here...          if (formControl) {            nsCOMPtr<nsIDOMHTMLFormElement> formElement;            formControl->GetForm(getter_AddRefs(formElement));            if (formElement.get() != NS_STATIC_CAST(nsIDOMHTMLFormElement *,                                                    this)) {              // Set node to null so that we don't define the property              // here...              node = nsnull;            }          }          if (node) {            nsCOMPtr<nsIScriptObjectOwner> owner(do_QueryInterface(node));            rv = owner->GetScriptObject(scriptContext, (void**)&obj);            if (NS_FAILED(rv)) {              return PR_FALSE;            }          }        }      }    }  }  if (obj) {    JSObject* myObj;    rv = GetScriptObject(scriptContext, (void**)&myObj);    ret = ::JS_DefineUCProperty(aContext, myObj,                                str, str_len, OBJECT_TO_JSVAL(obj),                                nsnull, nsnull, 0);    *aDidDefineProperty = PR_TRUE;  }  else {    ret = nsGenericHTMLContainerElement::Resolve(aContext, aObj, aID,                                                 aDidDefineProperty);  }  return ret;}