Commit 1dd32d99 authored by Toni Barzic's avatar Toni Barzic Committed by Commit Bot

Hide overview focus widget on overview session exit

When shutting down overview session, make sure the
OverviewModeFocusedWidget is hidden (and deactivated), to prevent it
from handling key pressed events (when the overview session is active,
key press events are handled by OverviewSession before they get
dispatched to the active window).
Without this, the OverviewModeFocusedWidget might end up handling tab
key event, and cause a crash when the focus manager attempts to find the
next focusable view within an childless widget.

BUG=1033972

Change-Id: I0b817cb5784b6ffd79d5a4b011a233cd410863c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2036258Reviewed-by: default avatarSammie Quon <sammiequon@chromium.org>
Commit-Queue: Toni Baržić <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738031}
parent 2b239559
......@@ -257,6 +257,12 @@ void OverviewSession::Shutdown() {
grid_list_.clear();
// Hide the focus widget on overview session end to prevent it from retaining
// focus and handling key press events now that overview session is not
// consuming them.
if (overview_focus_widget_)
overview_focus_widget_->Hide();
if (no_windows_widget_) {
if (enter_exit_overview_type_ == EnterExitOverviewType::kImmediateExit) {
ImmediatelyCloseWidgetOnExit(std::move(no_windows_widget_));
......
......@@ -1308,6 +1308,48 @@ TEST_P(OverviewSessionTest, RemoveDisplayWithAnimation) {
EXPECT_FALSE(InOverviewSession());
}
// Tests that tab key does not cause crash if pressed just after overview
// session exits.
TEST_P(OverviewSessionTest, NoCrashOnTabAfterExit) {
std::unique_ptr<aura::Window> window = CreateTestWindow();
wm::ActivateWindow(window.get());
ToggleOverview();
EXPECT_TRUE(InOverviewSession());
ToggleOverview();
SendKey(ui::VKEY_TAB);
EXPECT_FALSE(InOverviewSession());
}
// Tests that tab key does not cause crash if pressed just after overview
// session exits, and a child window was active before session start.
TEST_P(OverviewSessionTest,
NoCrashOnTabAfterExitWithChildWindowInitiallyFocused) {
std::unique_ptr<aura::Window> window = CreateTestWindow();
std::unique_ptr<aura::Window> child_window = CreateChildWindow(window.get());
wm::ActivateWindow(child_window.get());
ToggleOverview();
EXPECT_TRUE(InOverviewSession());
ToggleOverview();
SendKey(ui::VKEY_TAB);
EXPECT_FALSE(InOverviewSession());
}
// Tests that tab key does not cause crash if pressed just after overview
// session exits when no windows existed before starting overview session.
TEST_P(OverviewSessionTest, NoCrashOnTabAfterExitWithNoWindows) {
ToggleOverview();
EXPECT_TRUE(InOverviewSession());
ToggleOverview();
SendKey(ui::VKEY_TAB);
EXPECT_FALSE(InOverviewSession());
}
// Tests that dragging a window from the top of a display creates a drop target
// on that display. The workflow will be real after the tablet disambiguation
// work. Until then, this test can safely be disabled.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment