Fixing nsbeta3+ 38215. Making with(window.location) { href=someurl; } work by dynamically defining the 'href' property in LocationImpl::Resolve() (since src is defined as [noscript] in the IDL). r/a=vidur, r/a=brendan

This commit is contained in:
jst%netscape.com 2000-09-21 03:43:10 +00:00
parent 210fd6e3c6
commit 2f0eed6fbb

View File

@ -849,6 +849,23 @@ LocationImpl::EnumerateProperty(JSContext *aContext, JSObject *aObj)
PRBool
LocationImpl::Resolve(JSContext *aContext, JSObject *aObj, jsval aID)
{
if (JSVAL_IS_STRING(aID)) {
JSString *str;
str = JSVAL_TO_STRING(aID);
const jschar *chars = ::JS_GetStringChars(str);
const PRUnichar *unichars = NS_REINTERPRET_CAST(const PRUnichar*, chars);
if (!nsCRT::strcmp(unichars, NS_LITERAL_STRING("href").get())) {
// properties defined as 'noscript' in the IDL needs to be defined
// lazily here so that unqualified lookups of such properties work
::JS_DefineUCProperty(aContext, (JSObject *)mScriptObject,
chars, ::JS_GetStringLength(str),
JSVAL_VOID, nsnull, nsnull, 0);
}
}
return JS_TRUE;
}