diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-02 01:25:41 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-02 01:25:41 +0000 |
commit | 97df4b330f4a2b1a34adb1eb8e5f5e7f60d716ff (patch) | |
tree | 46cd48cb3b533fb88bb6e6975427e7741578cb5c /chrome/browser/browser_focus_uitest.cc | |
parent | 7a0f5a3abf37e21eb15f4fe4058e917426e2e105 (diff) | |
download | chromium_src-97df4b330f4a2b1a34adb1eb8e5f5e7f60d716ff.zip chromium_src-97df4b330f4a2b1a34adb1eb8e5f5e7f60d716ff.tar.gz chromium_src-97df4b330f4a2b1a34adb1eb8e5f5e7f60d716ff.tar.bz2 |
Don't send tab switching/killing/creating keyboard accelerators to pages. This avoids tabs maliciously preventing closing using ctrl+f4/ctrl+w/alt+f4, and also hung/slow renderers from making tab cycling sluggish.
BUG=5496
TEST=added ui test
Review URL: http://codereview.chromium.org/224023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27814 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_focus_uitest.cc')
-rw-r--r-- | chrome/browser/browser_focus_uitest.cc | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc index 89abf91..e5f014a 100644 --- a/chrome/browser/browser_focus_uitest.cc +++ b/chrome/browser/browser_focus_uitest.cc @@ -15,8 +15,13 @@ #include "chrome/browser/tab_contents/tab_contents_view.h" #include "chrome/browser/view_ids.h" #include "chrome/common/chrome_paths.h" +#include "chrome/test/automation/browser_proxy.h" +#include "chrome/test/automation/tab_proxy.h" +#include "chrome/test/automation/window_proxy.h" #include "chrome/test/in_process_browser_test.h" +#include "chrome/test/ui/ui_test.h" #include "chrome/test/ui_test_utils.h" +#include "views/event.h" #include "views/focus/focus_manager.h" #include "views/view.h" #include "views/window/window.h" @@ -737,3 +742,38 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReloadCrashedTab) { browser()->ShowDownloadsTab(); CheckViewHasFocus(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW); } + +#if !defined(OS_MACOSX) // see BrowserWindowCocoa::GetCommandId +// Tests that tab related keyboard accelerators are reserved by the app. + +class BrowserInteractiveTest : public UITest { +}; + +TEST_F(BrowserInteractiveTest, ReserveKeyboardAccelerators) { + const std::string kBadPage = + "<html><script>" + "document.onkeydown = function() {" + " event.preventDefault();" + " return false;" + "}" + "</script></html>"; + scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); + browser->AppendTab(GURL("data:text/html," + kBadPage)); + int tab_count = 0; + ASSERT_TRUE(browser->GetTabCount(&tab_count)); + ASSERT_EQ(tab_count, 2); + + int active_tab = 0; + ASSERT_TRUE(browser->GetActiveTabIndex(&active_tab)); + ASSERT_EQ(active_tab, 1); + + scoped_refptr<WindowProxy> window(browser->GetWindow()); + ASSERT_TRUE(window->SimulateOSKeyPress( + base::VKEY_TAB, views::Event::EF_CONTROL_DOWN)); + ASSERT_TRUE(browser->WaitForTabToBecomeActive(0, action_max_timeout_ms())); + + ASSERT_TRUE(window->SimulateOSKeyPress( + base::VKEY_F4, views::Event::EF_CONTROL_DOWN)); + ASSERT_TRUE(browser->WaitForTabCountToBecome(1, action_max_timeout_ms())); +} +#endif |