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

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

Issue 1412733017: Tests comparing original-vs-saved multi-frame pages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Using the right test file extension for html-only save-type. Created 5 years, 1 month 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/a.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 "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"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/prefs/pref_member.h" 12 #include "base/prefs/pref_member.h"
13 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/strings/utf_string_conversions.h"
15 #include "base/test/test_file_util.h" 16 #include "base/test/test_file_util.h"
16 #include "chrome/app/chrome_command_ids.h" 17 #include "chrome/app/chrome_command_ids.h"
17 #include "chrome/browser/download/chrome_download_manager_delegate.h" 18 #include "chrome/browser/download/chrome_download_manager_delegate.h"
18 #include "chrome/browser/download/download_history.h" 19 #include "chrome/browser/download/download_history.h"
19 #include "chrome/browser/download/download_prefs.h" 20 #include "chrome/browser/download/download_prefs.h"
20 #include "chrome/browser/download/download_service.h" 21 #include "chrome/browser/download/download_service.h"
21 #include "chrome/browser/download/download_service_factory.h" 22 #include "chrome/browser/download/download_service_factory.h"
22 #include "chrome/browser/download/save_package_file_picker.h" 23 #include "chrome/browser/download/save_package_file_picker.h"
23 #include "chrome/browser/net/url_request_mock_util.h" 24 #include "chrome/browser/net/url_request_mock_util.h"
24 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
(...skipping 11 matching lines...) Expand all
36 #include "components/history/core/browser/download_row.h" 37 #include "components/history/core/browser/download_row.h"
37 #include "content/public/browser/download_item.h" 38 #include "content/public/browser/download_item.h"
38 #include "content/public/browser/download_manager.h" 39 #include "content/public/browser/download_manager.h"
39 #include "content/public/browser/notification_service.h" 40 #include "content/public/browser/notification_service.h"
40 #include "content/public/browser/notification_types.h" 41 #include "content/public/browser/notification_types.h"
41 #include "content/public/browser/web_contents.h" 42 #include "content/public/browser/web_contents.h"
42 #include "content/public/common/content_switches.h" 43 #include "content/public/common/content_switches.h"
43 #include "content/public/common/url_constants.h" 44 #include "content/public/common/url_constants.h"
44 #include "content/public/test/browser_test_utils.h" 45 #include "content/public/test/browser_test_utils.h"
45 #include "content/public/test/test_utils.h" 46 #include "content/public/test/test_utils.h"
47 #include "net/base/filename_util.h"
46 #include "net/dns/mock_host_resolver.h" 48 #include "net/dns/mock_host_resolver.h"
47 #include "net/test/embedded_test_server/embedded_test_server.h" 49 #include "net/test/embedded_test_server/embedded_test_server.h"
48 #include "net/test/url_request/url_request_mock_http_job.h" 50 #include "net/test/url_request/url_request_mock_http_job.h"
49 #include "testing/gmock/include/gmock/gmock.h" 51 #include "testing/gmock/include/gmock/gmock.h"
50 #include "testing/gtest/include/gtest/gtest.h" 52 #include "testing/gtest/include/gtest/gtest.h"
51 53
52 using content::BrowserContext; 54 using content::BrowserContext;
53 using content::BrowserThread; 55 using content::BrowserThread;
54 using content::DownloadItem; 56 using content::DownloadItem;
55 using content::DownloadManager; 57 using content::DownloadManager;
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 GURL NavigateToMockURL(const std::string& prefix) { 303 GURL NavigateToMockURL(const std::string& prefix) {
302 GURL url = URLRequestMockHTTPJob::GetMockUrl( 304 GURL url = URLRequestMockHTTPJob::GetMockUrl(
303 "save_page/" + prefix + ".htm"); 305 "save_page/" + prefix + ".htm");
304 ui_test_utils::NavigateToURL(browser(), url); 306 ui_test_utils::NavigateToURL(browser(), url);
305 return url; 307 return url;
306 } 308 }
307 309
308 // Returns full paths of destination file and directory. 310 // Returns full paths of destination file and directory.
309 void GetDestinationPaths(const std::string& prefix, 311 void GetDestinationPaths(const std::string& prefix,
310 base::FilePath* full_file_name, 312 base::FilePath* full_file_name,
311 base::FilePath* dir) { 313 base::FilePath* dir,
312 *full_file_name = save_dir_.path().AppendASCII(prefix + ".htm"); 314 content::SavePageType save_page_type =
315 content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML) {
316 std::string extension =
317 (save_page_type == content::SAVE_PAGE_TYPE_AS_MHTML) ? ".mht" : ".htm";
318 *full_file_name = save_dir_.path().AppendASCII(prefix + extension);
313 *dir = save_dir_.path().AppendASCII(prefix + "_files"); 319 *dir = save_dir_.path().AppendASCII(prefix + "_files");
314 } 320 }
315 321
316 WebContents* GetCurrentTab(Browser* browser) const { 322 WebContents* GetCurrentTab(Browser* browser) const {
317 WebContents* current_tab = 323 WebContents* current_tab =
318 browser->tab_strip_model()->GetActiveWebContents(); 324 browser->tab_strip_model()->GetActiveWebContents();
319 EXPECT_TRUE(current_tab); 325 EXPECT_TRUE(current_tab);
320 return current_tab; 326 return current_tab;
321 } 327 }
322 328
(...skipping 20 matching lines...) Expand all
343 349
344 return (expected_url == download_item->GetOriginalUrl()); 350 return (expected_url == download_item->GetOriginalUrl());
345 } 351 }
346 352
347 void SaveCurrentTab(const GURL& url, 353 void SaveCurrentTab(const GURL& url,
348 content::SavePageType save_page_type, 354 content::SavePageType save_page_type,
349 const std::string& prefix_for_output_files, 355 const std::string& prefix_for_output_files,
350 int expected_number_of_files, 356 int expected_number_of_files,
351 base::FilePath* output_dir, 357 base::FilePath* output_dir,
352 base::FilePath* main_file_name) { 358 base::FilePath* main_file_name) {
353 GetDestinationPaths(prefix_for_output_files, main_file_name, output_dir); 359 GetDestinationPaths(prefix_for_output_files, main_file_name, output_dir,
360 save_page_type);
354 DownloadPersistedObserver persisted( 361 DownloadPersistedObserver persisted(
355 browser()->profile(), 362 browser()->profile(),
356 base::Bind(&DownloadStoredProperly, url, *main_file_name, 363 base::Bind(&DownloadStoredProperly, url, *main_file_name,
357 expected_number_of_files, history::DownloadState::COMPLETE)); 364 expected_number_of_files, history::DownloadState::COMPLETE));
358 base::RunLoop run_loop; 365 base::RunLoop run_loop;
359 SavePackageFinishedObserver observer( 366 SavePackageFinishedObserver observer(
360 content::BrowserContext::GetDownloadManager(browser()->profile()), 367 content::BrowserContext::GetDownloadManager(browser()->profile()),
361 run_loop.QuitClosure()); 368 run_loop.QuitClosure());
362 ASSERT_TRUE(GetCurrentTab(browser()) 369 ASSERT_TRUE(GetCurrentTab(browser())
363 ->SavePage(*main_file_name, *output_dir, save_page_type)); 370 ->SavePage(*main_file_name, *output_dir, save_page_type));
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 784 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
778 content::SetupCrossSiteRedirector(embedded_test_server()); 785 content::SetupCrossSiteRedirector(embedded_test_server());
779 } 786 }
780 787
781 private: 788 private:
782 DISALLOW_COPY_AND_ASSIGN(SavePageSitePerProcessBrowserTest); 789 DISALLOW_COPY_AND_ASSIGN(SavePageSitePerProcessBrowserTest);
783 }; 790 };
784 791
785 // Test for crbug.com/526786. 792 // Test for crbug.com/526786.
786 IN_PROC_BROWSER_TEST_F(SavePageSitePerProcessBrowserTest, SaveAsCompleteHtml) { 793 IN_PROC_BROWSER_TEST_F(SavePageSitePerProcessBrowserTest, SaveAsCompleteHtml) {
787 GURL url(embedded_test_server()->GetURL("a.com", "/save_page/iframes.htm")); 794 GURL url(
795 embedded_test_server()->GetURL("a.com", "/save_page/frames-xsite.htm"));
788 ui_test_utils::NavigateToURL(browser(), url); 796 ui_test_utils::NavigateToURL(browser(), url);
789 797
790 base::FilePath full_file_name, dir; 798 base::FilePath full_file_name, dir;
791 SaveCurrentTab(url, content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, "iframes", 5, 799 SaveCurrentTab(url, content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML,
792 &dir, &full_file_name); 800 "frames-xsite-complete-html", 5, &dir, &full_file_name);
793 ASSERT_FALSE(HasFailure()); 801 ASSERT_FALSE(HasFailure());
794 802
795 EXPECT_TRUE(base::DirectoryExists(dir)); 803 EXPECT_TRUE(base::DirectoryExists(dir));
796 base::FilePath expected_files[] = { 804 base::FilePath expected_files[] = {
797 full_file_name, 805 full_file_name,
798 dir.AppendASCII("a.html"), // From iframes.htm 806 dir.AppendASCII("a.html"), // From iframes.htm
799 dir.AppendASCII("b.html"), // From iframes.htm 807 dir.AppendASCII("b.html"), // From iframes.htm
800 dir.AppendASCII("1.css"), // From b.htm 808 dir.AppendASCII("1.css"), // From b.htm
801 dir.AppendASCII("1.png"), // Deduplicated from iframes.htm and b.htm. 809 dir.AppendASCII("1.png"), // Deduplicated from iframes.htm and b.htm.
802 }; 810 };
803 for (auto file_path : expected_files) { 811 for (auto file_path : expected_files) {
804 EXPECT_TRUE(base::PathExists(file_path)) << "Does " << file_path.value() 812 EXPECT_TRUE(base::PathExists(file_path)) << "Does " << file_path.value()
805 << " exist?"; 813 << " exist?";
806 int64 actual_file_size = 0; 814 int64 actual_file_size = 0;
807 EXPECT_TRUE(base::GetFileSize(file_path, &actual_file_size)); 815 EXPECT_TRUE(base::GetFileSize(file_path, &actual_file_size));
808 EXPECT_NE(0, actual_file_size) << "Is " << file_path.value() 816 EXPECT_NE(0, actual_file_size) << "Is " << file_path.value()
809 << " non-empty?"; 817 << " non-empty?";
810 } 818 }
811 819
812 // Verify that local links got correctly replaced with local paths 820 // Verify that local links got correctly replaced with local paths
813 // (most importantly for iframe elements, which are only exercised 821 // (most importantly for iframe elements, which are only exercised
814 // by this particular test). 822 // by this particular test).
815 std::string main_contents; 823 std::string main_contents;
816 ASSERT_TRUE(base::ReadFileToString(full_file_name, &main_contents)); 824 ASSERT_TRUE(base::ReadFileToString(full_file_name, &main_contents));
817 EXPECT_THAT(main_contents, 825 EXPECT_THAT(
818 HasSubstr("<iframe src=\"./iframes_files/a.html\"></iframe>")); 826 main_contents,
819 EXPECT_THAT(main_contents, 827 HasSubstr("<iframe "
820 HasSubstr("<iframe src=\"./iframes_files/b.html\"></iframe>")); 828 "src=\"./frames-xsite-complete-html_files/a.html\"></iframe>"));
821 EXPECT_THAT(main_contents, 829 EXPECT_THAT(
822 HasSubstr("<img src=\"./iframes_files/1.png\">")); 830 main_contents,
831 HasSubstr("<iframe "
832 "src=\"./frames-xsite-complete-html_files/b.html\"></iframe>"));
833 EXPECT_THAT(
834 main_contents,
835 HasSubstr("<img src=\"./frames-xsite-complete-html_files/1.png\">"));
823 836
824 // Verification of html contents. 837 // Verification of html contents.
825 EXPECT_THAT(main_contents, HasSubstr("896fd88d-a77a-4f46-afd8-24db7d5af9c2")) 838 EXPECT_THAT(
826 << "Verifing if content from iframes.htm is present"; 839 main_contents,
840 HasSubstr("frames-xsite.htm: 896fd88d-a77a-4f46-afd8-24db7d5af9c2"));
827 std::string a_contents; 841 std::string a_contents;
828 ASSERT_TRUE(base::ReadFileToString(dir.AppendASCII("a.html"), &a_contents)); 842 ASSERT_TRUE(base::ReadFileToString(dir.AppendASCII("a.html"), &a_contents));
829 EXPECT_THAT(a_contents, HasSubstr("1b8aae2b-e164-462f-bd5b-98aa366205f2")) 843 EXPECT_THAT(a_contents,
830 << "Verifing if content from a.htm is present"; 844 HasSubstr("a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2"));
831 std::string b_contents; 845 std::string b_contents;
832 ASSERT_TRUE(base::ReadFileToString(dir.AppendASCII("b.html"), &b_contents)); 846 ASSERT_TRUE(base::ReadFileToString(dir.AppendASCII("b.html"), &b_contents));
833 EXPECT_THAT(b_contents, HasSubstr("3a35f7fa-96a9-4487-9f18-4470263907fa")) 847 EXPECT_THAT(b_contents,
834 << "Verifing if content from b.htm is present"; 848 HasSubstr("b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa"));
835 } 849 }
836 850
837 // Test for crbug.com/538766. 851 // Test for crbug.com/538766.
838 // Disabled because the test will fail until the bug is fixed 852 // Disabled because the test will fail until the bug is fixed
839 // (but note that the test only fails with --site-per-process flag). 853 // (but note that the test only fails with --site-per-process flag).
840 IN_PROC_BROWSER_TEST_F(SavePageSitePerProcessBrowserTest, 854 IN_PROC_BROWSER_TEST_F(SavePageSitePerProcessBrowserTest,
841 DISABLED_SaveAsMHTML) { 855 DISABLED_SaveAsMHTML) {
842 GURL url(embedded_test_server()->GetURL("a.com", "/save_page/iframes.htm")); 856 GURL url(
857 embedded_test_server()->GetURL("a.com", "/save_page/frames-xsite.htm"));
843 ui_test_utils::NavigateToURL(browser(), url); 858 ui_test_utils::NavigateToURL(browser(), url);
844 859
845 base::FilePath full_file_name, dir; 860 base::FilePath full_file_name, dir;
846 SaveCurrentTab(url, content::SAVE_PAGE_TYPE_AS_MHTML, "iframes", -1, &dir, 861 SaveCurrentTab(url, content::SAVE_PAGE_TYPE_AS_MHTML, "frames-xsite-mhtml",
847 &full_file_name); 862 -1, &dir, &full_file_name);
848 ASSERT_FALSE(HasFailure()); 863 ASSERT_FALSE(HasFailure());
849 864
850 std::string mhtml; 865 std::string mhtml;
851 ASSERT_TRUE(base::ReadFileToString(full_file_name, &mhtml)); 866 ASSERT_TRUE(base::ReadFileToString(full_file_name, &mhtml));
852 867
853 // Verify content of main frame, subframes and some savable resources. 868 // Verify content of main frame, subframes and some savable resources.
854 EXPECT_THAT(mhtml, HasSubstr("896fd88d-a77a-4f46-afd8-24db7d5af9c2")) 869 EXPECT_THAT(
855 << "Verifing if content from iframes.htm is present"; 870 mhtml,
856 EXPECT_THAT(mhtml, HasSubstr("1b8aae2b-e164-462f-bd5b-98aa366205f2")) 871 HasSubstr("frames-xsite.htm: 896fd88d-a77a-4f46-afd8-24db7d5af9c2"));
857 << "Verifing if content from a.htm is present"; 872 EXPECT_THAT(mhtml, HasSubstr("a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2"));
858 EXPECT_THAT(mhtml, HasSubstr("3a35f7fa-96a9-4487-9f18-4470263907fa")) 873 EXPECT_THAT(mhtml, HasSubstr("b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa"));
859 << "Verifing if content from b.htm is present";
860 EXPECT_THAT(mhtml, HasSubstr("font-size: 20px;")) 874 EXPECT_THAT(mhtml, HasSubstr("font-size: 20px;"))
861 << "Verifing if content from 1.css is present"; 875 << "Verifying if content from 1.css is present";
862 876
863 // Verify presence of URLs associated with main frame, subframes and some 877 // Verify presence of URLs associated with main frame, subframes and some
864 // savable resources. 878 // savable resources.
865 // (note that these are single-line regexes). 879 // (note that these are single-line regexes).
866 EXPECT_THAT(mhtml, ContainsRegex("Content-Location.*/save_page/iframes.htm")); 880 EXPECT_THAT(mhtml,
881 ContainsRegex("Content-Location.*/save_page/frames-xsite.htm"));
867 EXPECT_THAT(mhtml, ContainsRegex("Content-Location.*/save_page/a.htm")); 882 EXPECT_THAT(mhtml, ContainsRegex("Content-Location.*/save_page/a.htm"));
868 EXPECT_THAT(mhtml, ContainsRegex("Content-Location.*/save_page/b.htm")); 883 EXPECT_THAT(mhtml, ContainsRegex("Content-Location.*/save_page/b.htm"));
869 EXPECT_THAT(mhtml, ContainsRegex("Content-Location.*/save_page/1.css")); 884 EXPECT_THAT(mhtml, ContainsRegex("Content-Location.*/save_page/1.css"));
870 EXPECT_THAT(mhtml, ContainsRegex("Content-Location.*/save_page/1.png")); 885 EXPECT_THAT(mhtml, ContainsRegex("Content-Location.*/save_page/1.png"));
871 886
872 // Verify that 1.png appear in the output only once (despite being referred to 887 // Verify that 1.png appears in the output only once (despite being referred
873 // twice - from iframes.htm and from b.htm). 888 // to twice - from iframes.htm and from b.htm).
874 int count = 0; 889 int count = 0;
875 size_t pos = 0; 890 size_t pos = 0;
876 for (;;) { 891 for (;;) {
877 pos = mhtml.find("Content-Type: image/png", pos); 892 pos = mhtml.find("Content-Type: image/png", pos);
878 if (pos == std::string::npos) 893 if (pos == std::string::npos)
879 break; 894 break;
880 count++; 895 count++;
881 pos++; 896 pos++;
882 } 897 }
883 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";
884 } 899 }
885 900
901 // Test suite that verifies that the frame tree "looks" the same before
902 // and after a save-page-as.
903 class SavePageMultiFrameBrowserTest : public SavePageSitePerProcessBrowserTest {
904 protected:
905 void TestMultiFramePage(content::SavePageType save_page_type,
906 const GURL& url,
907 int expected_number_of_frames,
908 const std::vector<std::string>& expected_substrings) {
909 // Navigate to the test page and verify if test expectations
910 // are met (this is mostly a sanity check - a failure to meet
911 // expectations would probably mean that there is a test bug
912 // (i.e. that we got called with wrong expected_foo argument).
913 ui_test_utils::NavigateToURL(browser(), url);
914 DLOG(INFO) << "Verifying test expectations for original page... : "
915 << GetCurrentTab(browser())->GetLastCommittedURL();
916 // TODO(lukasza/paulmeyer): crbug.com/457440: Can uncomment
917 // the assertion below once find-in-page works for oop frames.
918 // AssertExpectationsAboutCurrentTab(expected_number_of_frames,
919 // expected_substrings);
920
921 // Save the page.
922 base::FilePath full_file_name, dir;
923 SaveCurrentTab(url, save_page_type, "save_result", -1, &dir,
924 &full_file_name);
925 ASSERT_FALSE(HasFailure());
926
927 // Stop the test server (to make sure the locally saved page
928 // is self-contained / won't try to open original resources).
929 ASSERT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete());
930
931 // Open the saved page and verify if test expectations are
932 // met (i.e. if the same expectations are met for "after"
933 // [saved version of the page] as for the "before"
934 // [the original version of the page].
935 ui_test_utils::NavigateToURL(browser(),
936 GURL(net::FilePathToFileURL(full_file_name)));
937 DLOG(INFO) << "Verifying test expectations for saved page... : "
938 << GetCurrentTab(browser())->GetLastCommittedURL();
939 AssertExpectationsAboutCurrentTab(expected_number_of_frames,
940 expected_substrings);
941 }
942
943 private:
944 void AssertExpectationsAboutCurrentTab(
945 int expected_number_of_frames,
946 const std::vector<std::string>& expected_substrings) {
947 int actual_number_of_frames = 0;
948 GetCurrentTab(browser())->ForEachFrame(base::Bind(
949 &IncrementInteger, base::Unretained(&actual_number_of_frames)));
950 EXPECT_EQ(expected_number_of_frames, actual_number_of_frames);
951
952 for (const auto& expected_substring : expected_substrings) {
953 int actual_number_of_matches = ui_test_utils::FindInPage(
954 GetCurrentTab(browser()), base::UTF8ToUTF16(expected_substring),
955 true, // |forward|
956 true, // |case_sensitive|
957 nullptr, nullptr);
958
959 EXPECT_EQ(1, actual_number_of_matches)
960 << "Verifying if \"" << expected_substring << "\" appears "
961 << "exactly once in the web-contents text";
962 }
963
964 int actual_number_of_errors = ui_test_utils::FindInPage(
965 GetCurrentTab(browser()), base::UTF8ToUTF16("err"),
966 true, // |forward|
967 false, // |case_sensitive|
968 nullptr, nullptr);
969 EXPECT_EQ(0, actual_number_of_errors);
970 }
971
972 static void IncrementInteger(int* i, content::RenderFrameHost* /* unused */) {
973 (*i)++;
974 }
975 };
976
977 // TODO(lukasza): Pivot on mhtml-vs-complete-html using test params
978 // (once all SavePageMultiFrameBrowserTest are enabled).
979
980 IN_PROC_BROWSER_TEST_F(SavePageMultiFrameBrowserTest,
981 CrossSiteFrames_CompleteHtml) {
982 std::vector<std::string> expected_substrings{
983 "frames-xsite.htm: 896fd88d-a77a-4f46-afd8-24db7d5af9c2",
984 "a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2",
985 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa",
986 };
987 GURL url(
988 embedded_test_server()->GetURL("a.com", "/save_page/frames-xsite.htm"));
989 TestMultiFramePage(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, url, 3,
990 expected_substrings);
991 }
992
993 // Test for crbug.com/538766 and crbug.com/539936.
994 // Disabled because both bugs are not yet fixed.
995 IN_PROC_BROWSER_TEST_F(SavePageMultiFrameBrowserTest,
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
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
1012 // (svg and png objects do not get a separate frame)
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
1034 std::vector<std::string> expected_substrings{
1035 "frames-objects.htm: 8da13db4-a512-4d9b-b1c5-dc1c134234b9",
1036 "a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2",
1037 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa",
1038 };
1039 GURL url(
1040 embedded_test_server()->GetURL("a.com", "/save_page/frames-objects.htm"));
1041 TestMultiFramePage(content::SAVE_PAGE_TYPE_AS_MHTML, url,
1042 expected_number_of_frames, expected_substrings);
1043 }
1044
1045 IN_PROC_BROWSER_TEST_F(SavePageMultiFrameBrowserTest, AboutBlank_CompleteHtml) {
1046 std::vector<std::string> expected_substrings{
1047 "main: acb0609d-eb10-4c26-83e2-ad8afb7b0ff3",
1048 "sub1: b124df3a-d39f-47a1-ae04-5bb5d0bf549e",
1049 "sub2: 07014068-604d-45ae-884f-a068cfe7bc0a",
1050 "sub3: 06cc8fcc-c692-4a1a-a10f-1645b746e8f4",
1051 };
1052 GURL url(embedded_test_server()->GetURL("a.com",
1053 "/save_page/frames-about-blank.htm"));
1054 TestMultiFramePage(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, url, 4,
1055 expected_substrings);
1056 }
1057
1058 IN_PROC_BROWSER_TEST_F(SavePageMultiFrameBrowserTest, AboutBlank_MHTML) {
1059 std::vector<std::string> expected_substrings{
1060 "main: acb0609d-eb10-4c26-83e2-ad8afb7b0ff3",
1061 "sub1: b124df3a-d39f-47a1-ae04-5bb5d0bf549e",
1062 "sub2: 07014068-604d-45ae-884f-a068cfe7bc0a",
1063 "sub3: 06cc8fcc-c692-4a1a-a10f-1645b746e8f4",
1064 };
1065 GURL url(embedded_test_server()->GetURL("a.com",
1066 "/save_page/frames-about-blank.htm"));
1067 TestMultiFramePage(content::SAVE_PAGE_TYPE_AS_MHTML, url, 4,
1068 expected_substrings);
1069 }
1070
886 } // namespace 1071 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/save_page/a.htm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698