OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 "/pdf_private/accessibility_crash_2.pdf")); | 755 "/pdf_private/accessibility_crash_2.pdf")); |
756 | 756 |
757 WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); | 757 WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); |
758 ASSERT_TRUE(guest_contents); | 758 ASSERT_TRUE(guest_contents); |
759 | 759 |
760 WaitForAccessibilityTreeToContainNodeWithName(guest_contents, "Page 1"); | 760 WaitForAccessibilityTreeToContainNodeWithName(guest_contents, "Page 1"); |
761 } | 761 } |
762 #endif | 762 #endif |
763 | 763 |
764 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, LinkCtrlLeftClick) { | 764 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, LinkCtrlLeftClick) { |
765 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | |
766 GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test-link.pdf")); | 765 GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test-link.pdf")); |
767 WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); | 766 WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); |
768 ASSERT_TRUE(guest_contents); | 767 ASSERT_TRUE(guest_contents); |
769 | 768 |
770 // The link position of the test-link.pdf in page coordinates is (110, 110). | 769 // The link position of the test-link.pdf in page coordinates is (110, 110). |
771 // Convert the link position from page coordinates to screen coordinates. | 770 // Convert the link position from page coordinates to screen coordinates. |
772 gfx::Point link_position(110, 110); | 771 gfx::Point link_position(110, 110); |
773 ConvertPageCoordToScreenCoord(guest_contents, &link_position); | 772 ConvertPageCoordToScreenCoord(guest_contents, &link_position); |
774 | 773 |
775 WebContents* web_contents = GetActiveWebContents(); | 774 WebContents* web_contents = GetActiveWebContents(); |
(...skipping 15 matching lines...) Expand all Loading... |
791 WebContents* new_web_contents = | 790 WebContents* new_web_contents = |
792 browser()->tab_strip_model()->GetWebContentsAt(1); | 791 browser()->tab_strip_model()->GetWebContentsAt(1); |
793 ASSERT_TRUE(new_web_contents); | 792 ASSERT_TRUE(new_web_contents); |
794 ASSERT_NE(web_contents, new_web_contents); | 793 ASSERT_NE(web_contents, new_web_contents); |
795 | 794 |
796 const GURL& url = new_web_contents->GetURL(); | 795 const GURL& url = new_web_contents->GetURL(); |
797 ASSERT_EQ(std::string("http://www.example.com/"), url.spec()); | 796 ASSERT_EQ(std::string("http://www.example.com/"), url.spec()); |
798 } | 797 } |
799 | 798 |
800 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, LinkMiddleClick) { | 799 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, LinkMiddleClick) { |
801 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | |
802 GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test-link.pdf")); | 800 GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test-link.pdf")); |
803 WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); | 801 WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); |
804 ASSERT_TRUE(guest_contents); | 802 ASSERT_TRUE(guest_contents); |
805 | 803 |
806 // The link position of the test-link.pdf in page coordinates is (110, 110). | 804 // The link position of the test-link.pdf in page coordinates is (110, 110). |
807 // Convert the link position from page coordinates to screen coordinates. | 805 // Convert the link position from page coordinates to screen coordinates. |
808 gfx::Point link_position(110, 110); | 806 gfx::Point link_position(110, 110); |
809 ConvertPageCoordToScreenCoord(guest_contents, &link_position); | 807 ConvertPageCoordToScreenCoord(guest_contents, &link_position); |
810 | 808 |
811 WebContents* web_contents = GetActiveWebContents(); | 809 WebContents* web_contents = GetActiveWebContents(); |
(...skipping 14 matching lines...) Expand all Loading... |
826 WebContents* new_web_contents = | 824 WebContents* new_web_contents = |
827 browser()->tab_strip_model()->GetWebContentsAt(1); | 825 browser()->tab_strip_model()->GetWebContentsAt(1); |
828 ASSERT_TRUE(new_web_contents); | 826 ASSERT_TRUE(new_web_contents); |
829 ASSERT_NE(web_contents, new_web_contents); | 827 ASSERT_NE(web_contents, new_web_contents); |
830 | 828 |
831 const GURL& url = new_web_contents->GetURL(); | 829 const GURL& url = new_web_contents->GetURL(); |
832 ASSERT_EQ(std::string("http://www.example.com/"), url.spec()); | 830 ASSERT_EQ(std::string("http://www.example.com/"), url.spec()); |
833 } | 831 } |
834 | 832 |
835 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, LinkCtrlShiftLeftClick) { | 833 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, LinkCtrlShiftLeftClick) { |
836 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | |
837 GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test-link.pdf")); | 834 GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test-link.pdf")); |
838 WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); | 835 WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); |
839 ASSERT_TRUE(guest_contents); | 836 ASSERT_TRUE(guest_contents); |
840 | 837 |
841 // The link position of the test-link.pdf in page coordinates is (110, 110). | 838 // The link position of the test-link.pdf in page coordinates is (110, 110). |
842 // Convert the link position from page coordinates to screen coordinates. | 839 // Convert the link position from page coordinates to screen coordinates. |
843 gfx::Point link_position(110, 110); | 840 gfx::Point link_position(110, 110); |
844 ConvertPageCoordToScreenCoord(guest_contents, &link_position); | 841 ConvertPageCoordToScreenCoord(guest_contents, &link_position); |
845 | 842 |
846 WebContents* web_contents = GetActiveWebContents(); | 843 WebContents* web_contents = GetActiveWebContents(); |
(...skipping 12 matching lines...) Expand all Loading... |
859 ASSERT_EQ(2, tab_count); | 856 ASSERT_EQ(2, tab_count); |
860 | 857 |
861 WebContents* active_web_contents = GetActiveWebContents(); | 858 WebContents* active_web_contents = GetActiveWebContents(); |
862 ASSERT_NE(web_contents, active_web_contents); | 859 ASSERT_NE(web_contents, active_web_contents); |
863 | 860 |
864 const GURL& url = active_web_contents->GetURL(); | 861 const GURL& url = active_web_contents->GetURL(); |
865 ASSERT_EQ(std::string("http://www.example.com/"), url.spec()); | 862 ASSERT_EQ(std::string("http://www.example.com/"), url.spec()); |
866 } | 863 } |
867 | 864 |
868 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, LinkShiftMiddleClick) { | 865 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, LinkShiftMiddleClick) { |
869 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | |
870 GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test-link.pdf")); | 866 GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test-link.pdf")); |
871 WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); | 867 WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); |
872 ASSERT_TRUE(guest_contents); | 868 ASSERT_TRUE(guest_contents); |
873 | 869 |
874 // The link position of the test-link.pdf in page coordinates is (110, 110). | 870 // The link position of the test-link.pdf in page coordinates is (110, 110). |
875 // Convert the link position from page coordinates to screen coordinates. | 871 // Convert the link position from page coordinates to screen coordinates. |
876 gfx::Point link_position(110, 110); | 872 gfx::Point link_position(110, 110); |
877 ConvertPageCoordToScreenCoord(guest_contents, &link_position); | 873 ConvertPageCoordToScreenCoord(guest_contents, &link_position); |
878 | 874 |
879 WebContents* web_contents = GetActiveWebContents(); | 875 WebContents* web_contents = GetActiveWebContents(); |
(...skipping 10 matching lines...) Expand all Loading... |
890 ASSERT_EQ(2, tab_count); | 886 ASSERT_EQ(2, tab_count); |
891 | 887 |
892 WebContents* active_web_contents = GetActiveWebContents(); | 888 WebContents* active_web_contents = GetActiveWebContents(); |
893 ASSERT_NE(web_contents, active_web_contents); | 889 ASSERT_NE(web_contents, active_web_contents); |
894 | 890 |
895 const GURL& url = active_web_contents->GetURL(); | 891 const GURL& url = active_web_contents->GetURL(); |
896 ASSERT_EQ(std::string("http://www.example.com/"), url.spec()); | 892 ASSERT_EQ(std::string("http://www.example.com/"), url.spec()); |
897 } | 893 } |
898 | 894 |
899 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, LinkShiftLeftClick) { | 895 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, LinkShiftLeftClick) { |
900 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | |
901 GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test-link.pdf")); | 896 GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test-link.pdf")); |
902 WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); | 897 WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); |
903 ASSERT_TRUE(guest_contents); | 898 ASSERT_TRUE(guest_contents); |
904 ASSERT_EQ(1U, chrome::GetTotalBrowserCount()); | 899 ASSERT_EQ(1U, chrome::GetTotalBrowserCount()); |
905 | 900 |
906 // The link position of the test-link.pdf in page coordinates is (110, 110). | 901 // The link position of the test-link.pdf in page coordinates is (110, 110). |
907 // Convert the link position from page coordinates to screen coordinates. | 902 // Convert the link position from page coordinates to screen coordinates. |
908 gfx::Point link_position(110, 110); | 903 gfx::Point link_position(110, 110); |
909 ConvertPageCoordToScreenCoord(guest_contents, &link_position); | 904 ConvertPageCoordToScreenCoord(guest_contents, &link_position); |
910 | 905 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 | 953 |
959 EXPECT_TRUE(web_contents->GetController().GetPendingEntry()); | 954 EXPECT_TRUE(web_contents->GetController().GetPendingEntry()); |
960 EXPECT_FALSE(active_web_contents->GetController().GetPendingEntry()); | 955 EXPECT_FALSE(active_web_contents->GetController().GetPendingEntry()); |
961 } | 956 } |
962 | 957 |
963 // This test opens a PDF by clicking a link via javascript and verifies that | 958 // This test opens a PDF by clicking a link via javascript and verifies that |
964 // the PDF is loaded and functional by clicking a link in the PDF. The link | 959 // the PDF is loaded and functional by clicking a link in the PDF. The link |
965 // click in the PDF opens a new tab. The main page handles the pageShow event | 960 // click in the PDF opens a new tab. The main page handles the pageShow event |
966 // and updates the history state. | 961 // and updates the history state. |
967 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, OpenPDFOnLinkClickWithReplaceState) { | 962 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, OpenPDFOnLinkClickWithReplaceState) { |
968 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | |
969 | |
970 // Navigate to the main page. | 963 // Navigate to the main page. |
971 GURL test_url( | 964 GURL test_url( |
972 embedded_test_server()->GetURL("/pdf/pdf_href_replace_state.html")); | 965 embedded_test_server()->GetURL("/pdf/pdf_href_replace_state.html")); |
973 ui_test_utils::NavigateToURL(browser(), test_url); | 966 ui_test_utils::NavigateToURL(browser(), test_url); |
974 WebContents* web_contents = GetActiveWebContents(); | 967 WebContents* web_contents = GetActiveWebContents(); |
975 ASSERT_TRUE(web_contents); | 968 ASSERT_TRUE(web_contents); |
976 | 969 |
977 // Click on the link which opens the PDF via JS. | 970 // Click on the link which opens the PDF via JS. |
978 content::TestNavigationObserver navigation_observer(web_contents); | 971 content::TestNavigationObserver navigation_observer(web_contents); |
979 const char kPdfLinkClick[] = "document.getElementById('link').click();"; | 972 const char kPdfLinkClick[] = "document.getElementById('link').click();"; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1024 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, OpenFromFTP) { | 1017 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, OpenFromFTP) { |
1025 net::SpawnedTestServer ftp_server( | 1018 net::SpawnedTestServer ftp_server( |
1026 net::SpawnedTestServer::TYPE_FTP, net::SpawnedTestServer::kLocalhost, | 1019 net::SpawnedTestServer::TYPE_FTP, net::SpawnedTestServer::kLocalhost, |
1027 base::FilePath(FILE_PATH_LITERAL("chrome/test/data/pdf"))); | 1020 base::FilePath(FILE_PATH_LITERAL("chrome/test/data/pdf"))); |
1028 ASSERT_TRUE(ftp_server.Start()); | 1021 ASSERT_TRUE(ftp_server.Start()); |
1029 | 1022 |
1030 GURL url(ftp_server.GetURL("/test.pdf")); | 1023 GURL url(ftp_server.GetURL("/test.pdf")); |
1031 ASSERT_TRUE(LoadPdf(url)); | 1024 ASSERT_TRUE(LoadPdf(url)); |
1032 EXPECT_EQ(base::ASCIIToUTF16("test.pdf"), GetActiveWebContents()->GetTitle()); | 1025 EXPECT_EQ(base::ASCIIToUTF16("test.pdf"), GetActiveWebContents()->GetTitle()); |
1033 } | 1026 } |
OLD | NEW |