Bug 1334572 - Dispatch WindowLowered/Raised events asynchronously in test mode (for marionette) (r=smaug)

MozReview-Commit-ID: Kwgl6sX4OoU
This commit is contained in:
Bill McCloskey 2017-01-30 15:42:02 -08:00
Родитель c8c4ea2401
Коммит ed66ab4b53
1 изменённых файлов: 12 добавлений и 4 удалений

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

@ -2204,10 +2204,18 @@ nsFocusManager::RaiseWindow(nsPIDOMWindowOuter* aWindow)
if (sTestMode) {
// In test mode, emulate the existing window being lowered and the new
// window being raised.
if (mActiveWindow)
WindowLowered(mActiveWindow);
WindowRaised(aWindow);
// window being raised. This happens in a separate runnable to avoid
// touching multiple windows in the current runnable.
nsCOMPtr<nsPIDOMWindowOuter> active(mActiveWindow);
nsCOMPtr<nsPIDOMWindowOuter> window(aWindow);
RefPtr<nsFocusManager> self(this);
NS_DispatchToCurrentThread(
NS_NewRunnableFunction([self, active, window] () -> void {
if (active) {
self->WindowLowered(active);
}
self->WindowRaised(window);
}));
return;
}