| 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> |
| 6 #include <vector> |
| 7 |
| 5 #include "base/bind.h" | 8 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 7 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 9 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
| 11 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 12 #include "base/prefs/pref_member.h" | 15 #include "base/prefs/pref_member.h" |
| 13 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
| 14 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
| (...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 (*i)++; | 992 (*i)++; |
| 990 } | 993 } |
| 991 }; | 994 }; |
| 992 | 995 |
| 993 // Test coverage for OOPIFs for CompleteHtml (crbug.com/526786) and | 996 // Test coverage for OOPIFs for CompleteHtml (crbug.com/526786) and |
| 994 // MHTML (crbug.com/538766) as well as for redirected iframes saved | 997 // MHTML (crbug.com/538766) as well as for redirected iframes saved |
| 995 // as MHTML (crbug.com/539936). | 998 // as MHTML (crbug.com/539936). |
| 996 IN_PROC_BROWSER_TEST_P(SavePageMultiFrameBrowserTest, CrossSite) { | 999 IN_PROC_BROWSER_TEST_P(SavePageMultiFrameBrowserTest, CrossSite) { |
| 997 content::SavePageType save_page_type = GetParam(); | 1000 content::SavePageType save_page_type = GetParam(); |
| 998 | 1001 |
| 999 std::vector<std::string> expected_substrings{ | 1002 std::string arr[] = { |
| 1000 "frames-xsite.htm: 896fd88d-a77a-4f46-afd8-24db7d5af9c2", | 1003 "frames-xsite.htm: 896fd88d-a77a-4f46-afd8-24db7d5af9c2", |
| 1001 "a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2", | 1004 "a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2", |
| 1002 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa", | 1005 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa", |
| 1003 }; | 1006 }; |
| 1007 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr)); |
| 1004 | 1008 |
| 1005 GURL url( | 1009 GURL url( |
| 1006 embedded_test_server()->GetURL("a.com", "/save_page/frames-xsite.htm")); | 1010 embedded_test_server()->GetURL("a.com", "/save_page/frames-xsite.htm")); |
| 1007 | 1011 |
| 1008 // TODO(lukasza): crbug.com/538766: Enable CrossSite testing of MHTML. | 1012 // TODO(lukasza): crbug.com/538766: Enable CrossSite testing of MHTML. |
| 1009 if (save_page_type == content::SAVE_PAGE_TYPE_AS_MHTML) | 1013 if (save_page_type == content::SAVE_PAGE_TYPE_AS_MHTML) |
| 1010 return; | 1014 return; |
| 1011 | 1015 |
| 1012 // TODO(lukasza/paulmeyer): crbug.com/457440: Can enable verification | 1016 // TODO(lukasza/paulmeyer): crbug.com/457440: Can enable verification |
| 1013 // of the original page once find-in-page works for OOP frames. | 1017 // of the original page once find-in-page works for OOP frames. |
| 1014 bool skip_verification_of_original_page = true; | 1018 bool skip_verification_of_original_page = true; |
| 1015 | 1019 |
| 1016 TestMultiFramePage(save_page_type, url, 3, expected_substrings, | 1020 TestMultiFramePage(save_page_type, url, 3, expected_substrings, |
| 1017 skip_verification_of_original_page); | 1021 skip_verification_of_original_page); |
| 1018 } | 1022 } |
| 1019 | 1023 |
| 1020 // Test for crbug.com/553478. | 1024 // Test for crbug.com/553478. |
| 1021 IN_PROC_BROWSER_TEST_P(SavePageMultiFrameBrowserTest, ObjectElements) { | 1025 IN_PROC_BROWSER_TEST_P(SavePageMultiFrameBrowserTest, ObjectElements) { |
| 1022 content::SavePageType save_page_type = GetParam(); | 1026 content::SavePageType save_page_type = GetParam(); |
| 1023 | 1027 |
| 1024 // 4 = main frame + iframe + object w/ html doc + object w/ pdf doc | 1028 // 4 = main frame + iframe + object w/ html doc + object w/ pdf doc |
| 1025 // (svg and png objects do not get a separate frame) | 1029 // (svg and png objects do not get a separate frame) |
| 1026 int expected_number_of_frames = 6; | 1030 int expected_number_of_frames = 6; |
| 1027 | 1031 |
| 1028 std::vector<std::string> expected_substrings{ | 1032 std::string arr[] = { |
| 1029 "frames-objects.htm: 8da13db4-a512-4d9b-b1c5-dc1c134234b9", | 1033 "frames-objects.htm: 8da13db4-a512-4d9b-b1c5-dc1c134234b9", |
| 1030 "a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2", | 1034 "a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2", |
| 1031 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa", | 1035 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa", |
| 1032 "frames-nested.htm: 4388232f-8d45-4d2e-9807-721b381be153", | 1036 "frames-nested.htm: 4388232f-8d45-4d2e-9807-721b381be153", |
| 1033 "frames-nested2.htm: 6d23dc47-f283-4977-96ec-66bcf72301a4", | 1037 "frames-nested2.htm: 6d23dc47-f283-4977-96ec-66bcf72301a4", |
| 1034 }; | 1038 }; |
| 1039 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr)); |
| 1035 | 1040 |
| 1036 GURL url( | 1041 GURL url( |
| 1037 embedded_test_server()->GetURL("a.com", "/save_page/frames-objects.htm")); | 1042 embedded_test_server()->GetURL("a.com", "/save_page/frames-objects.htm")); |
| 1038 | 1043 |
| 1039 // TODO(lukasza): crbug.com/553478: Enable <object> testing of MHTML. | 1044 // TODO(lukasza): crbug.com/553478: Enable <object> testing of MHTML. |
| 1040 if (save_page_type == content::SAVE_PAGE_TYPE_AS_MHTML) | 1045 if (save_page_type == content::SAVE_PAGE_TYPE_AS_MHTML) |
| 1041 return; | 1046 return; |
| 1042 | 1047 |
| 1043 TestMultiFramePage(save_page_type, url, expected_number_of_frames, | 1048 TestMultiFramePage(save_page_type, url, expected_number_of_frames, |
| 1044 expected_substrings); | 1049 expected_substrings); |
| 1045 } | 1050 } |
| 1046 | 1051 |
| 1047 IN_PROC_BROWSER_TEST_P(SavePageMultiFrameBrowserTest, AboutBlank) { | 1052 IN_PROC_BROWSER_TEST_P(SavePageMultiFrameBrowserTest, AboutBlank) { |
| 1048 content::SavePageType save_page_type = GetParam(); | 1053 content::SavePageType save_page_type = GetParam(); |
| 1049 | 1054 |
| 1050 std::vector<std::string> expected_substrings{ | 1055 std::string arr[] = { |
| 1051 "main: acb0609d-eb10-4c26-83e2-ad8afb7b0ff3", | 1056 "main: acb0609d-eb10-4c26-83e2-ad8afb7b0ff3", |
| 1052 "sub1: b124df3a-d39f-47a1-ae04-5bb5d0bf549e", | 1057 "sub1: b124df3a-d39f-47a1-ae04-5bb5d0bf549e", |
| 1053 "sub2: 07014068-604d-45ae-884f-a068cfe7bc0a", | 1058 "sub2: 07014068-604d-45ae-884f-a068cfe7bc0a", |
| 1054 "sub3: 06cc8fcc-c692-4a1a-a10f-1645b746e8f4", | 1059 "sub3: 06cc8fcc-c692-4a1a-a10f-1645b746e8f4", |
| 1055 }; | 1060 }; |
| 1061 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr)); |
| 1056 | 1062 |
| 1057 GURL url(embedded_test_server()->GetURL("a.com", | 1063 GURL url(embedded_test_server()->GetURL("a.com", |
| 1058 "/save_page/frames-about-blank.htm")); | 1064 "/save_page/frames-about-blank.htm")); |
| 1059 | 1065 |
| 1060 TestMultiFramePage(save_page_type, url, 4, expected_substrings); | 1066 TestMultiFramePage(save_page_type, url, 4, expected_substrings); |
| 1061 } | 1067 } |
| 1062 | 1068 |
| 1063 // Test for crbug.com/554666. | 1069 // Test for crbug.com/554666. |
| 1064 IN_PROC_BROWSER_TEST_P(SavePageMultiFrameBrowserTest, NestedFrames) { | 1070 IN_PROC_BROWSER_TEST_P(SavePageMultiFrameBrowserTest, NestedFrames) { |
| 1065 content::SavePageType save_page_type = GetParam(); | 1071 content::SavePageType save_page_type = GetParam(); |
| 1066 | 1072 |
| 1067 std::vector<std::string> expected_substrings{ | 1073 std::string arr[] = { |
| 1068 "frames-nested.htm: 4388232f-8d45-4d2e-9807-721b381be153", | 1074 "frames-nested.htm: 4388232f-8d45-4d2e-9807-721b381be153", |
| 1069 "frames-nested2.htm: 6d23dc47-f283-4977-96ec-66bcf72301a4", | 1075 "frames-nested2.htm: 6d23dc47-f283-4977-96ec-66bcf72301a4", |
| 1070 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa", | 1076 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa", |
| 1071 }; | 1077 }; |
| 1078 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr)); |
| 1072 | 1079 |
| 1073 GURL url( | 1080 GURL url( |
| 1074 embedded_test_server()->GetURL("a.com", "/save_page/frames-nested.htm")); | 1081 embedded_test_server()->GetURL("a.com", "/save_page/frames-nested.htm")); |
| 1075 | 1082 |
| 1076 TestMultiFramePage(save_page_type, url, 3, expected_substrings); | 1083 TestMultiFramePage(save_page_type, url, 3, expected_substrings); |
| 1077 } | 1084 } |
| 1078 | 1085 |
| 1086 // Test for crbug.com/106364 and crbug.com/538188. |
| 1087 // Test frames have the same uri ... |
| 1088 // subframe1 and subframe2 - both have src=b.htm |
| 1089 // subframe3 and subframe4 - about:blank (no src, only srcdoc attribute). |
| 1090 // ... but different content (generated by main frame's javascript). |
| 1091 IN_PROC_BROWSER_TEST_P(SavePageMultiFrameBrowserTest, RuntimeChanges) { |
| 1092 content::SavePageType save_page_type = GetParam(); |
| 1093 |
| 1094 std::string arr[] = { |
| 1095 "frames-runtime-changes.htm: 4388232f-8d45-4d2e-9807-721b381be153", |
| 1096 "subframe1: 21595339-61fc-4854-b6df-0668328ea263", |
| 1097 "subframe2: adf55719-15e7-45be-9eda-d12fe782a1bd", |
| 1098 "subframe3: 50e294bf-3a5b-499d-8772-651ead26952f", |
| 1099 "subframe4: e0ea9289-7467-4d32-ba5c-c604e8d84cb7", |
| 1100 }; |
| 1101 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr)); |
| 1102 |
| 1103 // TODO(lukasza): crbug.com/106364: Fix complete-html mode as well. |
| 1104 if (save_page_type == content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML) |
| 1105 return; |
| 1106 |
| 1107 GURL url(embedded_test_server()->GetURL( |
| 1108 "a.com", "/save_page/frames-runtime-changes.htm?do_runtime_changes=1")); |
| 1109 |
| 1110 TestMultiFramePage(save_page_type, url, 5, expected_substrings); |
| 1111 } |
| 1112 |
| 1079 INSTANTIATE_TEST_CASE_P( | 1113 INSTANTIATE_TEST_CASE_P( |
| 1080 , | 1114 SaveType, |
| 1081 SavePageMultiFrameBrowserTest, | 1115 SavePageMultiFrameBrowserTest, |
| 1082 ::testing::Values(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, | 1116 ::testing::Values(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, |
| 1083 content::SAVE_PAGE_TYPE_AS_MHTML)); | 1117 content::SAVE_PAGE_TYPE_AS_MHTML)); |
| 1084 | 1118 |
| 1085 } // namespace | 1119 } // namespace |
| OLD | NEW |