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

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: Fixing base::FilePath -> std::string conversion. 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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 } 300 }
300 301
301 GURL NavigateToMockURL(const std::string& prefix) { 302 GURL NavigateToMockURL(const std::string& prefix) {
302 GURL url = URLRequestMockHTTPJob::GetMockUrl( 303 GURL url = URLRequestMockHTTPJob::GetMockUrl(
303 "save_page/" + prefix + ".htm"); 304 "save_page/" + prefix + ".htm");
304 ui_test_utils::NavigateToURL(browser(), url); 305 ui_test_utils::NavigateToURL(browser(), url);
305 return url; 306 return url;
306 } 307 }
307 308
308 // Returns full paths of destination file and directory. 309 // Returns full paths of destination file and directory.
309 void GetDestinationPaths(const std::string& prefix, 310 void GetDestinationPaths(const std::string& prefix,
asanka 2015/11/11 21:37:37 The directory is not used for the MHTML case, righ
Łukasz Anforowicz 2015/11/11 23:55:40 Right.
asanka 2015/11/12 03:14:36 For ONLY_HTML, it now returns an ".mht" extension.
Łukasz Anforowicz 2015/11/12 06:30:27 Doh, you're right. I don't know how I could have
310 base::FilePath* full_file_name, 311 base::FilePath* full_file_name,
311 base::FilePath* dir) { 312 base::FilePath* dir,
312 *full_file_name = save_dir_.path().AppendASCII(prefix + ".htm"); 313 content::SavePageType save_page_type =
314 content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML) {
315 std::string extension =
316 (save_page_type == content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML) ? ".htm"
317 : ".mht";
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 << "Verifing if content from 1.css is present";
asanka 2015/11/11 21:37:37 Verifying
Łukasz Anforowicz 2015/11/11 23:55:40 Done.
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 LOG(INFO) << "Verifying test expectations for original page... : "
asanka 2015/11/11 21:37:37 DLOG(INFO)
Łukasz Anforowicz 2015/11/11 23:55:40 Done.
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].
asanka 2015/11/11 21:37:37 Use net::FilePathToFileURL().
Łukasz Anforowicz 2015/11/11 23:55:40 Thanks! I knew that I saw this some time ago, but
935 std::string ascii_path = full_file_name.MaybeAsASCII();
936 ASSERT_TRUE(!ascii_path.empty());
937 std::string file_url;
938 file_url += url::kFileScheme;
939 file_url += "://";
940 file_url += ascii_path;
941 ui_test_utils::NavigateToURL(browser(), GURL(file_url));
942 LOG(INFO) << "Verifying test expectations for saved page... : "
asanka 2015/11/11 21:37:37 DLOG(INFO)
Łukasz Anforowicz 2015/11/11 23:55:40 Done.
943 << GetCurrentTab(browser())->GetLastCommittedURL();
944 AssertExpectationsAboutCurrentTab(expected_number_of_frames,
945 expected_substrings);
946 }
947
948 private:
949 void AssertExpectationsAboutCurrentTab(
Łukasz Anforowicz 2015/11/11 23:55:40 RE: top-level question about entropy in mhtml file
asanka 2015/11/12 03:14:36 Got it.
950 int expected_number_of_frames,
951 const std::vector<std::string>& expected_substrings) {
952 int actual_number_of_frames = 0;
953 GetCurrentTab(browser())->ForEachFrame(base::Bind(
954 &IncrementInteger, base::Unretained(&actual_number_of_frames)));
955 EXPECT_EQ(expected_number_of_frames, actual_number_of_frames);
956
957 for (const auto& expected_substring : expected_substrings) {
958 int actual_number_of_matches = ui_test_utils::FindInPage(
959 GetCurrentTab(browser()), base::UTF8ToUTF16(expected_substring),
960 true, // |forward|
961 true, // |case_sensitive|
962 nullptr, nullptr);
963
964 EXPECT_EQ(1, actual_number_of_matches)
965 << "Verifying if \"" << expected_substring << "\" appears "
966 << "exactly once in the web-contents text";
967 }
968
969 int actual_number_of_errors = ui_test_utils::FindInPage(
970 GetCurrentTab(browser()), base::UTF8ToUTF16("err"),
971 true, // |forward|
972 false, // |case_sensitive|
973 nullptr, nullptr);
974 EXPECT_EQ(0, actual_number_of_errors);
975 }
976
977 static void IncrementInteger(int* i, content::RenderFrameHost* /* unused */) {
978 (*i)++;
979 }
980 };
981
982 // TODO(lukasza): Pivot on mhtml-vs-complete-html using test params
983 // (once all SavePageMultiFrameBrowserTest are enabled).
984
985 IN_PROC_BROWSER_TEST_F(SavePageMultiFrameBrowserTest,
986 CrossSiteFrames_CompleteHtml) {
987 std::vector<std::string> expected_substrings{
988 "frames-xsite.htm: 896fd88d-a77a-4f46-afd8-24db7d5af9c2",
989 "a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2",
990 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa",
991 };
992 GURL url(
993 embedded_test_server()->GetURL("a.com", "/save_page/frames-xsite.htm"));
994 TestMultiFramePage(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, url, 3,
995 expected_substrings);
996 }
997
998 // Test for crbug.com/538766 and crbug.com/539936.
999 // Disabled because both bugs are not yet fixed.
1000 IN_PROC_BROWSER_TEST_F(SavePageMultiFrameBrowserTest,
1001 DISABLED_CrossSiteFrames_MHTML) {
1002 std::vector<std::string> expected_substrings{
1003 "frames-xsite.htm: 896fd88d-a77a-4f46-afd8-24db7d5af9c2",
1004 "a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2",
1005 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa",
1006 };
1007 GURL url(
1008 embedded_test_server()->GetURL("a.com", "/save_page/frames-xsite.htm"));
1009 TestMultiFramePage(content::SAVE_PAGE_TYPE_AS_MHTML, url, 3,
1010 expected_substrings);
1011 }
1012
1013 // Test for crbug.com/553478 (complete html part).
1014 IN_PROC_BROWSER_TEST_F(SavePageMultiFrameBrowserTest,
1015 DISABLED_ObjectElements_CompleteHtml) {
1016 // 4 = main frame + iframe + object w/ html doc + object w/ pdf doc
1017 // (svg and png objects do not get a separate frame)
1018 int expected_number_of_frames = 4;
1019
1020 std::vector<std::string> expected_substrings{
1021 "frames-objects.htm: 8da13db4-a512-4d9b-b1c5-dc1c134234b9",
1022 "a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2",
1023 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa",
1024 };
1025 GURL url(
1026 embedded_test_server()->GetURL("a.com", "/save_page/frames-objects.htm"));
1027 TestMultiFramePage(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, url,
1028 expected_number_of_frames, expected_substrings);
1029 }
1030
1031 // Test for crbug.com/553478 (mhtml part).
1032 // See crbug.com/553478#c3 for some MHTML-specific notes.
1033 IN_PROC_BROWSER_TEST_F(SavePageMultiFrameBrowserTest,
1034 DISABLED_ObjectElements_MHTML) {
1035 // 4 = main frame + iframe + object w/ html doc + object w/ pdf doc
1036 // (svg and png objects do not get a separate frame)
1037 int expected_number_of_frames = 4;
1038
1039 std::vector<std::string> expected_substrings{
1040 "frames-objects.htm: 8da13db4-a512-4d9b-b1c5-dc1c134234b9",
1041 "a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2",
1042 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa",
1043 };
1044 GURL url(
1045 embedded_test_server()->GetURL("a.com", "/save_page/frames-objects.htm"));
1046 TestMultiFramePage(content::SAVE_PAGE_TYPE_AS_MHTML, url,
1047 expected_number_of_frames, expected_substrings);
1048 }
1049
1050 IN_PROC_BROWSER_TEST_F(SavePageMultiFrameBrowserTest, AboutBlank_CompleteHtml) {
1051 std::vector<std::string> expected_substrings{
1052 "main: acb0609d-eb10-4c26-83e2-ad8afb7b0ff3",
1053 "sub1: b124df3a-d39f-47a1-ae04-5bb5d0bf549e",
1054 "sub2: 07014068-604d-45ae-884f-a068cfe7bc0a",
1055 "sub3: 06cc8fcc-c692-4a1a-a10f-1645b746e8f4",
1056 };
1057 GURL url(embedded_test_server()->GetURL("a.com",
1058 "/save_page/frames-about-blank.htm"));
1059 TestMultiFramePage(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, url, 4,
1060 expected_substrings);
1061 }
1062
1063 IN_PROC_BROWSER_TEST_F(SavePageMultiFrameBrowserTest, AboutBlank_MHTML) {
1064 std::vector<std::string> expected_substrings{
1065 "main: acb0609d-eb10-4c26-83e2-ad8afb7b0ff3",
1066 "sub1: b124df3a-d39f-47a1-ae04-5bb5d0bf549e",
1067 "sub2: 07014068-604d-45ae-884f-a068cfe7bc0a",
1068 "sub3: 06cc8fcc-c692-4a1a-a10f-1645b746e8f4",
1069 };
1070 GURL url(embedded_test_server()->GetURL("a.com",
1071 "/save_page/frames-about-blank.htm"));
1072 TestMultiFramePage(content::SAVE_PAGE_TYPE_AS_MHTML, url, 4,
1073 expected_substrings);
1074 }
1075
886 } // namespace 1076 } // 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