OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_commands.h" | 10 #include "chrome/browser/ui/browser_commands.h" |
| 11 #include "chrome/browser/ui/browser_iterator.h" |
11 #include "chrome/browser/ui/browser_list.h" | 12 #include "chrome/browser/ui/browser_list.h" |
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 14 #include "chrome/common/chrome_notification_types.h" |
13 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/common/chrome_notification_types.h" | |
15 #include "chrome/test/base/in_process_browser_test.h" | 16 #include "chrome/test/base/in_process_browser_test.h" |
16 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
18 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
19 #include "content/public/test/browser_test_utils.h" | 20 #include "content/public/test/browser_test_utils.h" |
20 | 21 |
21 using content::BrowserThread; | 22 using content::BrowserThread; |
22 | 23 |
23 class FastShutdown : public InProcessBrowserTest { | 24 class FastShutdown : public InProcessBrowserTest { |
24 protected: | 25 protected: |
(...skipping 22 matching lines...) Expand all Loading... |
47 | 48 |
48 content::WindowedNotificationObserver window_observer( | 49 content::WindowedNotificationObserver window_observer( |
49 chrome::NOTIFICATION_BROWSER_WINDOW_READY, | 50 chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
50 content::NotificationService::AllSources()); | 51 content::NotificationService::AllSources()); |
51 ui_test_utils::NavigateToURLWithDisposition( | 52 ui_test_utils::NavigateToURLWithDisposition( |
52 browser(), url, NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_NONE); | 53 browser(), url, NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_NONE); |
53 window_observer.Wait(); | 54 window_observer.Wait(); |
54 | 55 |
55 // Close the new window, removing the one and only beforeunload handler. | 56 // Close the new window, removing the one and only beforeunload handler. |
56 ASSERT_EQ(2u, BrowserList::size()); | 57 ASSERT_EQ(2u, BrowserList::size()); |
57 BrowserList::const_iterator i = BrowserList::begin(); | 58 chrome::BrowserIterator it; |
58 ++i; | 59 it.Next(); |
59 chrome::CloseWindow(*i); | 60 chrome::CloseWindow(*it); |
60 | 61 |
61 // Need to wait for the renderer process to shutdown to ensure that we got the | 62 // Need to wait for the renderer process to shutdown to ensure that we got the |
62 // set cookies IPC. | 63 // set cookies IPC. |
63 content::WindowedNotificationObserver renderer_shutdown_observer( | 64 content::WindowedNotificationObserver renderer_shutdown_observer( |
64 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 65 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
65 content::NotificationService::AllSources()); | 66 content::NotificationService::AllSources()); |
66 // Close the tab. This should launch the unload handler, which sets a cookie | 67 // Close the tab. This should launch the unload handler, which sets a cookie |
67 // that's stored to disk. | 68 // that's stored to disk. |
68 chrome::CloseTab(browser()); | 69 chrome::CloseTab(browser()); |
69 renderer_shutdown_observer.Wait(); | 70 renderer_shutdown_observer.Wait(); |
70 | 71 |
71 EXPECT_EQ("unloaded=ohyeah", content::GetCookies(browser()->profile(), url)); | 72 EXPECT_EQ("unloaded=ohyeah", content::GetCookies(browser()->profile(), url)); |
72 } | 73 } |
73 #endif | 74 #endif |
OLD | NEW |