summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-02 01:47:00 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-02 01:47:00 +0000
commit468a82d9381d6787d603b42b6427a65b35694b90 (patch)
tree379e43aee6055c7a5b491d986a733cd95ffd5f2e /chrome/test
parent7548cebee69f8c560e0e3e14e220f237e3112a55 (diff)
downloadchromium_src-468a82d9381d6787d603b42b6427a65b35694b90.zip
chromium_src-468a82d9381d6787d603b42b6427a65b35694b90.tar.gz
chromium_src-468a82d9381d6787d603b42b6427a65b35694b90.tar.bz2
Adding new files for http://codereview.chromium.org/245036/show
The trybots are failing that patch, so I am going to try checking in these changes separately, then try the rest of the patch. TBR=nsylvain Review URL: http://codereview.chromium.org/249064 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27820 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/data/fast_shutdown/on_before_unloader.html1
-rw-r--r--chrome/test/data/fast_shutdown/on_unloader.html9
-rw-r--r--chrome/test/ui/fast_shutdown_uitest.cc46
3 files changed, 56 insertions, 0 deletions
diff --git a/chrome/test/data/fast_shutdown/on_before_unloader.html b/chrome/test/data/fast_shutdown/on_before_unloader.html
new file mode 100644
index 0000000..fe6580d
--- /dev/null
+++ b/chrome/test/data/fast_shutdown/on_before_unloader.html
@@ -0,0 +1 @@
+<BODY onBeforeUnload="var x = 5">
diff --git a/chrome/test/data/fast_shutdown/on_unloader.html b/chrome/test/data/fast_shutdown/on_unloader.html
new file mode 100644
index 0000000..7e7d19b
--- /dev/null
+++ b/chrome/test/data/fast_shutdown/on_unloader.html
@@ -0,0 +1,9 @@
+<BODY onUnload="alert('bye now!')" onClick="doPopup()">
+
+<script>
+
+function doPopup() {
+ popup = window.open('on_before_unloader.html')
+}
+
+</script>
diff --git a/chrome/test/ui/fast_shutdown_uitest.cc b/chrome/test/ui/fast_shutdown_uitest.cc
new file mode 100644
index 0000000..286f6d2
--- /dev/null
+++ b/chrome/test/ui/fast_shutdown_uitest.cc
@@ -0,0 +1,46 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "app/message_box_flags.h"
+#include "base/gfx/rect.h"
+#include "chrome/app/chrome_dll_resource.h"
+#include "chrome/browser/view_ids.h"
+#include "chrome/test/ui/ui_test.h"
+#include "chrome/test/automation/automation_proxy.h"
+#include "chrome/test/automation/browser_proxy.h"
+#include "chrome/test/automation/tab_proxy.h"
+#include "chrome/test/automation/window_proxy.h"
+#include "views/event.h"
+
+class FastShutdown : public UITest {
+};
+
+// This tests for a previous error where uninstalling an onbeforeunload
+// handler would enable fast shutdown even if an onUnload handler still
+// existed.
+TEST_F(FastShutdown, SlowTermination) {
+ scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser.get());
+ scoped_refptr<WindowProxy> window(browser->GetWindow());
+ ASSERT_TRUE(window.get());
+
+ // This page has an unload handler.
+ GURL url = GetTestUrl(L"fast_shutdown", L"on_unloader.html");
+ NavigateToURLBlockUntilNavigationsComplete(url, 1);
+ gfx::Rect bounds;
+ ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_CONTAINER, &bounds, true));
+ // This click will launch a popup which has a before unload handler.
+ ASSERT_TRUE(window->SimulateOSClick(bounds.CenterPoint(),
+ views::Event::EF_LEFT_BUTTON_DOWN));
+ ASSERT_TRUE(browser->WaitForTabCountToBecome(2, action_timeout_ms()));
+ // Close the tab, removing the one and only before unload handler.
+ scoped_refptr<TabProxy> tab(browser->GetTab(1));
+ ASSERT_TRUE(tab->Close(true));
+
+ // Close the browser. We should launch the unload handler, which is an
+ // alert().
+ ASSERT_TRUE(browser->ApplyAccelerator(IDC_CLOSE_WINDOW));
+ ASSERT_TRUE(automation()->WaitForAppModalDialog(action_timeout_ms()));
+ automation()->ClickAppModalDialogButton(MessageBoxFlags::DIALOGBUTTON_OK);
+}