Fixing nsbeta3+ bug 45389. Adding support for window.location.assign('xxx');. r=nisheeth@netscape.com
git-svn-id: svn://10.0.0.236/trunk@78503 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -65,6 +65,8 @@ public:
|
||||
|
||||
NS_IMETHOD Replace(const nsAReadableString& aUrl)=0;
|
||||
|
||||
NS_IMETHOD Assign(const nsAReadableString& aUrl)=0;
|
||||
|
||||
NS_IMETHOD ToString(nsAWritableString& aReturn)=0;
|
||||
};
|
||||
|
||||
@@ -88,6 +90,7 @@ public:
|
||||
NS_IMETHOD SetSearch(const nsAReadableString& aSearch); \
|
||||
NS_IMETHOD Reload(PRBool aForceget); \
|
||||
NS_IMETHOD Replace(const nsAReadableString& aUrl); \
|
||||
NS_IMETHOD Assign(const nsAReadableString& aUrl); \
|
||||
NS_IMETHOD ToString(nsAWritableString& aReturn); \
|
||||
|
||||
|
||||
@@ -111,6 +114,7 @@ public:
|
||||
NS_IMETHOD SetSearch(const nsAReadableString& aSearch) { return _to SetSearch(aSearch); } \
|
||||
NS_IMETHOD Reload(PRBool aForceget) { return _to Reload(aForceget); } \
|
||||
NS_IMETHOD Replace(const nsAReadableString& aUrl) { return _to Replace(aUrl); } \
|
||||
NS_IMETHOD Assign(const nsAReadableString& aUrl) { return _to Assign(aUrl); } \
|
||||
NS_IMETHOD ToString(nsAWritableString& aReturn) { return _to ToString(aReturn); } \
|
||||
|
||||
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
interface Location {
|
||||
interface Location {
|
||||
/* IID: { 0xa6cf906d, 0x15b3, 0x11d2, \
|
||||
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } } */
|
||||
|
||||
attribute wstring hash;
|
||||
attribute wstring hash;
|
||||
attribute wstring host;
|
||||
attribute wstring hostname;
|
||||
attribute wstring hostname;
|
||||
noscript attribute wstring href;
|
||||
attribute wstring pathname;
|
||||
attribute wstring port;
|
||||
attribute wstring protocol;
|
||||
attribute wstring search;
|
||||
|
||||
noscript void reload(in boolean forceget);
|
||||
noscript void reload(in boolean forceget);
|
||||
noscript void replace(in wstring url);
|
||||
void assign(in wstring url);
|
||||
|
||||
wstring toString();
|
||||
};
|
||||
wstring toString();
|
||||
};
|
||||
|
||||
interface NSLocation {
|
||||
interface NSLocation {
|
||||
/* IID: { 0xa6cf9108, 0x15b3, 0x11d2, \
|
||||
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } } */
|
||||
void reload(/* ... */);
|
||||
void replace(/* ... */);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -677,6 +677,7 @@ enum nsDOMProp {
|
||||
NS_DOM_PROP_KEYEVENT_METAKEY,
|
||||
NS_DOM_PROP_KEYEVENT_SHIFTKEY,
|
||||
NS_DOM_PROP_LINKSTYLE_SHEET,
|
||||
NS_DOM_PROP_LOCATION_ASSIGN,
|
||||
NS_DOM_PROP_LOCATION_HASH,
|
||||
NS_DOM_PROP_LOCATION_HOST,
|
||||
NS_DOM_PROP_LOCATION_HOSTNAME,
|
||||
|
||||
@@ -675,6 +675,7 @@
|
||||
"keyevent.metakey", \
|
||||
"keyevent.shiftkey", \
|
||||
"linkstyle.sheet", \
|
||||
"location.assign", \
|
||||
"location.hash", \
|
||||
"location.host", \
|
||||
"location.hostname", \
|
||||
|
||||
@@ -348,6 +348,7 @@ public:
|
||||
NS_IMETHOD SetSearch(const nsAReadableString& aSearch);
|
||||
NS_IMETHOD Reload(PRBool aForceget);
|
||||
NS_IMETHOD Replace(const nsAReadableString& aUrl);
|
||||
NS_IMETHOD Assign(const nsAReadableString& aUrl);
|
||||
NS_IMETHOD ToString(nsAWritableString& aReturn);
|
||||
|
||||
// nsIDOMNSLocation
|
||||
|
||||
@@ -322,6 +322,47 @@ ResolveLocation(JSContext *cx, JSObject *obj, jsval id)
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method Assign
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
LocationAssign(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMLocation *nativeThis = (nsIDOMLocation*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsresult result = NS_OK;
|
||||
nsAutoString b0;
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
*rval = JSVAL_NULL;
|
||||
nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj);
|
||||
if (!secMan)
|
||||
return PR_FALSE;
|
||||
result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_LOCATION_ASSIGN, PR_FALSE);
|
||||
if (NS_FAILED(result)) {
|
||||
return nsJSUtils::nsReportError(cx, obj, result);
|
||||
}
|
||||
if (argc < 1) {
|
||||
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR);
|
||||
}
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
|
||||
result = nativeThis->Assign(b0);
|
||||
if (NS_FAILED(result)) {
|
||||
return nsJSUtils::nsReportError(cx, obj, result);
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method ToString
|
||||
//
|
||||
@@ -479,6 +520,7 @@ static JSPropertySpec LocationProperties[] =
|
||||
//
|
||||
static JSFunctionSpec LocationMethods[] =
|
||||
{
|
||||
{"assign", LocationAssign, 1},
|
||||
{"toString", LocationToString, 0},
|
||||
{"reload", NSLocationReload, 0},
|
||||
{"replace", NSLocationReplace, 0},
|
||||
|
||||
@@ -639,6 +639,24 @@ LocationImpl::Replace(const nsAReadableString& aUrl)
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LocationImpl::Assign(const nsAReadableString& aUrl)
|
||||
{
|
||||
nsAutoString oldHref;
|
||||
nsCOMPtr<nsIURI> oldUrl;
|
||||
nsresult result = NS_OK;
|
||||
|
||||
result = GetHref(oldHref);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = NS_NewURI(getter_AddRefs(oldUrl), oldHref);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = SetHrefWithBase(aUrl, oldUrl, PR_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LocationImpl::Reload(JSContext *cx, jsval *argv, PRUint32 argc)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user