| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "chrome/browser/ui/browser.h" | 6 #include "chrome/browser/ui/browser.h" |
| 7 #include "chrome/browser/ui/browser_list.h" | 7 #include "chrome/browser/ui/browser_list.h" |
| 8 #include "chrome/browser/ui/browser_window.h" | 8 #include "chrome/browser/ui/browser_window.h" |
| 9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
| 10 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 " window.open(null, null, 'width=100,height=100');" | 41 " window.open(null, null, 'width=100,height=100');" |
| 42 " }" | 42 " }" |
| 43 "</script>" | 43 "</script>" |
| 44 "</body></html>"; | 44 "</body></html>"; |
| 45 GURL url("data:text/html," + HTML); | 45 GURL url("data:text/html," + HTML); |
| 46 CommandLine::ForCurrentProcess()->AppendSwitch( | 46 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 47 switches::kDisablePopupBlocking); | 47 switches::kDisablePopupBlocking); |
| 48 | 48 |
| 49 ui_test_utils::WindowedNotificationObserver tab_added_observer( | 49 ui_test_utils::WindowedNotificationObserver tab_added_observer( |
| 50 content::NOTIFICATION_TAB_ADDED, | 50 content::NOTIFICATION_TAB_ADDED, |
| 51 NotificationService::AllSources()); | 51 content::NotificationService::AllSources()); |
| 52 browser()->OpenURL(url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED); | 52 browser()->OpenURL(url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED); |
| 53 tab_added_observer.Wait(); | 53 tab_added_observer.Wait(); |
| 54 | 54 |
| 55 // Find the new browser. | 55 // Find the new browser. |
| 56 Browser* new_browser = NULL; | 56 Browser* new_browser = NULL; |
| 57 for (BrowserList::const_iterator i = BrowserList::begin(); | 57 for (BrowserList::const_iterator i = BrowserList::begin(); |
| 58 i != BrowserList::end() && !new_browser; ++i) { | 58 i != BrowserList::end() && !new_browser; ++i) { |
| 59 if (*i != browser()) | 59 if (*i != browser()) |
| 60 new_browser = *i; | 60 new_browser = *i; |
| 61 } | 61 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 84 " window.open(null, null, 'width=1000,height=1000');" | 84 " window.open(null, null, 'width=1000,height=1000');" |
| 85 " }" | 85 " }" |
| 86 "</script>" | 86 "</script>" |
| 87 "</body></html>"; | 87 "</body></html>"; |
| 88 GURL url("data:text/html," + HTML); | 88 GURL url("data:text/html," + HTML); |
| 89 CommandLine::ForCurrentProcess()->AppendSwitch( | 89 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 90 switches::kDisablePopupBlocking); | 90 switches::kDisablePopupBlocking); |
| 91 int old_tab_count = browser()->tab_count(); | 91 int old_tab_count = browser()->tab_count(); |
| 92 ui_test_utils::WindowedNotificationObserver tab_added_observer( | 92 ui_test_utils::WindowedNotificationObserver tab_added_observer( |
| 93 content::NOTIFICATION_TAB_ADDED, | 93 content::NOTIFICATION_TAB_ADDED, |
| 94 NotificationService::AllSources()); | 94 content::NotificationService::AllSources()); |
| 95 browser()->OpenURL(url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED); | 95 browser()->OpenURL(url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED); |
| 96 tab_added_observer.Wait(); | 96 tab_added_observer.Wait(); |
| 97 | 97 |
| 98 // Shouldn't find a new browser. | 98 // Shouldn't find a new browser. |
| 99 Browser* new_browser = NULL; | 99 Browser* new_browser = NULL; |
| 100 for (BrowserList::const_iterator i = BrowserList::begin(); | 100 for (BrowserList::const_iterator i = BrowserList::begin(); |
| 101 i != BrowserList::end() && !new_browser; ++i) { | 101 i != BrowserList::end() && !new_browser; ++i) { |
| 102 if (*i != browser()) | 102 if (*i != browser()) |
| 103 new_browser = *i; | 103 new_browser = *i; |
| 104 } | 104 } |
| 105 EXPECT_FALSE(new_browser); | 105 EXPECT_FALSE(new_browser); |
| 106 | 106 |
| 107 // Should find a new tab. | 107 // Should find a new tab. |
| 108 EXPECT_EQ(old_tab_count + 1, browser()->tab_count()); | 108 EXPECT_EQ(old_tab_count + 1, browser()->tab_count()); |
| 109 } | 109 } |
| 110 | 110 |
| 111 } // namespace chromeos | 111 } // namespace chromeos |
| OLD | NEW |