From 5924a0b4c58a2f889752a6c76256895a62b31eb0 Mon Sep 17 00:00:00 2001 From: "sky@chromium.org" Date: Fri, 27 Apr 2012 17:02:28 +0000 Subject: Cleans up a couple of places that were installing WindowObservers but never removing them. This is problematic as it is possible for a Window to be destroyed after the shell. ScopedObserver is pretty generic, but I'll leave it here for now. BUG=124860 TEST=covered by unit test R=ben@chromium.org Review URL: https://chromiumcodereview.appspot.com/10206027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134287 0039d316-1c4b-4281-b951-d872f2087c98 --- ash/shell_unittest.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'ash/shell_unittest.cc') diff --git a/ash/shell_unittest.cc b/ash/shell_unittest.cc index d4dd7ea..88e8fd9 100644 --- a/ash/shell_unittest.cc +++ b/ash/shell_unittest.cc @@ -317,4 +317,28 @@ TEST_F(ShellTest, FullscreenWindowHidesShelf) { widget->Close(); } +// This verifies WindowObservers are removed when a window is destroyed after +// the Shell is destroyed. This scenario (aura::Windows being deleted after the +// Shell) occurs if someone is holding a reference to an unparented Window, as +// is the case with a RenderWidgetHostViewAura that isn't on screen. As long as +// everything is ok, we won't crash. If there is a bug, window's destructor will +// notify some deleted object (say VideoDetector or ActivationController) and +// this will crash. +class ShellTest2 : public test::AshTestBase { + public: + ShellTest2() {} + virtual ~ShellTest2() {} + + protected: + scoped_ptr window_; + + private: + DISALLOW_COPY_AND_ASSIGN(ShellTest2); +}; + +TEST_F(ShellTest2, DontCrashWhenWindowDeleted) { + window_.reset(new aura::Window(NULL)); + window_->Init(ui::LAYER_NOT_DRAWN); +} + } // namespace ash -- cgit v1.1