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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
893 if (pos == std::string::npos) | 893 if (pos == std::string::npos) |
894 break; | 894 break; |
895 count++; | 895 count++; |
896 pos++; | 896 pos++; |
897 } | 897 } |
898 EXPECT_EQ(1, count) << "Verify number of image/png parts in the mhtml output"; | 898 EXPECT_EQ(1, count) << "Verify number of image/png parts in the mhtml output"; |
899 } | 899 } |
900 | 900 |
901 // Test suite that verifies that the frame tree "looks" the same before | 901 // Test suite that verifies that the frame tree "looks" the same before |
902 // and after a save-page-as. | 902 // and after a save-page-as. |
903 class SavePageMultiFrameBrowserTest : public SavePageSitePerProcessBrowserTest { | 903 class SavePageMultiFrameBrowserTest |
904 : public SavePageSitePerProcessBrowserTest, | |
905 public ::testing::WithParamInterface<content::SavePageType> { | |
904 protected: | 906 protected: |
905 void TestMultiFramePage(content::SavePageType save_page_type, | 907 void TestMultiFramePage(content::SavePageType save_page_type, |
906 const GURL& url, | 908 const GURL& url, |
907 int expected_number_of_frames, | 909 int expected_number_of_frames, |
908 const std::vector<std::string>& expected_substrings) { | 910 const std::vector<std::string>& expected_substrings, |
911 bool skip_verification_of_original_page = false) { | |
909 // Navigate to the test page and verify if test expectations | 912 // Navigate to the test page and verify if test expectations |
910 // are met (this is mostly a sanity check - a failure to meet | 913 // are met (this is mostly a sanity check - a failure to meet |
911 // expectations would probably mean that there is a test bug | 914 // expectations would probably mean that there is a test bug |
912 // (i.e. that we got called with wrong expected_foo argument). | 915 // (i.e. that we got called with wrong expected_foo argument). |
913 ui_test_utils::NavigateToURL(browser(), url); | 916 ui_test_utils::NavigateToURL(browser(), url); |
914 DLOG(INFO) << "Verifying test expectations for original page... : " | 917 DLOG(INFO) << "Verifying test expectations for original page... : " |
915 << GetCurrentTab(browser())->GetLastCommittedURL(); | 918 << GetCurrentTab(browser())->GetLastCommittedURL(); |
916 // TODO(lukasza/paulmeyer): crbug.com/457440: Can uncomment | 919 if (!skip_verification_of_original_page) { |
917 // the assertion below once find-in-page works for oop frames. | 920 AssertExpectationsAboutCurrentTab(expected_number_of_frames, |
918 // AssertExpectationsAboutCurrentTab(expected_number_of_frames, | 921 expected_substrings); |
919 // expected_substrings); | 922 } |
920 | 923 |
921 // Save the page. | 924 // Save the page. |
922 base::FilePath full_file_name, dir; | 925 base::FilePath full_file_name, dir; |
923 SaveCurrentTab(url, save_page_type, "save_result", -1, &dir, | 926 SaveCurrentTab(url, save_page_type, "save_result", -1, &dir, |
924 &full_file_name); | 927 &full_file_name); |
925 ASSERT_FALSE(HasFailure()); | 928 ASSERT_FALSE(HasFailure()); |
926 | 929 |
927 // Stop the test server (to make sure the locally saved page | 930 // Stop the test server (to make sure the locally saved page |
928 // is self-contained / won't try to open original resources). | 931 // is self-contained / won't try to open original resources). |
929 ASSERT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete()); | 932 ASSERT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
967 false, // |case_sensitive| | 970 false, // |case_sensitive| |
968 nullptr, nullptr); | 971 nullptr, nullptr); |
969 EXPECT_EQ(0, actual_number_of_errors); | 972 EXPECT_EQ(0, actual_number_of_errors); |
970 } | 973 } |
971 | 974 |
972 static void IncrementInteger(int* i, content::RenderFrameHost* /* unused */) { | 975 static void IncrementInteger(int* i, content::RenderFrameHost* /* unused */) { |
973 (*i)++; | 976 (*i)++; |
974 } | 977 } |
975 }; | 978 }; |
976 | 979 |
977 // TODO(lukasza): Pivot on mhtml-vs-complete-html using test params | 980 // Test coverage for OOPIFs for CompleteHtml (crbug.com/526786) and |
978 // (once all SavePageMultiFrameBrowserTest are enabled). | 981 // MHTML (crbug.com/538766) as well as for redirected iframes saved |
982 // as MHTML (crbug.com/539936). | |
Randy Smith (Not in Mondays)
2015/11/13 22:39:07
I find this comment a bit confusing "as well as fo
| |
983 IN_PROC_BROWSER_TEST_P(SavePageMultiFrameBrowserTest, CrossSite) { | |
984 content::SavePageType save_page_type = GetParam(); | |
979 | 985 |
980 IN_PROC_BROWSER_TEST_F(SavePageMultiFrameBrowserTest, | |
981 CrossSiteFrames_CompleteHtml) { | |
982 std::vector<std::string> expected_substrings{ | 986 std::vector<std::string> expected_substrings{ |
983 "frames-xsite.htm: 896fd88d-a77a-4f46-afd8-24db7d5af9c2", | 987 "frames-xsite.htm: 896fd88d-a77a-4f46-afd8-24db7d5af9c2", |
984 "a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2", | 988 "a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2", |
985 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa", | 989 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa", |
986 }; | 990 }; |
991 | |
987 GURL url( | 992 GURL url( |
988 embedded_test_server()->GetURL("a.com", "/save_page/frames-xsite.htm")); | 993 embedded_test_server()->GetURL("a.com", "/save_page/frames-xsite.htm")); |
989 TestMultiFramePage(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, url, 3, | 994 |
990 expected_substrings); | 995 // TODO(lukasza): crbug.com/538766: Enable CrossSite testing of MHTML. |
996 if (save_page_type == content::SAVE_PAGE_TYPE_AS_MHTML) | |
997 return; | |
998 | |
999 // TODO(lukasza/paulmeyer): crbug.com/457440: Can enable verification | |
1000 // of the original page once find-in-page works for OOP frames. | |
1001 bool skip_verification_of_original_page = true; | |
1002 | |
1003 TestMultiFramePage(save_page_type, url, 3, expected_substrings, | |
1004 skip_verification_of_original_page); | |
991 } | 1005 } |
992 | 1006 |
993 // Test for crbug.com/538766 and crbug.com/539936. | 1007 // Test for crbug.com/553478. |
Randy Smith (Not in Mondays)
2015/11/13 22:39:07
Could you include a line about what the test does
| |
994 // Disabled because both bugs are not yet fixed. | 1008 IN_PROC_BROWSER_TEST_P(SavePageMultiFrameBrowserTest, DISABLED_ObjectElements) { |
995 IN_PROC_BROWSER_TEST_F(SavePageMultiFrameBrowserTest, | 1009 content::SavePageType save_page_type = GetParam(); |
996 DISABLED_CrossSiteFrames_MHTML) { | |
997 std::vector<std::string> expected_substrings{ | |
998 "frames-xsite.htm: 896fd88d-a77a-4f46-afd8-24db7d5af9c2", | |
999 "a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2", | |
1000 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa", | |
1001 }; | |
1002 GURL url( | |
1003 embedded_test_server()->GetURL("a.com", "/save_page/frames-xsite.htm")); | |
1004 TestMultiFramePage(content::SAVE_PAGE_TYPE_AS_MHTML, url, 3, | |
1005 expected_substrings); | |
1006 } | |
1007 | 1010 |
1008 // Test for crbug.com/553478 (complete html part). | |
1009 IN_PROC_BROWSER_TEST_F(SavePageMultiFrameBrowserTest, | |
1010 DISABLED_ObjectElements_CompleteHtml) { | |
1011 // 4 = main frame + iframe + object w/ html doc + object w/ pdf doc | 1011 // 4 = main frame + iframe + object w/ html doc + object w/ pdf doc |
1012 // (svg and png objects do not get a separate frame) | 1012 // (svg and png objects do not get a separate frame) |
1013 int expected_number_of_frames = 4; | 1013 int expected_number_of_frames = 4; |
1014 | |
1015 std::vector<std::string> expected_substrings{ | |
1016 "frames-objects.htm: 8da13db4-a512-4d9b-b1c5-dc1c134234b9", | |
1017 "a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2", | |
1018 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa", | |
1019 }; | |
1020 GURL url( | |
1021 embedded_test_server()->GetURL("a.com", "/save_page/frames-objects.htm")); | |
1022 TestMultiFramePage(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, url, | |
1023 expected_number_of_frames, expected_substrings); | |
1024 } | |
1025 | |
1026 // Test for crbug.com/553478 (mhtml part). | |
1027 // See crbug.com/553478#c3 for some MHTML-specific notes. | |
1028 IN_PROC_BROWSER_TEST_F(SavePageMultiFrameBrowserTest, | |
1029 DISABLED_ObjectElements_MHTML) { | |
1030 // 4 = main frame + iframe + object w/ html doc + object w/ pdf doc | |
1031 // (svg and png objects do not get a separate frame) | |
1032 int expected_number_of_frames = 4; | |
1033 | 1014 |
1034 std::vector<std::string> expected_substrings{ | 1015 std::vector<std::string> expected_substrings{ |
1035 "frames-objects.htm: 8da13db4-a512-4d9b-b1c5-dc1c134234b9", | 1016 "frames-objects.htm: 8da13db4-a512-4d9b-b1c5-dc1c134234b9", |
1036 "a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2", | 1017 "a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2", |
1037 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa", | 1018 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa", |
1038 }; | 1019 }; |
1020 | |
1039 GURL url( | 1021 GURL url( |
1040 embedded_test_server()->GetURL("a.com", "/save_page/frames-objects.htm")); | 1022 embedded_test_server()->GetURL("a.com", "/save_page/frames-objects.htm")); |
1041 TestMultiFramePage(content::SAVE_PAGE_TYPE_AS_MHTML, url, | 1023 |
1042 expected_number_of_frames, expected_substrings); | 1024 TestMultiFramePage(save_page_type, url, expected_number_of_frames, |
1025 expected_substrings); | |
1043 } | 1026 } |
1044 | 1027 |
1045 IN_PROC_BROWSER_TEST_F(SavePageMultiFrameBrowserTest, AboutBlank_CompleteHtml) { | 1028 IN_PROC_BROWSER_TEST_P(SavePageMultiFrameBrowserTest, AboutBlank) { |
1029 content::SavePageType save_page_type = GetParam(); | |
1030 | |
1046 std::vector<std::string> expected_substrings{ | 1031 std::vector<std::string> expected_substrings{ |
1047 "main: acb0609d-eb10-4c26-83e2-ad8afb7b0ff3", | 1032 "main: acb0609d-eb10-4c26-83e2-ad8afb7b0ff3", |
1048 "sub1: b124df3a-d39f-47a1-ae04-5bb5d0bf549e", | 1033 "sub1: b124df3a-d39f-47a1-ae04-5bb5d0bf549e", |
1049 "sub2: 07014068-604d-45ae-884f-a068cfe7bc0a", | 1034 "sub2: 07014068-604d-45ae-884f-a068cfe7bc0a", |
1050 "sub3: 06cc8fcc-c692-4a1a-a10f-1645b746e8f4", | 1035 "sub3: 06cc8fcc-c692-4a1a-a10f-1645b746e8f4", |
1051 }; | 1036 }; |
1037 | |
1052 GURL url(embedded_test_server()->GetURL("a.com", | 1038 GURL url(embedded_test_server()->GetURL("a.com", |
1053 "/save_page/frames-about-blank.htm")); | 1039 "/save_page/frames-about-blank.htm")); |
1054 TestMultiFramePage(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, url, 4, | 1040 |
1055 expected_substrings); | 1041 TestMultiFramePage(save_page_type, url, 4, expected_substrings); |
1056 } | 1042 } |
1057 | 1043 |
1058 IN_PROC_BROWSER_TEST_F(SavePageMultiFrameBrowserTest, AboutBlank_MHTML) { | 1044 // Test for crbug.com/554666. |
1045 IN_PROC_BROWSER_TEST_P(SavePageMultiFrameBrowserTest, NestedFrames) { | |
1046 content::SavePageType save_page_type = GetParam(); | |
1047 | |
1059 std::vector<std::string> expected_substrings{ | 1048 std::vector<std::string> expected_substrings{ |
1060 "main: acb0609d-eb10-4c26-83e2-ad8afb7b0ff3", | 1049 "frames-nested.htm: 4388232f-8d45-4d2e-9807-721b381be153", |
1061 "sub1: b124df3a-d39f-47a1-ae04-5bb5d0bf549e", | 1050 "frames-nested2.htm: 6d23dc47-f283-4977-96ec-66bcf72301a4", |
1062 "sub2: 07014068-604d-45ae-884f-a068cfe7bc0a", | 1051 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa", |
1063 "sub3: 06cc8fcc-c692-4a1a-a10f-1645b746e8f4", | |
1064 }; | 1052 }; |
1065 GURL url(embedded_test_server()->GetURL("a.com", | 1053 |
1066 "/save_page/frames-about-blank.htm")); | 1054 GURL url( |
1067 TestMultiFramePage(content::SAVE_PAGE_TYPE_AS_MHTML, url, 4, | 1055 embedded_test_server()->GetURL("a.com", "/save_page/frames-nested.htm")); |
1068 expected_substrings); | 1056 |
1057 TestMultiFramePage(save_page_type, url, 3, expected_substrings); | |
1069 } | 1058 } |
1070 | 1059 |
1060 INSTANTIATE_TEST_CASE_P( | |
1061 , | |
Randy Smith (Not in Mondays)
2015/11/13 22:39:07
nit, suggestion: I'm no expert in the use of INSTA
| |
1062 SavePageMultiFrameBrowserTest, | |
1063 ::testing::Values(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, | |
1064 content::SAVE_PAGE_TYPE_AS_MHTML)); | |
1065 | |
1071 } // namespace | 1066 } // namespace |
OLD | NEW |