Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Unified Diff: ash/shell_unittest.cc

Issue 15690015: Fix crash when JS alert from background page appears during lock screen (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments resolved Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ash/wm/stacking_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/shell_unittest.cc
diff --git a/ash/shell_unittest.cc b/ash/shell_unittest.cc
index 70ca5c2eeda785c1e4381d6c02840e25b3109903..be1d1cd3a8cd2599e106cd0cc62650bc744c7a2d 100644
--- a/ash/shell_unittest.cc
+++ b/ash/shell_unittest.cc
@@ -25,6 +25,7 @@
#include "ui/gfx/size.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
+#include "ui/views/window/dialog_delegate.h"
using aura::RootWindow;
@@ -207,6 +208,16 @@ TEST_F(ShellTest, CreateModalWindow) {
widget->Close();
}
+class TestModalDialogDelegate : public views::DialogDelegateView {
+ public:
+ TestModalDialogDelegate() {}
+
+ // Overridden from views::WidgetDelegate:
+ virtual ui::ModalType GetModalType() const OVERRIDE {
+ return ui::MODAL_TYPE_SYSTEM;
+ }
+};
+
TEST_F(ShellTest, CreateLockScreenModalWindow) {
views::Widget::InitParams widget_params(
views::Widget::InitParams::TYPE_WINDOW);
@@ -214,6 +225,7 @@ TEST_F(ShellTest, CreateLockScreenModalWindow) {
// Create a normal window.
views::Widget* widget = CreateTestWindow(widget_params);
widget->Show();
+ EXPECT_TRUE(widget->GetNativeView()->HasFocus());
// It should be in default container.
EXPECT_TRUE(GetDefaultContainer()->Contains(
@@ -227,6 +239,7 @@ TEST_F(ShellTest, CreateLockScreenModalWindow) {
ash::internal::kShellWindowId_LockScreenContainer)->
AddChild(lock_widget->GetNativeView());
lock_widget->Show();
+ EXPECT_TRUE(lock_widget->GetNativeView()->HasFocus());
// It should be in LockScreen container.
aura::Window* lock_screen = Shell::GetContainer(
@@ -238,6 +251,7 @@ TEST_F(ShellTest, CreateLockScreenModalWindow) {
views::Widget* lock_modal_widget = views::Widget::CreateWindowWithParent(
new ModalWindow(), lock_widget->GetNativeView());
lock_modal_widget->Show();
+ EXPECT_TRUE(lock_modal_widget->GetNativeView()->HasFocus());
// It should be in LockScreen modal container.
aura::Window* lock_modal_container = Shell::GetContainer(
@@ -250,6 +264,9 @@ TEST_F(ShellTest, CreateLockScreenModalWindow) {
views::Widget* modal_widget = views::Widget::CreateWindowWithParent(
new ModalWindow(), widget->GetNativeView());
modal_widget->Show();
+ // Window on lock screen shouldn't lost focus.
+ EXPECT_FALSE(modal_widget->GetNativeView()->HasFocus());
+ EXPECT_TRUE(lock_modal_widget->GetNativeView()->HasFocus());
// It should be in non-LockScreen modal container.
aura::Window* modal_container = Shell::GetContainer(
@@ -257,6 +274,16 @@ TEST_F(ShellTest, CreateLockScreenModalWindow) {
ash::internal::kShellWindowId_SystemModalContainer);
EXPECT_EQ(modal_container, modal_widget->GetNativeWindow()->parent());
+ // Modal dialog without parent, caused crash see crbug.com/226141
+ views::Widget* modal_dialog = views::DialogDelegate::CreateDialogWidget(
+ new TestModalDialogDelegate(), CurrentContext(), NULL);
+
+ modal_dialog->Show();
+ EXPECT_FALSE(modal_dialog->GetNativeView()->HasFocus());
+ EXPECT_TRUE(lock_modal_widget->GetNativeView()->HasFocus());
+
+ modal_dialog->Close();
+ modal_widget->Close();
modal_widget->Close();
lock_modal_widget->Close();
lock_widget->Close();
« no previous file with comments | « no previous file | ash/wm/stacking_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698