OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/ref_counted.h" | 6 #include "base/ref_counted.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
9 #include "chrome/browser/browser_list.h" | 9 #include "chrome/browser/browser_list.h" |
10 #include "chrome/browser/renderer_host/render_view_host.h" | 10 #include "chrome/browser/renderer_host/render_view_host.h" |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 const std::string& newtab_url) { | 607 const std::string& newtab_url) { |
608 ui_test_utils::NavigateToURL(browser, start_url); | 608 ui_test_utils::NavigateToURL(browser, start_url); |
609 | 609 |
610 bool result = false; | 610 bool result = false; |
611 ui_test_utils::ExecuteJavaScriptAndExtractBool( | 611 ui_test_utils::ExecuteJavaScriptAndExtractBool( |
612 browser->GetSelectedTabContents()->render_view_host(), L"", | 612 browser->GetSelectedTabContents()->render_view_host(), L"", |
613 L"window.open('" + UTF8ToWide(newtab_url) + L"');" | 613 L"window.open('" + UTF8ToWide(newtab_url) + L"');" |
614 L"window.domAutomationController.send(true);", &result); | 614 L"window.domAutomationController.send(true);", &result); |
615 EXPECT_TRUE(result); | 615 EXPECT_TRUE(result); |
616 | 616 |
617 // Now the current tab should be the new tab. | 617 // Now the active tab in last active window should be the new tab. |
618 TabContents* newtab = browser->GetSelectedTabContents(); | 618 Browser* last_active_browser = BrowserList::GetLastActive(); |
| 619 EXPECT_TRUE(last_active_browser); |
| 620 TabContents* newtab = last_active_browser->GetSelectedTabContents(); |
| 621 EXPECT_TRUE(newtab); |
619 GURL expected_url = start_url.Resolve(newtab_url); | 622 GURL expected_url = start_url.Resolve(newtab_url); |
620 if (!newtab->controller().GetLastCommittedEntry() || | 623 if (!newtab->controller().GetLastCommittedEntry() || |
621 newtab->controller().GetLastCommittedEntry()->url() != expected_url) | 624 newtab->controller().GetLastCommittedEntry()->url() != expected_url) |
622 ui_test_utils::WaitForNavigation(&newtab->controller()); | 625 ui_test_utils::WaitForNavigation(&newtab->controller()); |
623 EXPECT_EQ(expected_url, newtab->controller().GetLastCommittedEntry()->url()); | 626 EXPECT_EQ(expected_url, newtab->controller().GetLastCommittedEntry()->url()); |
624 | 627 |
625 return newtab; | 628 return newtab; |
626 } | 629 } |
627 | 630 |
628 // Tests that an extension page can call window.open to an extension URL and | 631 // Tests that an extension page can call window.open to an extension URL and |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 | 775 |
773 // If the options page hasn't already come up, wait for it. | 776 // If the options page hasn't already come up, wait for it. |
774 if (tab_strip->count() == 1) { | 777 if (tab_strip->count() == 1) { |
775 ui_test_utils::WaitForNewTab(browser()); | 778 ui_test_utils::WaitForNewTab(browser()); |
776 } | 779 } |
777 ASSERT_EQ(2, tab_strip->count()); | 780 ASSERT_EQ(2, tab_strip->count()); |
778 | 781 |
779 EXPECT_EQ(extension->GetResourceURL("options.html"), | 782 EXPECT_EQ(extension->GetResourceURL("options.html"), |
780 tab_strip->GetTabContentsAt(1)->GetURL()); | 783 tab_strip->GetTabContentsAt(1)->GetURL()); |
781 } | 784 } |
OLD | NEW |