From 835b49979f1335dc8c380264ccef341f21867765 Mon Sep 17 00:00:00 2001 From: "mrbkap@gmail.com" Date: Mon, 30 Jul 2007 14:47:03 -0700 Subject: [PATCH] Fix assertion and incorrect '!' that could cause us to create cross-origin wrappers in the wrong scope. bug 389796, r+sr=jst --- dom/src/base/nsDOMClassInfo.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/dom/src/base/nsDOMClassInfo.cpp b/dom/src/base/nsDOMClassInfo.cpp index 370ecfe5bd4a..97e87a5e1b8e 100644 --- a/dom/src/base/nsDOMClassInfo.cpp +++ b/dom/src/base/nsDOMClassInfo.cpp @@ -5979,16 +5979,7 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx, if (id == sWindow_id) { // window should *always* be the outer window object. - JSObject *scope; - 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(); - } + nsGlobalWindow *oldWin = win; win = win->GetOuterWindowInternal(); NS_ENSURE_TRUE(win, NS_ERROR_NOT_AVAILABLE); @@ -6001,6 +5992,17 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx, nsCOMPtr chrome = do_QueryInterface((nsIScriptGlobalObject *)win); 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, scope, JSVAL_TO_OBJECT(winVal),