| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 98 |
| 99 const char* kOpenNewBeforeUnloadPage = | 99 const char* kOpenNewBeforeUnloadPage = |
| 100 "w=window.open(); w.onbeforeunload=function(e){return 'foo'};"; | 100 "w=window.open(); w.onbeforeunload=function(e){return 'foo'};"; |
| 101 | 101 |
| 102 const base::FilePath::CharType* kBeforeUnloadFile = | 102 const base::FilePath::CharType* kBeforeUnloadFile = |
| 103 FILE_PATH_LITERAL("beforeunload.html"); | 103 FILE_PATH_LITERAL("beforeunload.html"); |
| 104 | 104 |
| 105 const base::FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html"); | 105 const base::FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html"); |
| 106 const base::FilePath::CharType* kTitle2File = FILE_PATH_LITERAL("title2.html"); | 106 const base::FilePath::CharType* kTitle2File = FILE_PATH_LITERAL("title2.html"); |
| 107 | 107 |
| 108 const base::FilePath::CharType kDocRoot[] = | |
| 109 FILE_PATH_LITERAL("chrome/test/data"); | |
| 110 | |
| 111 // Given a page title, returns the expected window caption string. | 108 // Given a page title, returns the expected window caption string. |
| 112 string16 WindowCaptionFromPageTitle(const string16& page_title) { | 109 string16 WindowCaptionFromPageTitle(const string16& page_title) { |
| 113 #if defined(OS_MACOSX) || defined(OS_CHROMEOS) | 110 #if defined(OS_MACOSX) || defined(OS_CHROMEOS) |
| 114 // On Mac or ChromeOS, we don't want to suffix the page title with | 111 // On Mac or ChromeOS, we don't want to suffix the page title with |
| 115 // the application name. | 112 // the application name. |
| 116 if (page_title.empty()) | 113 if (page_title.empty()) |
| 117 return l10n_util::GetStringUTF16(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED); | 114 return l10n_util::GetStringUTF16(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED); |
| 118 return page_title; | 115 return page_title; |
| 119 #else | 116 #else |
| 120 if (page_title.empty()) | 117 if (page_title.empty()) |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 // it to a cross-site URL. It should also work for meta-refreshes. | 517 // it to a cross-site URL. It should also work for meta-refreshes. |
| 521 // See http://crbug.com/93517. | 518 // See http://crbug.com/93517. |
| 522 IN_PROC_BROWSER_TEST_F(BrowserTest, NullOpenerRedirectForksProcess) { | 519 IN_PROC_BROWSER_TEST_F(BrowserTest, NullOpenerRedirectForksProcess) { |
| 523 CommandLine::ForCurrentProcess()->AppendSwitch( | 520 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 524 switches::kDisablePopupBlocking); | 521 switches::kDisablePopupBlocking); |
| 525 | 522 |
| 526 // Create http and https servers for a cross-site transition. | 523 // Create http and https servers for a cross-site transition. |
| 527 ASSERT_TRUE(test_server()->Start()); | 524 ASSERT_TRUE(test_server()->Start()); |
| 528 net::TestServer https_test_server(net::TestServer::TYPE_HTTPS, | 525 net::TestServer https_test_server(net::TestServer::TYPE_HTTPS, |
| 529 net::TestServer::kLocalhost, | 526 net::TestServer::kLocalhost, |
| 530 base::FilePath(kDocRoot)); | 527 net::TestServer::GetTestDataPath()); |
| 531 ASSERT_TRUE(https_test_server.Start()); | 528 ASSERT_TRUE(https_test_server.Start()); |
| 532 GURL http_url(test_server()->GetURL("files/title1.html")); | 529 GURL http_url(test_server()->GetURL("files/title1.html")); |
| 533 GURL https_url(https_test_server.GetURL("")); | 530 GURL https_url(https_test_server.GetURL("")); |
| 534 | 531 |
| 535 // Start with an http URL. | 532 // Start with an http URL. |
| 536 ui_test_utils::NavigateToURL(browser(), http_url); | 533 ui_test_utils::NavigateToURL(browser(), http_url); |
| 537 WebContents* oldtab = browser()->tab_strip_model()->GetActiveWebContents(); | 534 WebContents* oldtab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 538 content::RenderProcessHost* process = oldtab->GetRenderProcessHost(); | 535 content::RenderProcessHost* process = oldtab->GetRenderProcessHost(); |
| 539 | 536 |
| 540 // Now open a tab to a blank page, set its opener to null, and redirect it | 537 // Now open a tab to a blank page, set its opener to null, and redirect it |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 // http://www.google.com/chrome/intl/en/webmasters-faq.html#newtab will not | 606 // http://www.google.com/chrome/intl/en/webmasters-faq.html#newtab will not |
| 610 // fork a new renderer process. | 607 // fork a new renderer process. |
| 611 IN_PROC_BROWSER_TEST_F(BrowserTest, OtherRedirectsDontForkProcess) { | 608 IN_PROC_BROWSER_TEST_F(BrowserTest, OtherRedirectsDontForkProcess) { |
| 612 CommandLine::ForCurrentProcess()->AppendSwitch( | 609 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 613 switches::kDisablePopupBlocking); | 610 switches::kDisablePopupBlocking); |
| 614 | 611 |
| 615 // Create http and https servers for a cross-site transition. | 612 // Create http and https servers for a cross-site transition. |
| 616 ASSERT_TRUE(test_server()->Start()); | 613 ASSERT_TRUE(test_server()->Start()); |
| 617 net::TestServer https_test_server(net::TestServer::TYPE_HTTPS, | 614 net::TestServer https_test_server(net::TestServer::TYPE_HTTPS, |
| 618 net::TestServer::kLocalhost, | 615 net::TestServer::kLocalhost, |
| 619 base::FilePath(kDocRoot)); | 616 net::TestServer::GetTestDataPath()); |
| 620 ASSERT_TRUE(https_test_server.Start()); | 617 ASSERT_TRUE(https_test_server.Start()); |
| 621 GURL http_url(test_server()->GetURL("files/title1.html")); | 618 GURL http_url(test_server()->GetURL("files/title1.html")); |
| 622 GURL https_url(https_test_server.GetURL("")); | 619 GURL https_url(https_test_server.GetURL("")); |
| 623 | 620 |
| 624 // Start with an http URL. | 621 // Start with an http URL. |
| 625 ui_test_utils::NavigateToURL(browser(), http_url); | 622 ui_test_utils::NavigateToURL(browser(), http_url); |
| 626 WebContents* oldtab = browser()->tab_strip_model()->GetActiveWebContents(); | 623 WebContents* oldtab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 627 content::RenderProcessHost* process = oldtab->GetRenderProcessHost(); | 624 content::RenderProcessHost* process = oldtab->GetRenderProcessHost(); |
| 628 | 625 |
| 629 // Now open a tab to a blank page, set its opener to null, and redirect it | 626 // Now open a tab to a blank page, set its opener to null, and redirect it |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 ui_test_utils::NavigateToURL(browser(), http_url); | 721 ui_test_utils::NavigateToURL(browser(), http_url); |
| 725 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); | 722 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); |
| 726 } | 723 } |
| 727 | 724 |
| 728 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutHttps) { | 725 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutHttps) { |
| 729 CommandUpdater* command_updater = | 726 CommandUpdater* command_updater = |
| 730 browser()->command_controller()->command_updater(); | 727 browser()->command_controller()->command_updater(); |
| 731 | 728 |
| 732 net::TestServer test_server(net::TestServer::TYPE_HTTPS, | 729 net::TestServer test_server(net::TestServer::TYPE_HTTPS, |
| 733 net::TestServer::kLocalhost, | 730 net::TestServer::kLocalhost, |
| 734 base::FilePath(kDocRoot)); | 731 net::TestServer::GetTestDataPath()); |
| 735 ASSERT_TRUE(test_server.Start()); | 732 ASSERT_TRUE(test_server.Start()); |
| 736 GURL https_url(test_server.GetURL("/")); | 733 GURL https_url(test_server.GetURL("/")); |
| 737 ASSERT_TRUE(https_url.SchemeIs(chrome::kHttpsScheme)); | 734 ASSERT_TRUE(https_url.SchemeIs(chrome::kHttpsScheme)); |
| 738 ui_test_utils::NavigateToURL(browser(), https_url); | 735 ui_test_utils::NavigateToURL(browser(), https_url); |
| 739 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); | 736 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); |
| 740 } | 737 } |
| 741 | 738 |
| 742 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutFtp) { | 739 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutFtp) { |
| 743 CommandUpdater* command_updater = | 740 CommandUpdater* command_updater = |
| 744 browser()->command_controller()->command_updater(); | 741 browser()->command_controller()->command_updater(); |
| 745 | 742 |
| 746 net::TestServer test_server(net::TestServer::TYPE_FTP, | 743 net::TestServer test_server(net::TestServer::TYPE_FTP, |
| 747 net::TestServer::kLocalhost, | 744 net::TestServer::kLocalhost, |
| 748 base::FilePath(kDocRoot)); | 745 net::TestServer::GetTestDataPath()); |
| 749 ASSERT_TRUE(test_server.Start()); | 746 ASSERT_TRUE(test_server.Start()); |
| 750 GURL ftp_url(test_server.GetURL("")); | 747 GURL ftp_url(test_server.GetURL("")); |
| 751 ASSERT_TRUE(ftp_url.SchemeIs(chrome::kFtpScheme)); | 748 ASSERT_TRUE(ftp_url.SchemeIs(chrome::kFtpScheme)); |
| 752 ui_test_utils::NavigateToURL(browser(), ftp_url); | 749 ui_test_utils::NavigateToURL(browser(), ftp_url); |
| 753 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); | 750 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); |
| 754 } | 751 } |
| 755 | 752 |
| 756 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutInvalid) { | 753 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutInvalid) { |
| 757 CommandUpdater* command_updater = | 754 CommandUpdater* command_updater = |
| 758 browser()->command_controller()->command_updater(); | 755 browser()->command_controller()->command_updater(); |
| (...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2023 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); | 2020 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); |
| 2024 } | 2021 } |
| 2025 | 2022 |
| 2026 // Shift-middle-clicks open in a foreground tab. | 2023 // Shift-middle-clicks open in a foreground tab. |
| 2027 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftMiddleClickTest) { | 2024 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftMiddleClickTest) { |
| 2028 int modifiers = WebKit::WebInputEvent::ShiftKey; | 2025 int modifiers = WebKit::WebInputEvent::ShiftKey; |
| 2029 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonMiddle; | 2026 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonMiddle; |
| 2030 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; | 2027 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; |
| 2031 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); | 2028 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); |
| 2032 } | 2029 } |
| OLD | NEW |