Fix assertion and incorrect '!' that could cause us to create cross-origin wrappers in the wrong scope. bug 389796, r+sr=jst

This commit is contained in:
mrbkap%gmail.com 2007-07-30 21:47:03 +00:00
Родитель 1210be855f
Коммит 79e4f1479d
1 изменённых файлов: 12 добавлений и 10 удалений

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

@ -5979,16 +5979,7 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
if (id == sWindow_id) { if (id == sWindow_id) {
// window should *always* be the outer window object. // window should *always* be the outer window object.
JSObject *scope; nsGlobalWindow *oldWin = win;
nsGlobalWindow *innerWin;
if (win->IsInnerWindow()) {
scope = win->GetGlobalJSObject();
} else if (!(innerWin = win->GetCurrentInnerWindowInternal())) {
scope = innerWin->GetGlobalJSObject();
} else {
NS_ERROR("I don't know what scope to use!");
scope = win->GetGlobalJSObject();
}
win = win->GetOuterWindowInternal(); win = win->GetOuterWindowInternal();
NS_ENSURE_TRUE(win, NS_ERROR_NOT_AVAILABLE); NS_ENSURE_TRUE(win, NS_ERROR_NOT_AVAILABLE);
@ -6001,6 +5992,17 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
nsCOMPtr<nsIDOMChromeWindow> chrome = nsCOMPtr<nsIDOMChromeWindow> chrome =
do_QueryInterface((nsIScriptGlobalObject *)win); do_QueryInterface((nsIScriptGlobalObject *)win);
if (!chrome) { if (!chrome) {
JSObject *scope;
nsGlobalWindow *innerWin;
if (oldWin->IsInnerWindow()) {
scope = oldWin->GetGlobalJSObject();
} else if ((innerWin = oldWin->GetCurrentInnerWindowInternal())) {
scope = innerWin->GetGlobalJSObject();
} else {
NS_ERROR("I don't know what scope to use!");
scope = oldWin->GetGlobalJSObject();
}
rv = sXPConnect->GetCrossOriginWrapperForObject(cx, rv = sXPConnect->GetCrossOriginWrapperForObject(cx,
scope, scope,
JSVAL_TO_OBJECT(winVal), JSVAL_TO_OBJECT(winVal),