Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(493)

Side by Side Diff: chrome/browser/download/save_page_browsertest.cc

Issue 2155333002: Test for auth dialog appearing during save-page-as. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Prevent prompts during save-page-as. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/test/data/save_page/broken-image.htm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 15 matching lines...) Expand all
26 #include "chrome/browser/download/download_history.h" 26 #include "chrome/browser/download/download_history.h"
27 #include "chrome/browser/download/download_prefs.h" 27 #include "chrome/browser/download/download_prefs.h"
28 #include "chrome/browser/download/download_service.h" 28 #include "chrome/browser/download/download_service.h"
29 #include "chrome/browser/download/download_service_factory.h" 29 #include "chrome/browser/download/download_service_factory.h"
30 #include "chrome/browser/download/save_package_file_picker.h" 30 #include "chrome/browser/download/save_package_file_picker.h"
31 #include "chrome/browser/net/url_request_mock_util.h" 31 #include "chrome/browser/net/url_request_mock_util.h"
32 #include "chrome/browser/profiles/profile.h" 32 #include "chrome/browser/profiles/profile.h"
33 #include "chrome/browser/ui/browser.h" 33 #include "chrome/browser/ui/browser.h"
34 #include "chrome/browser/ui/browser_commands.h" 34 #include "chrome/browser/ui/browser_commands.h"
35 #include "chrome/browser/ui/browser_window.h" 35 #include "chrome/browser/ui/browser_window.h"
36 #include "chrome/browser/ui/login/login_handler.h"
37 #include "chrome/browser/ui/login/login_handler_test_utils.h"
36 #include "chrome/browser/ui/tabs/tab_strip_model.h" 38 #include "chrome/browser/ui/tabs/tab_strip_model.h"
37 #include "chrome/common/chrome_paths.h" 39 #include "chrome/common/chrome_paths.h"
38 #include "chrome/common/chrome_switches.h" 40 #include "chrome/common/chrome_switches.h"
39 #include "chrome/common/pref_names.h" 41 #include "chrome/common/pref_names.h"
40 #include "chrome/common/url_constants.h" 42 #include "chrome/common/url_constants.h"
41 #include "chrome/test/base/in_process_browser_test.h" 43 #include "chrome/test/base/in_process_browser_test.h"
42 #include "chrome/test/base/ui_test_utils.h" 44 #include "chrome/test/base/ui_test_utils.h"
43 #include "components/history/core/browser/download_constants.h" 45 #include "components/history/core/browser/download_constants.h"
44 #include "components/history/core/browser/download_row.h" 46 #include "components/history/core/browser/download_row.h"
45 #include "components/prefs/pref_member.h" 47 #include "components/prefs/pref_member.h"
46 #include "components/prefs/pref_service.h" 48 #include "components/prefs/pref_service.h"
47 #include "content/public/browser/download_item.h" 49 #include "content/public/browser/download_item.h"
48 #include "content/public/browser/download_manager.h" 50 #include "content/public/browser/download_manager.h"
51 #include "content/public/browser/navigation_controller.h"
49 #include "content/public/browser/notification_service.h" 52 #include "content/public/browser/notification_service.h"
50 #include "content/public/browser/notification_types.h" 53 #include "content/public/browser/notification_types.h"
51 #include "content/public/browser/render_frame_host.h" 54 #include "content/public/browser/render_frame_host.h"
52 #include "content/public/browser/render_process_host.h" 55 #include "content/public/browser/render_process_host.h"
53 #include "content/public/browser/web_contents.h" 56 #include "content/public/browser/web_contents.h"
54 #include "content/public/common/content_switches.h" 57 #include "content/public/common/content_switches.h"
58 #include "content/public/common/referrer.h"
55 #include "content/public/common/url_constants.h" 59 #include "content/public/common/url_constants.h"
56 #include "content/public/test/browser_test_utils.h" 60 #include "content/public/test/browser_test_utils.h"
61 #include "content/public/test/test_navigation_observer.h"
57 #include "content/public/test/test_utils.h" 62 #include "content/public/test/test_utils.h"
58 #include "net/base/filename_util.h" 63 #include "net/base/filename_util.h"
59 #include "net/dns/mock_host_resolver.h" 64 #include "net/dns/mock_host_resolver.h"
60 #include "net/test/embedded_test_server/embedded_test_server.h" 65 #include "net/test/embedded_test_server/embedded_test_server.h"
61 #include "net/test/url_request/url_request_mock_http_job.h" 66 #include "net/test/url_request/url_request_mock_http_job.h"
62 #include "testing/gmock/include/gmock/gmock.h" 67 #include "testing/gmock/include/gmock/gmock.h"
63 #include "testing/gtest/include/gtest/gtest.h" 68 #include "testing/gtest/include/gtest/gtest.h"
64 69
65 using content::BrowserContext; 70 using content::BrowserContext;
66 using content::BrowserThread; 71 using content::BrowserThread;
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 EXPECT_TRUE(base::DirectoryExists(dir)); 982 EXPECT_TRUE(base::DirectoryExists(dir));
978 EXPECT_TRUE(base::PathExists(full_file_name)); 983 EXPECT_TRUE(base::PathExists(full_file_name));
979 } 984 }
980 985
981 // Test suite that verifies that the frame tree "looks" the same before 986 // Test suite that verifies that the frame tree "looks" the same before
982 // and after a save-page-as. 987 // and after a save-page-as.
983 class SavePageOriginalVsSavedComparisonTest 988 class SavePageOriginalVsSavedComparisonTest
984 : public SavePageSitePerProcessBrowserTest, 989 : public SavePageSitePerProcessBrowserTest,
985 public ::testing::WithParamInterface<content::SavePageType> { 990 public ::testing::WithParamInterface<content::SavePageType> {
986 protected: 991 protected:
987 void TestOriginalVsSavedPage( 992 void TestCurrentVsSavedPage(
988 content::SavePageType save_page_type, 993 content::SavePageType save_page_type,
989 const GURL& url,
990 int expected_number_of_frames, 994 int expected_number_of_frames,
991 const std::vector<std::string>& expected_substrings) { 995 const std::vector<std::string>& expected_substrings) {
992 // Navigate to the test page and verify if test expectations 996 // Verify if test expectations are met on the current page (this is mostly
993 // are met (this is mostly a sanity check - a failure to meet 997 // a sanity check - a failure to meet expectations would probably mean that
994 // expectations would probably mean that there is a test bug 998 // there is a test bug (i.e. that we got called with wrong expected_foo
995 // (i.e. that we got called with wrong expected_foo argument). 999 // argument).
996 ui_test_utils::NavigateToURL(browser(), url); 1000 GURL original_url = GetCurrentTab(browser())->GetLastCommittedURL();
997 DLOG(INFO) << "Verifying test expectations for original page... : " 1001 DLOG(INFO) << "Verifying test expectations for original page... : "
998 << GetCurrentTab(browser())->GetLastCommittedURL(); 1002 << original_url;
999 AssertExpectationsAboutCurrentTab(expected_number_of_frames, 1003 AssertExpectationsAboutCurrentTab(expected_number_of_frames,
1000 expected_substrings); 1004 expected_substrings);
1001 1005
1002 // Save the page. 1006 // Save the page.
1003 base::FilePath full_file_name, dir; 1007 base::FilePath full_file_name, dir;
1004 SaveCurrentTab(url, save_page_type, "save_result", -1, &dir, 1008 SaveCurrentTab(original_url, save_page_type, "save_result", -1, &dir,
1005 &full_file_name); 1009 &full_file_name);
1006 ASSERT_FALSE(HasFailure()); 1010 ASSERT_FALSE(HasFailure());
1007 1011
1008 // Stop the test server (to make sure the locally saved page 1012 // Stop the test server (to make sure the locally saved page
1009 // is self-contained / won't try to open original resources). 1013 // is self-contained / won't try to open original resources).
1010 ASSERT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete()); 1014 ASSERT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete());
1011 1015
1012 // Open the saved page and verify if test expectations are 1016 // Open the saved page and verify if test expectations are
1013 // met (i.e. if the same expectations are met for "after" 1017 // met (i.e. if the same expectations are met for "after"
1014 // [saved version of the page] as for the "before" 1018 // [saved version of the page] as for the "before"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 std::string arr[] = { 1082 std::string arr[] = {
1079 "frames-xsite.htm: 896fd88d-a77a-4f46-afd8-24db7d5af9c2", 1083 "frames-xsite.htm: 896fd88d-a77a-4f46-afd8-24db7d5af9c2",
1080 "a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2", 1084 "a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2",
1081 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa", 1085 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa",
1082 }; 1086 };
1083 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr)); 1087 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr));
1084 1088
1085 GURL url( 1089 GURL url(
1086 embedded_test_server()->GetURL("a.com", "/save_page/frames-xsite.htm")); 1090 embedded_test_server()->GetURL("a.com", "/save_page/frames-xsite.htm"));
1087 1091
1088 TestOriginalVsSavedPage(save_page_type, url, 3, expected_substrings); 1092 ui_test_utils::NavigateToURL(browser(), url);
1093 TestCurrentVsSavedPage(save_page_type, 3, expected_substrings);
1089 } 1094 }
1090 1095
1091 // Test compares original-vs-saved for a page with <object> elements. 1096 // Test compares original-vs-saved for a page with <object> elements.
1092 // (see crbug.com/553478). 1097 // (see crbug.com/553478).
1093 IN_PROC_BROWSER_TEST_P(SavePageOriginalVsSavedComparisonTest, ObjectElements) { 1098 IN_PROC_BROWSER_TEST_P(SavePageOriginalVsSavedComparisonTest, ObjectElements) {
1094 content::SavePageType save_page_type = GetParam(); 1099 content::SavePageType save_page_type = GetParam();
1095 1100
1096 // 4 = main frame + iframe + object w/ html doc + object w/ pdf doc 1101 // 4 = main frame + iframe + object w/ html doc + object w/ pdf doc
1097 // (svg and png objects do not get a separate frame) 1102 // (svg and png objects do not get a separate frame)
1098 int expected_number_of_frames = 6; 1103 int expected_number_of_frames = 6;
1099 1104
1100 std::string arr[] = { 1105 std::string arr[] = {
1101 "frames-objects.htm: 8da13db4-a512-4d9b-b1c5-dc1c134234b9", 1106 "frames-objects.htm: 8da13db4-a512-4d9b-b1c5-dc1c134234b9",
1102 "a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2", 1107 "a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2",
1103 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa", 1108 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa",
1104 "frames-nested.htm: 4388232f-8d45-4d2e-9807-721b381be153", 1109 "frames-nested.htm: 4388232f-8d45-4d2e-9807-721b381be153",
1105 "frames-nested2.htm: 6d23dc47-f283-4977-96ec-66bcf72301a4", 1110 "frames-nested2.htm: 6d23dc47-f283-4977-96ec-66bcf72301a4",
1106 }; 1111 };
1107 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr)); 1112 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr));
1108 1113
1109 GURL url(
1110 embedded_test_server()->GetURL("a.com", "/save_page/frames-objects.htm"));
1111
1112 // TODO(lukasza): crbug.com/553478: Enable <object> testing of MHTML. 1114 // TODO(lukasza): crbug.com/553478: Enable <object> testing of MHTML.
1113 if (save_page_type == content::SAVE_PAGE_TYPE_AS_MHTML) 1115 if (save_page_type == content::SAVE_PAGE_TYPE_AS_MHTML)
1114 return; 1116 return;
1115 1117
1116 TestOriginalVsSavedPage(save_page_type, url, expected_number_of_frames, 1118 GURL url(
1117 expected_substrings); 1119 embedded_test_server()->GetURL("a.com", "/save_page/frames-objects.htm"));
1120 ui_test_utils::NavigateToURL(browser(), url);
1121 TestCurrentVsSavedPage(save_page_type, expected_number_of_frames,
1122 expected_substrings);
1118 } 1123 }
1119 1124
1120 // Test compares original-vs-saved for a page with frames at about:blank uri. 1125 // Test compares original-vs-saved for a page with frames at about:blank uri.
1121 // This tests handling of iframe elements without src attribute (only with 1126 // This tests handling of iframe elements without src attribute (only with
1122 // srcdoc attribute) and how they get saved / cross-referenced. 1127 // srcdoc attribute) and how they get saved / cross-referenced.
1123 IN_PROC_BROWSER_TEST_P(SavePageOriginalVsSavedComparisonTest, AboutBlank) { 1128 IN_PROC_BROWSER_TEST_P(SavePageOriginalVsSavedComparisonTest, AboutBlank) {
1124 content::SavePageType save_page_type = GetParam(); 1129 content::SavePageType save_page_type = GetParam();
1125 1130
1126 std::string arr[] = { 1131 std::string arr[] = {
1127 "main: acb0609d-eb10-4c26-83e2-ad8afb7b0ff3", 1132 "main: acb0609d-eb10-4c26-83e2-ad8afb7b0ff3",
1128 "sub1: b124df3a-d39f-47a1-ae04-5bb5d0bf549e", 1133 "sub1: b124df3a-d39f-47a1-ae04-5bb5d0bf549e",
1129 "sub2: 07014068-604d-45ae-884f-a068cfe7bc0a", 1134 "sub2: 07014068-604d-45ae-884f-a068cfe7bc0a",
1130 "sub3: 06cc8fcc-c692-4a1a-a10f-1645b746e8f4", 1135 "sub3: 06cc8fcc-c692-4a1a-a10f-1645b746e8f4",
1131 }; 1136 };
1132 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr)); 1137 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr));
1133 1138
1134 GURL url(embedded_test_server()->GetURL("a.com", 1139 GURL url(embedded_test_server()->GetURL("a.com",
1135 "/save_page/frames-about-blank.htm")); 1140 "/save_page/frames-about-blank.htm"));
1136 1141 ui_test_utils::NavigateToURL(browser(), url);
1137 TestOriginalVsSavedPage(save_page_type, url, 4, expected_substrings); 1142 TestCurrentVsSavedPage(save_page_type, 4, expected_substrings);
1138 } 1143 }
1139 1144
1140 // Test compares original-vs-saved for a page with nested frames. 1145 // Test compares original-vs-saved for a page with nested frames.
1141 // Two levels of nesting are especially good for verifying correct 1146 // Two levels of nesting are especially good for verifying correct
1142 // link rewriting for subframes-vs-main-frame (see crbug.com/554666). 1147 // link rewriting for subframes-vs-main-frame (see crbug.com/554666).
1143 IN_PROC_BROWSER_TEST_P(SavePageOriginalVsSavedComparisonTest, NestedFrames) { 1148 IN_PROC_BROWSER_TEST_P(SavePageOriginalVsSavedComparisonTest, NestedFrames) {
1144 content::SavePageType save_page_type = GetParam(); 1149 content::SavePageType save_page_type = GetParam();
1145 1150
1146 std::string arr[] = { 1151 std::string arr[] = {
1147 "frames-nested.htm: 4388232f-8d45-4d2e-9807-721b381be153", 1152 "frames-nested.htm: 4388232f-8d45-4d2e-9807-721b381be153",
1148 "frames-nested2.htm: 6d23dc47-f283-4977-96ec-66bcf72301a4", 1153 "frames-nested2.htm: 6d23dc47-f283-4977-96ec-66bcf72301a4",
1149 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa", 1154 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa",
1150 }; 1155 };
1151 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr)); 1156 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr));
1152 1157
1153 GURL url( 1158 GURL url(
1154 embedded_test_server()->GetURL("a.com", "/save_page/frames-nested.htm")); 1159 embedded_test_server()->GetURL("a.com", "/save_page/frames-nested.htm"));
1155 1160 ui_test_utils::NavigateToURL(browser(), url);
1156 TestOriginalVsSavedPage(save_page_type, url, 3, expected_substrings); 1161 TestCurrentVsSavedPage(save_page_type, 3, expected_substrings);
1157 } 1162 }
1158 1163
1159 // Test for crbug.com/106364 and crbug.com/538188. 1164 // Test for crbug.com/106364 and crbug.com/538188.
1160 // Test frames have the same uri ... 1165 // Test frames have the same uri ...
1161 // subframe1 and subframe2 - both have src=b.htm 1166 // subframe1 and subframe2 - both have src=b.htm
1162 // subframe3 and subframe4 - about:blank (no src, only srcdoc attribute). 1167 // subframe3 and subframe4 - about:blank (no src, only srcdoc attribute).
1163 // ... but different content (generated by main frame's javascript). 1168 // ... but different content (generated by main frame's javascript).
1164 IN_PROC_BROWSER_TEST_P(SavePageOriginalVsSavedComparisonTest, RuntimeChanges) { 1169 IN_PROC_BROWSER_TEST_P(SavePageOriginalVsSavedComparisonTest, RuntimeChanges) {
1165 content::SavePageType save_page_type = GetParam(); 1170 content::SavePageType save_page_type = GetParam();
1166 1171
1167 std::string arr[] = { 1172 std::string arr[] = {
1168 "frames-runtime-changes.htm: 4388232f-8d45-4d2e-9807-721b381be153", 1173 "frames-runtime-changes.htm: 4388232f-8d45-4d2e-9807-721b381be153",
1169 "subframe1: 21595339-61fc-4854-b6df-0668328ea263", 1174 "subframe1: 21595339-61fc-4854-b6df-0668328ea263",
1170 "subframe2: adf55719-15e7-45be-9eda-d12fe782a1bd", 1175 "subframe2: adf55719-15e7-45be-9eda-d12fe782a1bd",
1171 "subframe3: 50e294bf-3a5b-499d-8772-651ead26952f", 1176 "subframe3: 50e294bf-3a5b-499d-8772-651ead26952f",
1172 "subframe4: e0ea9289-7467-4d32-ba5c-c604e8d84cb7", 1177 "subframe4: e0ea9289-7467-4d32-ba5c-c604e8d84cb7",
1173 }; 1178 };
1174 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr)); 1179 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr));
1175 1180
1176 GURL url(embedded_test_server()->GetURL( 1181 GURL url(embedded_test_server()->GetURL(
1177 "a.com", "/save_page/frames-runtime-changes.htm?do_runtime_changes=1")); 1182 "a.com", "/save_page/frames-runtime-changes.htm?do_runtime_changes=1"));
1178 1183 ui_test_utils::NavigateToURL(browser(), url);
1179 TestOriginalVsSavedPage(save_page_type, url, 5, expected_substrings); 1184 TestCurrentVsSavedPage(save_page_type, 5, expected_substrings);
1180 } 1185 }
1181 1186
1182 // Test for saving frames with various encodings: 1187 // Test for saving frames with various encodings:
1183 // - iso-8859-2: encoding declared via <meta> element 1188 // - iso-8859-2: encoding declared via <meta> element
1184 // - utf16-le-bom.htm, utf16-be-bom.htm: encoding detected via BOM 1189 // - utf16-le-bom.htm, utf16-be-bom.htm: encoding detected via BOM
1185 // - utf16-le-nobom.htm, utf16-le-nobom.htm, utf32.htm - encoding declared via 1190 // - utf16-le-nobom.htm, utf16-le-nobom.htm, utf32.htm - encoding declared via
1186 // mocked http headers 1191 // mocked http headers
1187 IN_PROC_BROWSER_TEST_P(SavePageOriginalVsSavedComparisonTest, Encoding) { 1192 IN_PROC_BROWSER_TEST_P(SavePageOriginalVsSavedComparisonTest, Encoding) {
1188 content::SavePageType save_page_type = GetParam(); 1193 content::SavePageType save_page_type = GetParam();
1189 1194
1190 std::string arr[] = { 1195 std::string arr[] = {
1191 "frames-encodings.htm: f53295dd-a95b-4b32-85f5-b6e15377fb20", 1196 "frames-encodings.htm: f53295dd-a95b-4b32-85f5-b6e15377fb20",
1192 "iso-8859-2.htm: Za\xc5\xbc\xc3\xb3\xc5\x82\xc4\x87 " 1197 "iso-8859-2.htm: Za\xc5\xbc\xc3\xb3\xc5\x82\xc4\x87 "
1193 "g\xc4\x99\xc5\x9bl\xc4\x85 ja\xc5\xba\xc5\x84", 1198 "g\xc4\x99\xc5\x9bl\xc4\x85 ja\xc5\xba\xc5\x84",
1194 "utf16-le-nobom.htm: Za\xc5\xbc\xc3\xb3\xc5\x82\xc4\x87 " 1199 "utf16-le-nobom.htm: Za\xc5\xbc\xc3\xb3\xc5\x82\xc4\x87 "
1195 "g\xc4\x99\xc5\x9bl\xc4\x85 ja\xc5\xba\xc5\x84", 1200 "g\xc4\x99\xc5\x9bl\xc4\x85 ja\xc5\xba\xc5\x84",
1196 "utf16-le-bom.htm: Za\xc5\xbc\xc3\xb3\xc5\x82\xc4\x87 " 1201 "utf16-le-bom.htm: Za\xc5\xbc\xc3\xb3\xc5\x82\xc4\x87 "
1197 "g\xc4\x99\xc5\x9bl\xc4\x85 ja\xc5\xba\xc5\x84", 1202 "g\xc4\x99\xc5\x9bl\xc4\x85 ja\xc5\xba\xc5\x84",
1198 "utf16-be-nobom.htm: Za\xc5\xbc\xc3\xb3\xc5\x82\xc4\x87 " 1203 "utf16-be-nobom.htm: Za\xc5\xbc\xc3\xb3\xc5\x82\xc4\x87 "
1199 "g\xc4\x99\xc5\x9bl\xc4\x85 ja\xc5\xba\xc5\x84", 1204 "g\xc4\x99\xc5\x9bl\xc4\x85 ja\xc5\xba\xc5\x84",
1200 "utf16-be-bom.htm: Za\xc5\xbc\xc3\xb3\xc5\x82\xc4\x87 " 1205 "utf16-be-bom.htm: Za\xc5\xbc\xc3\xb3\xc5\x82\xc4\x87 "
1201 "g\xc4\x99\xc5\x9bl\xc4\x85 ja\xc5\xba\xc5\x84", 1206 "g\xc4\x99\xc5\x9bl\xc4\x85 ja\xc5\xba\xc5\x84",
1202 "utf32.htm: Za\xc5\xbc\xc3\xb3\xc5\x82\xc4\x87 " 1207 "utf32.htm: Za\xc5\xbc\xc3\xb3\xc5\x82\xc4\x87 "
1203 "g\xc4\x99\xc5\x9bl\xc4\x85 ja\xc5\xba\xc5\x84", 1208 "g\xc4\x99\xc5\x9bl\xc4\x85 ja\xc5\xba\xc5\x84",
1204 }; 1209 };
1205 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr)); 1210 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr));
1206 1211
1207 GURL url(embedded_test_server()->GetURL("a.com",
1208 "/save_page/frames-encodings.htm"));
1209
1210 // TODO(lukasza): crbug.com/541699: MHTML needs to handle multi-byte encodings 1212 // TODO(lukasza): crbug.com/541699: MHTML needs to handle multi-byte encodings
1211 // by either: 1213 // by either:
1212 // 1. Continuing to preserve the original encoding, but starting to round-trip 1214 // 1. Continuing to preserve the original encoding, but starting to round-trip
1213 // the encoding declaration (in Content-Type MIME/MHTML header?) 1215 // the encoding declaration (in Content-Type MIME/MHTML header?)
1214 // 2. Saving html docs in UTF8. 1216 // 2. Saving html docs in UTF8.
1215 // 3. Saving the BOM (not sure if this will help for all cases though). 1217 // 3. Saving the BOM (not sure if this will help for all cases though).
1216 if (save_page_type == content::SAVE_PAGE_TYPE_AS_MHTML) 1218 if (save_page_type == content::SAVE_PAGE_TYPE_AS_MHTML)
1217 return; 1219 return;
1218 1220
1219 TestOriginalVsSavedPage(save_page_type, url, 7, expected_substrings); 1221 GURL url(embedded_test_server()->GetURL("a.com",
1222 "/save_page/frames-encodings.htm"));
1223 ui_test_utils::NavigateToURL(browser(), url);
1224 TestCurrentVsSavedPage(save_page_type, 7, expected_substrings);
1220 } 1225 }
1221 1226
1222 // Test for saving style element and attribute (see also crbug.com/568293). 1227 // Test for saving style element and attribute (see also crbug.com/568293).
1223 IN_PROC_BROWSER_TEST_P(SavePageOriginalVsSavedComparisonTest, Style) { 1228 IN_PROC_BROWSER_TEST_P(SavePageOriginalVsSavedComparisonTest, Style) {
1224 content::SavePageType save_page_type = GetParam(); 1229 content::SavePageType save_page_type = GetParam();
1225 1230
1226 std::string arr[] = { 1231 std::string arr[] = {
1227 "style.htm: af84c3ca-0fc6-4b0d-bf7a-5ac18a4dab62", 1232 "style.htm: af84c3ca-0fc6-4b0d-bf7a-5ac18a4dab62",
1228 "frameE: c9539ccd-47b0-47cf-a03b-734614865872", 1233 "frameE: c9539ccd-47b0-47cf-a03b-734614865872",
1229 }; 1234 };
1230 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr)); 1235 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr));
1231 1236
1232 GURL url(embedded_test_server()->GetURL("a.com", "/save_page/style.htm")); 1237 GURL url(embedded_test_server()->GetURL("a.com", "/save_page/style.htm"));
1233 1238 ui_test_utils::NavigateToURL(browser(), url);
1234 TestOriginalVsSavedPage(save_page_type, url, 6, expected_substrings); 1239 TestCurrentVsSavedPage(save_page_type, 6, expected_substrings);
1235 } 1240 }
1236 1241
1237 // Test for saving a page with broken subresources: 1242 // Test for saving a page with broken subresources:
1238 // - Broken, undecodable image (see also https://crbug.com/586680) 1243 // - Broken, undecodable image (see also https://crbug.com/586680)
1239 // - Broken link, to unresolvable host (see also https://crbug.com/594219) 1244 // - Broken link, to unresolvable host (see also https://crbug.com/594219)
1245 // - Resource requiring authentication
1240 IN_PROC_BROWSER_TEST_P(SavePageOriginalVsSavedComparisonTest, BrokenImage) { 1246 IN_PROC_BROWSER_TEST_P(SavePageOriginalVsSavedComparisonTest, BrokenImage) {
1241 // Clear resolver rules to make sure that *.no.such.host used in the test html 1247 // Clear resolver rules to make sure that *.no.such.host used in the test html
1242 // doesn't resolve to 127.0.0.1 1248 // doesn't resolve to 127.0.0.1
1243 host_resolver()->ClearRules(); 1249 host_resolver()->ClearRules();
1244 1250
1245 content::SavePageType save_page_type = GetParam(); 1251 content::SavePageType save_page_type = GetParam();
1246 1252
1247 std::string arr[] = { 1253 std::string arr[] = {
1248 "broken-image.htm: 1e846775-b3ed-4d9c-a124-029554a1eb9d", 1254 "broken-image.htm: 1e846775-b3ed-4d9c-a124-029554a1eb9d",
1249 }; 1255 };
1250 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr)); 1256 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr));
1251 1257
1258 // Navigate to the test URL and dismiss the auth dialog.
1252 GURL url(embedded_test_server()->GetURL("127.0.0.1", 1259 GURL url(embedded_test_server()->GetURL("127.0.0.1",
1253 "/save_page/broken-image.htm")); 1260 "/save_page/broken-image.htm"));
1261 content::WebContents* web_contents =
1262 browser()->tab_strip_model()->GetActiveWebContents();
1263 content::TestNavigationObserver navigation_observer(web_contents, 1);
1264 content::NavigationController* navigation_controller =
1265 &web_contents->GetController();
1266 LoginPromptBrowserTestObserver login_observer;
1267 login_observer.Register(
1268 content::Source<content::NavigationController>(navigation_controller));
1269 WindowedAuthNeededObserver auth_needed_waiter(navigation_controller);
1270 web_contents->OpenURL(content::OpenURLParams(
1271 url, content::Referrer(), CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false));
1272 auth_needed_waiter.Wait();
1273 ASSERT_EQ(1u, login_observer.handlers().size());
1274 login_observer.handlers().front()->CancelAuth();
1275 navigation_observer.Wait();
1254 1276
1255 TestOriginalVsSavedPage(save_page_type, url, 1, expected_substrings); 1277 TestCurrentVsSavedPage(save_page_type, 1, expected_substrings);
1256 } 1278 }
1257 1279
1258 INSTANTIATE_TEST_CASE_P( 1280 INSTANTIATE_TEST_CASE_P(
1259 SaveType, 1281 SaveType,
1260 SavePageOriginalVsSavedComparisonTest, 1282 SavePageOriginalVsSavedComparisonTest,
1261 ::testing::Values(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, 1283 ::testing::Values(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML,
1262 content::SAVE_PAGE_TYPE_AS_MHTML)); 1284 content::SAVE_PAGE_TYPE_AS_MHTML));
1263 1285
1264 } // namespace 1286 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/save_page/broken-image.htm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698