| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/browser.h" |
| 6 #include "chrome/browser/browser_init.h" |
| 7 #include "chrome/browser/browser_list.h" |
| 8 #include "chrome/browser/browser_window.h" |
| 9 #include "chrome/test/in_process_browser_test.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 |
| 12 namespace { |
| 13 |
| 14 class BrowserInitTest : public InProcessBrowserTest { |
| 15 protected: |
| 16 }; |
| 17 |
| 18 // Test that when there is a popup as the active browser any requests to |
| 19 // BrowserInit::LaunchWithProfile::OpenURLsInBrowser don't crash because |
| 20 // there's no explicit profile given. |
| 21 IN_PROC_BROWSER_TEST_F(BrowserInitTest, OpenURLsPopup) { |
| 22 std::vector<GURL> urls; |
| 23 urls.push_back(GURL("http://www.google.com")); |
| 24 urls.push_back(GURL("http://dev.chromium.org")); |
| 25 |
| 26 Browser* popup = Browser::CreateForPopup(browser()->profile()); |
| 27 ASSERT_EQ(popup->type(), Browser::TYPE_POPUP); |
| 28 BrowserWindow* window = popup->window(); |
| 29 window->Activate(); |
| 30 Browser* frontmost = BrowserList::GetLastActive(); |
| 31 ASSERT_EQ(frontmost, popup); |
| 32 |
| 33 CommandLine dummy((std::wstring())); |
| 34 BrowserInit::LaunchWithProfile launch(std::wstring(), dummy); |
| 35 // This should create a new window, but re-use the profile from |popup|. If |
| 36 // it used a NULL or invalid profile, it would crash. |
| 37 launch.OpenURLsInBrowser(popup, false, urls); |
| 38 frontmost = BrowserList::GetLastActive(); |
| 39 ASSERT_NE(frontmost, popup); |
| 40 } |
| 41 |
| 42 } // namespace |
| OLD | NEW |