bug 580128 - Fix code that expects XPConnect to hand outer windows to C++ from JS. r=peterv

This commit is contained in:
Blake Kaplan 2010-09-17 14:54:40 -07:00
Родитель e106d8ade7
Коммит 10ebae6d32
4 изменённых файлов: 9 добавлений и 17 удалений

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

@ -6970,15 +6970,9 @@ nsWindowSH::Equality(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
nsGlobalWindow *win = nsGlobalWindow::FromWrapper(wrapper);
NS_ASSERTION(win->IsOuterWindow(),
"Inner window detected in Equality hook!");
nsCOMPtr<nsPIDOMWindow> other = do_QueryWrappedNative(other_wrapper);
if (other) {
NS_ASSERTION(other->IsOuterWindow(),
"Inner window detected in Equality hook!");
*bp = win->GetOuterWindow() == other->GetOuterWindow();
}

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

@ -328,7 +328,8 @@ nsFocusManager::SetActiveWindow(nsIDOMWindow* aWindow)
{
// only top-level windows can be made active
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(aWindow);
NS_ASSERTION(!piWindow || piWindow->IsOuterWindow(), "outer window expected");
if (piWindow)
piWindow = piWindow->GetOuterWindow();
NS_ENSURE_TRUE(piWindow && (piWindow == piWindow->GetPrivateRoot()),
NS_ERROR_INVALID_ARG);

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

@ -5717,15 +5717,7 @@ PostMessageEvent::Run()
NS_IMETHODIMP
nsGlobalWindow::PostMessageMoz(const nsAString& aMessage, const nsAString& aOrigin)
{
// NB: Since much of what this method does must happen at event dispatch time,
// this method does not forward to the inner window, unlike most other
// methods. We do this because the only time we need to refer to this
// window, we need a reference to the outer window (the PostMessageEvent
// ctor call), and we don't want to pay the price of forwarding to the
// inner window for no actual benefit. Furthermore, this function must
// only be called from script anyway, which should only have references to
// outer windows (and if script has an inner window we've already lost).
NS_ABORT_IF_FALSE(IsOuterWindow(), "only call this method on outer windows");
FORWARD_TO_OUTER(PostMessageMoz, (aMessage, aOrigin), NS_ERROR_NOT_INITIALIZED);
//
// Window.postMessage is an intentional subversion of the same-origin policy.

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

@ -223,8 +223,13 @@ nsSecureBrowserUIImpl::Init(nsIDOMWindow *aWindow)
return NS_ERROR_ALREADY_INITIALIZED;
}
nsCOMPtr<nsPIDOMWindow> pwin(do_QueryInterface(aWindow));
if (pwin->IsInnerWindow()) {
pwin = pwin->GetOuterWindow();
}
nsresult rv;
mWindow = do_GetWeakReference(aWindow, &rv);
mWindow = do_GetWeakReference(pwin, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIStringBundleService> service(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));