break; } case HTMLOPTIONELEMENT_TEXT: { PRBool ok = PR_FALSE; secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLOPTIONELEMENT_TEXT, PR_TRUE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_SECURITY_ERR); } nsAutoString prop; nsJSUtils::nsConvertJSValToString(prop, cx, *vp);  a->SetText(prop);
SetHTMLOptionElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp){  nsIDOMHTMLOptionElement *a = (nsIDOMHTMLOptionElement*)nsJSUtils::nsGetNativeThis(cx, obj);  // If there's no private data, this must be the prototype, so ignore  if (nsnull == a) {    return JS_TRUE;  }  if (JSVAL_IS_INT(id)) {    nsresult rv;    NS_WITH_SERVICE(nsIScriptSecurityManager, secMan,                    NS_SCRIPTSECURITYMANAGER_PROGID, &rv);    if (NS_FAILED(rv)) {      return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_SECMAN_ERR);    }    switch(JSVAL_TO_INT(id)) {      case HTMLOPTIONELEMENT_DEFAULTSELECTED:      {        PRBool ok = PR_FALSE;        secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLOPTIONELEMENT_DEFAULTSELECTED, PR_TRUE, &ok);        if (!ok) {          return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_SECURITY_ERR);        }        PRBool prop;        if (PR_FALSE == nsJSUtils::nsConvertJSValToBool(&prop, cx, *vp)) {          return nsJSUtils::nsReportError(cx, obj,  NS_ERROR_DOM_NOT_BOOLEAN_ERR);        }              a->SetDefaultSelected(prop);                break;      }      case HTMLOPTIONELEMENT_INDEX:      {        PRBool ok = PR_FALSE;        secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLOPTIONELEMENT_INDEX, PR_TRUE, &ok);        if (!ok) {          return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_SECURITY_ERR);        }        PRInt32 prop;        int32 temp;        if (JSVAL_IS_NUMBER(*vp) && JS_ValueToInt32(cx, *vp, &temp)) {          prop = (PRInt32)temp;        }        else {          return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_NUMBER_ERR);        }              a->SetIndex(prop);                break;      }      case HTMLOPTIONELEMENT_DISABLED:      {        PRBool ok = PR_FALSE;        secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLOPTIONELEMENT_DISABLED, PR_TRUE, &ok);        if (!ok) {          return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_SECURITY_ERR);        }        PRBool prop;        if (PR_FALSE == nsJSUtils::nsConvertJSValToBool(&prop, cx, *vp)) {          return nsJSUtils::nsReportError(cx, obj,  NS_ERROR_DOM_NOT_BOOLEAN_ERR);        }              a->SetDisabled(prop);                break;      }      case HTMLOPTIONELEMENT_LABEL:      {        PRBool ok = PR_FALSE;        secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLOPTIONELEMENT_LABEL, PR_TRUE, &ok);        if (!ok) {          return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_SECURITY_ERR);        }        nsAutoString prop;        nsJSUtils::nsConvertJSValToString(prop, cx, *vp);              a->SetLabel(prop);                break;      }      case HTMLOPTIONELEMENT_SELECTED:      {        PRBool ok = PR_FALSE;        secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLOPTIONELEMENT_SELECTED, PR_TRUE, &ok);        if (!ok) {          return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_SECURITY_ERR);        }        PRBool prop;        if (PR_FALSE == nsJSUtils::nsConvertJSValToBool(&prop, cx, *vp)) {          return nsJSUtils::nsReportError(cx, obj,  NS_ERROR_DOM_NOT_BOOLEAN_ERR);        }              a->SetSelected(prop);                break;      }      case HTMLOPTIONELEMENT_VALUE:      {        PRBool ok = PR_FALSE;        secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLOPTIONELEMENT_VALUE, PR_TRUE, &ok);        if (!ok) {          return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_SECURITY_ERR);        }        nsAutoString prop;        nsJSUtils::nsConvertJSValToString(prop, cx, *vp);              a->SetValue(prop);                break;      }      default:        return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, obj, id, vp);    }  }  else {    return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, obj, id, vp);  }  return PR_TRUE;}