зеркало из https://github.com/mozilla/pjs.git
Bug 665548 - r=jst
This commit is contained in:
Родитель
34753b1a17
Коммит
670c5f4902
|
@ -6816,6 +6816,57 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
if (id == sLocation_id) {
|
||||
// This must be done even if we're just getting the value of
|
||||
// window.location (i.e. no checking flags & JSRESOLVE_ASSIGNING
|
||||
// here) since we must define window.location to prevent the
|
||||
// getter from being overriden (for security reasons).
|
||||
|
||||
// Note: Because we explicitly don't forward to the inner window
|
||||
// above, we have to ensure here that our window has a current
|
||||
// inner window so that the location object we return will work.
|
||||
|
||||
if (win->IsOuterWindow()) {
|
||||
win->EnsureInnerWindow();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMLocation> location;
|
||||
rv = win->GetLocation(getter_AddRefs(location));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Make sure we wrap the location object in the inner window's
|
||||
// scope if we've got an inner window.
|
||||
JSObject *scope = nsnull;
|
||||
if (win->IsOuterWindow()) {
|
||||
nsGlobalWindow *innerWin = win->GetCurrentInnerWindowInternal();
|
||||
|
||||
if (innerWin) {
|
||||
scope = innerWin->GetGlobalJSObject();
|
||||
}
|
||||
}
|
||||
|
||||
if (!scope) {
|
||||
wrapper->GetJSObject(&scope);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||
jsval v;
|
||||
rv = WrapNative(cx, scope, location, &NS_GET_IID(nsIDOMLocation), PR_TRUE,
|
||||
&v, getter_AddRefs(holder));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JSBool ok = JS_WrapValue(cx, &v) &&
|
||||
JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull,
|
||||
JSPROP_PERMANENT | JSPROP_ENUMERATE);
|
||||
|
||||
if (!ok) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*objp = obj;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Hmm, we do an awful lot of QIs here; maybe we should add a
|
||||
// method on an interface that would let us just call into the
|
||||
|
@ -6923,58 +6974,6 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
if (id == sLocation_id) {
|
||||
// This must be done even if we're just getting the value of
|
||||
// window.location (i.e. no checking flags & JSRESOLVE_ASSIGNING
|
||||
// here) since we must define window.location to prevent the
|
||||
// getter from being overriden (for security reasons).
|
||||
|
||||
// Note: Because we explicitly don't forward to the inner window
|
||||
// above, we have to ensure here that our window has a current
|
||||
// inner window so that the location object we return will work.
|
||||
|
||||
if (win->IsOuterWindow()) {
|
||||
win->EnsureInnerWindow();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMLocation> location;
|
||||
rv = win->GetLocation(getter_AddRefs(location));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Make sure we wrap the location object in the inner window's
|
||||
// scope if we've got an inner window.
|
||||
JSObject *scope = nsnull;
|
||||
if (win->IsOuterWindow()) {
|
||||
nsGlobalWindow *innerWin = win->GetCurrentInnerWindowInternal();
|
||||
|
||||
if (innerWin) {
|
||||
scope = innerWin->GetGlobalJSObject();
|
||||
}
|
||||
}
|
||||
|
||||
if (!scope) {
|
||||
wrapper->GetJSObject(&scope);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||
jsval v;
|
||||
rv = WrapNative(cx, scope, location, &NS_GET_IID(nsIDOMLocation), PR_TRUE,
|
||||
&v, getter_AddRefs(holder));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JSBool ok = JS_WrapValue(cx, &v) &&
|
||||
JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull,
|
||||
JSPROP_PERMANENT | JSPROP_ENUMERATE);
|
||||
|
||||
if (!ok) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*objp = obj;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (id == sOnhashchange_id) {
|
||||
// Special handling so |"onhashchange" in window| returns true
|
||||
if (!JS_DefinePropertyById(cx, obj, id, JSVAL_VOID,
|
||||
|
|
Загрузка…
Ссылка в новой задаче