Fix for bug 50682. Regression introduced that prevented window.title from being changed. r=jst

This commit is contained in:
vidur%netscape.com 2000-08-30 18:38:30 +00:00
Родитель c387ac81a1
Коммит 17a5487872
2 изменённых файлов: 26 добавлений и 62 удалений

Просмотреть файл

@ -31,7 +31,7 @@ interface Window {
attribute wstring defaultStatus;
attribute wstring name;
attribute jsval location;
replaceable attribute DOMString title;
attribute DOMString title;
attribute long innerWidth;
attribute long innerHeight;
attribute long outerWidth;

Просмотреть файл

@ -414,6 +414,18 @@ GetWindowProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
}
break;
}
case WINDOW_TITLE:
{
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_WINDOW_TITLE, PR_FALSE);
if (NS_SUCCEEDED(rv)) {
nsAutoString prop;
rv = a->GetTitle(prop);
if (NS_SUCCEEDED(rv)) {
nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);
}
}
break;
}
case WINDOW_INNERWIDTH:
{
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_WINDOW_INNERWIDTH, PR_FALSE);
@ -1039,6 +1051,18 @@ SetWindowProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
}
break;
}
case WINDOW_TITLE:
{
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_WINDOW_TITLE, PR_TRUE);
if (NS_SUCCEEDED(rv)) {
nsAutoString prop;
nsJSUtils::nsConvertJSValToString(prop, cx, *vp);
rv = a->SetTitle(prop);
}
break;
}
case WINDOW_INNERWIDTH:
{
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_WINDOW_INNERWIDTH, PR_TRUE);
@ -2247,66 +2271,6 @@ WindowcontrollersSetter(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
return PR_TRUE;
}
/***********************************************************************/
//
// title Property Getter
//
PR_STATIC_CALLBACK(JSBool)
WindowtitleGetter(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMWindow *a = (nsIDOMWindow*)nsJSUtils::nsGetNativeThis(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
nsresult rv;
nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj);
if (!secMan)
return PR_FALSE;
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_WINDOW_TITLE, PR_FALSE);
if (NS_FAILED(rv)) {
return nsJSUtils::nsReportError(cx, obj, rv);
}
nsAutoString prop;
rv = a->GetTitle(prop);
if (NS_SUCCEEDED(rv)) {
nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);
}
return PR_TRUE;
}
/***********************************************************************/
//
// title Property Setter
//
PR_STATIC_CALLBACK(JSBool)
WindowtitleSetter(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMWindow *a = (nsIDOMWindow*)nsJSUtils::nsGetNativeThis(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
nsresult rv;
nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj);
if (!secMan)
return PR_FALSE;
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_WINDOW_TITLE, PR_TRUE);
if (NS_FAILED(rv)) {
return nsJSUtils::nsReportError(cx, obj, rv);
}
JS_DefineProperty(cx, obj, "title", *vp, nsnull, nsnull, JSPROP_ENUMERATE);
return PR_TRUE;
}
//
// Window finalizer
@ -4074,7 +4038,7 @@ static JSPropertySpec WindowProperties[] =
{"defaultStatus", WINDOW_DEFAULTSTATUS, JSPROP_ENUMERATE},
{"name", WINDOW_NAME, JSPROP_ENUMERATE},
{"location", WINDOW_LOCATION, JSPROP_ENUMERATE},
{"title", WINDOW_TITLE, JSPROP_ENUMERATE, WindowtitleGetter, WindowtitleSetter},
{"title", WINDOW_TITLE, JSPROP_ENUMERATE},
{"innerWidth", WINDOW_INNERWIDTH, JSPROP_ENUMERATE},
{"innerHeight", WINDOW_INNERHEIGHT, JSPROP_ENUMERATE},
{"outerWidth", WINDOW_OUTERWIDTH, JSPROP_ENUMERATE},