OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string> | 5 #include <string> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/location.h" |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/message_loop/message_loop.h" |
12 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
13 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
14 #include "base/sys_info.h" | 16 #include "base/sys_info.h" |
15 #include "chrome/app/chrome_command_ids.h" | 17 #include "chrome/app/chrome_command_ids.h" |
16 #include "chrome/browser/chrome_content_browser_client.h" | 18 #include "chrome/browser/chrome_content_browser_client.h" |
17 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
18 #include "chrome/browser/command_updater.h" | 20 #include "chrome/browser/command_updater.h" |
19 #include "chrome/browser/defaults.h" | 21 #include "chrome/browser/defaults.h" |
20 #include "chrome/browser/devtools/devtools_window_testing.h" | 22 #include "chrome/browser/devtools/devtools_window_testing.h" |
21 #include "chrome/browser/extensions/extension_browsertest.h" | 23 #include "chrome/browser/extensions/extension_browsertest.h" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 199 |
198 // Used by CloseWithAppMenuOpen. Invokes CloseWindow on the supplied browser. | 200 // Used by CloseWithAppMenuOpen. Invokes CloseWindow on the supplied browser. |
199 void CloseWindowCallback(Browser* browser) { | 201 void CloseWindowCallback(Browser* browser) { |
200 chrome::CloseWindow(browser); | 202 chrome::CloseWindow(browser); |
201 } | 203 } |
202 | 204 |
203 // Used by CloseWithAppMenuOpen. Posts a CloseWindowCallback and shows the app | 205 // Used by CloseWithAppMenuOpen. Posts a CloseWindowCallback and shows the app |
204 // menu. | 206 // menu. |
205 void RunCloseWithAppMenuCallback(Browser* browser) { | 207 void RunCloseWithAppMenuCallback(Browser* browser) { |
206 // ShowAppMenu is modal under views. Schedule a task that closes the window. | 208 // ShowAppMenu is modal under views. Schedule a task that closes the window. |
207 base::MessageLoop::current()->PostTask( | 209 base::MessageLoop::current()->task_runner()->PostTask( |
208 FROM_HERE, base::Bind(&CloseWindowCallback, browser)); | 210 FROM_HERE, base::Bind(&CloseWindowCallback, browser)); |
209 chrome::ShowAppMenu(browser); | 211 chrome::ShowAppMenu(browser); |
210 } | 212 } |
211 | 213 |
212 // Displays "INTERSTITIAL" while the interstitial is attached. | 214 // Displays "INTERSTITIAL" while the interstitial is attached. |
213 // (InterstitialPage can be used in a test directly, but there would be no way | 215 // (InterstitialPage can be used in a test directly, but there would be no way |
214 // to visually tell if it is showing or not.) | 216 // to visually tell if it is showing or not.) |
215 class TestInterstitialPage : public content::InterstitialPageDelegate { | 217 class TestInterstitialPage : public content::InterstitialPageDelegate { |
216 public: | 218 public: |
217 TestInterstitialPage(WebContents* tab, bool new_navigation, const GURL& url) { | 219 TestInterstitialPage(WebContents* tab, bool new_navigation, const GURL& url) { |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 // ensures that it happens through the single IDC_EXIT of the test. | 913 // ensures that it happens through the single IDC_EXIT of the test. |
912 void TearDownOnMainThread() override { | 914 void TearDownOnMainThread() override { |
913 // Cycle both the MessageLoop and the Cocoa runloop twice to flush out any | 915 // Cycle both the MessageLoop and the Cocoa runloop twice to flush out any |
914 // Chrome work that generates Cocoa work. Do this twice since there are two | 916 // Chrome work that generates Cocoa work. Do this twice since there are two |
915 // Browsers that must be closed. | 917 // Browsers that must be closed. |
916 CycleRunLoops(); | 918 CycleRunLoops(); |
917 CycleRunLoops(); | 919 CycleRunLoops(); |
918 | 920 |
919 // Run the application event loop to completion, which will cycle the | 921 // Run the application event loop to completion, which will cycle the |
920 // native MessagePump on all platforms. | 922 // native MessagePump on all platforms. |
921 base::MessageLoop::current()->PostTask(FROM_HERE, | 923 base::MessageLoop::current()->task_runner()->PostTask( |
922 base::MessageLoop::QuitClosure()); | 924 FROM_HERE, base::MessageLoop::QuitClosure()); |
923 base::MessageLoop::current()->Run(); | 925 base::MessageLoop::current()->Run(); |
924 | 926 |
925 // Take care of any remaining Cocoa work. | 927 // Take care of any remaining Cocoa work. |
926 CycleRunLoops(); | 928 CycleRunLoops(); |
927 | 929 |
928 // At this point, quit should be for real now. | 930 // At this point, quit should be for real now. |
929 ASSERT_EQ(0u, chrome::GetTotalBrowserCount()); | 931 ASSERT_EQ(0u, chrome::GetTotalBrowserCount()); |
930 } | 932 } |
931 | 933 |
932 // A helper function that cycles the MessageLoop, and on Mac, the Cocoa run | 934 // A helper function that cycles the MessageLoop, and on Mac, the Cocoa run |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1584 } | 1586 } |
1585 #endif // !defined(OS_CHROMEOS) | 1587 #endif // !defined(OS_CHROMEOS) |
1586 | 1588 |
1587 // This test verifies we don't crash when closing the last window and the app | 1589 // This test verifies we don't crash when closing the last window and the app |
1588 // menu is showing. | 1590 // menu is showing. |
1589 IN_PROC_BROWSER_TEST_F(BrowserTest, CloseWithAppMenuOpen) { | 1591 IN_PROC_BROWSER_TEST_F(BrowserTest, CloseWithAppMenuOpen) { |
1590 if (browser_defaults::kBrowserAliveWithNoWindows) | 1592 if (browser_defaults::kBrowserAliveWithNoWindows) |
1591 return; | 1593 return; |
1592 | 1594 |
1593 // We need a message loop running for menus on windows. | 1595 // We need a message loop running for menus on windows. |
1594 base::MessageLoop::current()->PostTask( | 1596 base::MessageLoop::current()->task_runner()->PostTask( |
1595 FROM_HERE, base::Bind(&RunCloseWithAppMenuCallback, browser())); | 1597 FROM_HERE, base::Bind(&RunCloseWithAppMenuCallback, browser())); |
1596 } | 1598 } |
1597 | 1599 |
1598 #if !defined(OS_MACOSX) | 1600 #if !defined(OS_MACOSX) |
1599 IN_PROC_BROWSER_TEST_F(BrowserTest, OpenAppWindowLikeNtp) { | 1601 IN_PROC_BROWSER_TEST_F(BrowserTest, OpenAppWindowLikeNtp) { |
1600 ASSERT_TRUE(test_server()->Start()); | 1602 ASSERT_TRUE(test_server()->Start()); |
1601 | 1603 |
1602 // Load an app | 1604 // Load an app |
1603 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 1605 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
1604 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); | 1606 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); |
(...skipping 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2859 // Visit a broken HTTPS url. Other conditions cannot be tested after | 2861 // Visit a broken HTTPS url. Other conditions cannot be tested after |
2860 // this one because once the interstitial is clicked through, all URLs | 2862 // this one because once the interstitial is clicked through, all URLs |
2861 // for this host will remain in a broken state. | 2863 // for this host will remain in a broken state. |
2862 GURL expired_url(https_test_server_expired.GetURL(std::string())); | 2864 GURL expired_url(https_test_server_expired.GetURL(std::string())); |
2863 ui_test_utils::NavigateToURL(browser(), expired_url); | 2865 ui_test_utils::NavigateToURL(browser(), expired_url); |
2864 | 2866 |
2865 ProceedThroughInterstitial(web_contents); | 2867 ProceedThroughInterstitial(web_contents); |
2866 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATION_BROKEN, | 2868 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATION_BROKEN, |
2867 observer.latest_security_style()); | 2869 observer.latest_security_style()); |
2868 } | 2870 } |
OLD | NEW |