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 active tab in last active window should be the new tab. | 617 // Now the current tab should be the new tab. |
618 Browser* last_active_browser = BrowserList::GetLastActive(); | 618 TabContents* newtab = browser->GetSelectedTabContents(); |
619 EXPECT_TRUE(last_active_browser); | |
620 TabContents* newtab = last_active_browser->GetSelectedTabContents(); | |
621 EXPECT_TRUE(newtab); | |
622 GURL expected_url = start_url.Resolve(newtab_url); | 619 GURL expected_url = start_url.Resolve(newtab_url); |
623 if (!newtab->controller().GetLastCommittedEntry() || | 620 if (!newtab->controller().GetLastCommittedEntry() || |
624 newtab->controller().GetLastCommittedEntry()->url() != expected_url) | 621 newtab->controller().GetLastCommittedEntry()->url() != expected_url) |
625 ui_test_utils::WaitForNavigation(&newtab->controller()); | 622 ui_test_utils::WaitForNavigation(&newtab->controller()); |
626 EXPECT_EQ(expected_url, newtab->controller().GetLastCommittedEntry()->url()); | 623 EXPECT_EQ(expected_url, newtab->controller().GetLastCommittedEntry()->url()); |
627 | 624 |
628 return newtab; | 625 return newtab; |
629 } | 626 } |
630 | 627 |
631 // Tests that an extension page can call window.open to an extension URL and | 628 // 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... |
775 | 772 |
776 // If the options page hasn't already come up, wait for it. | 773 // If the options page hasn't already come up, wait for it. |
777 if (tab_strip->count() == 1) { | 774 if (tab_strip->count() == 1) { |
778 ui_test_utils::WaitForNewTab(browser()); | 775 ui_test_utils::WaitForNewTab(browser()); |
779 } | 776 } |
780 ASSERT_EQ(2, tab_strip->count()); | 777 ASSERT_EQ(2, tab_strip->count()); |
781 | 778 |
782 EXPECT_EQ(extension->GetResourceURL("options.html"), | 779 EXPECT_EQ(extension->GetResourceURL("options.html"), |
783 tab_strip->GetTabContentsAt(1)->GetURL()); | 780 tab_strip->GetTabContentsAt(1)->GetURL()); |
784 } | 781 } |
OLD | NEW |