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> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 ASSERT_TRUE(base::ReadFileToString(dir.AppendASCII("a.html"), &a_contents)); | 858 ASSERT_TRUE(base::ReadFileToString(dir.AppendASCII("a.html"), &a_contents)); |
859 EXPECT_THAT(a_contents, | 859 EXPECT_THAT(a_contents, |
860 HasSubstr("a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2")); | 860 HasSubstr("a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2")); |
861 std::string b_contents; | 861 std::string b_contents; |
862 ASSERT_TRUE(base::ReadFileToString(dir.AppendASCII("b.html"), &b_contents)); | 862 ASSERT_TRUE(base::ReadFileToString(dir.AppendASCII("b.html"), &b_contents)); |
863 EXPECT_THAT(b_contents, | 863 EXPECT_THAT(b_contents, |
864 HasSubstr("b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa")); | 864 HasSubstr("b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa")); |
865 } | 865 } |
866 | 866 |
867 // Test for crbug.com/538766. | 867 // Test for crbug.com/538766. |
868 // Disabled because the test will fail until the bug is fixed | 868 IN_PROC_BROWSER_TEST_F(SavePageSitePerProcessBrowserTest, SaveAsMHTML) { |
869 // (but note that the test only fails with --site-per-process flag). | |
870 IN_PROC_BROWSER_TEST_F(SavePageSitePerProcessBrowserTest, | |
871 DISABLED_SaveAsMHTML) { | |
872 GURL url( | 869 GURL url( |
873 embedded_test_server()->GetURL("a.com", "/save_page/frames-xsite.htm")); | 870 embedded_test_server()->GetURL("a.com", "/save_page/frames-xsite.htm")); |
874 ui_test_utils::NavigateToURL(browser(), url); | 871 ui_test_utils::NavigateToURL(browser(), url); |
875 | 872 |
876 base::FilePath full_file_name, dir; | 873 base::FilePath full_file_name, dir; |
877 SaveCurrentTab(url, content::SAVE_PAGE_TYPE_AS_MHTML, "frames-xsite-mhtml", | 874 SaveCurrentTab(url, content::SAVE_PAGE_TYPE_AS_MHTML, "frames-xsite-mhtml", |
878 -1, &dir, &full_file_name); | 875 -1, &dir, &full_file_name); |
879 ASSERT_FALSE(HasFailure()); | 876 ASSERT_FALSE(HasFailure()); |
880 | 877 |
881 std::string mhtml; | 878 std::string mhtml; |
(...skipping 22 matching lines...) Expand all Loading... |
904 // to twice - from iframes.htm and from b.htm). | 901 // to twice - from iframes.htm and from b.htm). |
905 int count = 0; | 902 int count = 0; |
906 size_t pos = 0; | 903 size_t pos = 0; |
907 for (;;) { | 904 for (;;) { |
908 pos = mhtml.find("Content-Type: image/png", pos); | 905 pos = mhtml.find("Content-Type: image/png", pos); |
909 if (pos == std::string::npos) | 906 if (pos == std::string::npos) |
910 break; | 907 break; |
911 count++; | 908 count++; |
912 pos++; | 909 pos++; |
913 } | 910 } |
914 EXPECT_EQ(1, count) << "Verify number of image/png parts in the mhtml output"; | 911 // TODO(lukasza): Need to dedupe savable resources (i.e. 1.png) across frames. |
| 912 // This will be fixed by crrev.com/1417323006. |
| 913 // EXPECT_EQ(1, count) |
| 914 // << "Verify number of image/png parts in the mhtml output"; |
915 } | 915 } |
916 | 916 |
917 // Test suite that verifies that the frame tree "looks" the same before | 917 // Test suite that verifies that the frame tree "looks" the same before |
918 // and after a save-page-as. | 918 // and after a save-page-as. |
919 class SavePageMultiFrameBrowserTest | 919 class SavePageMultiFrameBrowserTest |
920 : public SavePageSitePerProcessBrowserTest, | 920 : public SavePageSitePerProcessBrowserTest, |
921 public ::testing::WithParamInterface<content::SavePageType> { | 921 public ::testing::WithParamInterface<content::SavePageType> { |
922 protected: | 922 protected: |
923 void TestMultiFramePage(content::SavePageType save_page_type, | 923 void TestMultiFramePage(content::SavePageType save_page_type, |
924 const GURL& url, | 924 const GURL& url, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1002 std::string arr[] = { | 1002 std::string arr[] = { |
1003 "frames-xsite.htm: 896fd88d-a77a-4f46-afd8-24db7d5af9c2", | 1003 "frames-xsite.htm: 896fd88d-a77a-4f46-afd8-24db7d5af9c2", |
1004 "a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2", | 1004 "a.htm: 1b8aae2b-e164-462f-bd5b-98aa366205f2", |
1005 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa", | 1005 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa", |
1006 }; | 1006 }; |
1007 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr)); | 1007 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr)); |
1008 | 1008 |
1009 GURL url( | 1009 GURL url( |
1010 embedded_test_server()->GetURL("a.com", "/save_page/frames-xsite.htm")); | 1010 embedded_test_server()->GetURL("a.com", "/save_page/frames-xsite.htm")); |
1011 | 1011 |
1012 // TODO(lukasza): crbug.com/538766: Enable CrossSite testing of MHTML. | |
1013 if (save_page_type == content::SAVE_PAGE_TYPE_AS_MHTML) | |
1014 return; | |
1015 | |
1016 // TODO(lukasza/paulmeyer): crbug.com/457440: Can enable verification | 1012 // TODO(lukasza/paulmeyer): crbug.com/457440: Can enable verification |
1017 // of the original page once find-in-page works for OOP frames. | 1013 // of the original page once find-in-page works for OOP frames. |
1018 bool skip_verification_of_original_page = true; | 1014 bool skip_verification_of_original_page = true; |
1019 | 1015 |
1020 TestMultiFramePage(save_page_type, url, 3, expected_substrings, | 1016 TestMultiFramePage(save_page_type, url, 3, expected_substrings, |
1021 skip_verification_of_original_page); | 1017 skip_verification_of_original_page); |
1022 } | 1018 } |
1023 | 1019 |
1024 // Test for crbug.com/553478. | 1020 // Test for crbug.com/553478. |
1025 IN_PROC_BROWSER_TEST_P(SavePageMultiFrameBrowserTest, ObjectElements) { | 1021 IN_PROC_BROWSER_TEST_P(SavePageMultiFrameBrowserTest, ObjectElements) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 TestMultiFramePage(save_page_type, url, 5, expected_substrings); | 1106 TestMultiFramePage(save_page_type, url, 5, expected_substrings); |
1111 } | 1107 } |
1112 | 1108 |
1113 INSTANTIATE_TEST_CASE_P( | 1109 INSTANTIATE_TEST_CASE_P( |
1114 SaveType, | 1110 SaveType, |
1115 SavePageMultiFrameBrowserTest, | 1111 SavePageMultiFrameBrowserTest, |
1116 ::testing::Values(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, | 1112 ::testing::Values(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, |
1117 content::SAVE_PAGE_TYPE_AS_MHTML)); | 1113 content::SAVE_PAGE_TYPE_AS_MHTML)); |
1118 | 1114 |
1119 } // namespace | 1115 } // namespace |
OLD | NEW |