Chromium Code Reviews| Index: content/browser/download/mhtml_generation_browsertest.cc |
| diff --git a/content/browser/download/mhtml_generation_browsertest.cc b/content/browser/download/mhtml_generation_browsertest.cc |
| index 6adf1212067e82662735802eb6ae34847e5b2cad..68c65a5a5af11307d43123ccb0a38c85d00fddfd 100644 |
| --- a/content/browser/download/mhtml_generation_browsertest.cc |
| +++ b/content/browser/download/mhtml_generation_browsertest.cc |
| @@ -17,6 +17,7 @@ |
| #include "base/threading/thread_restrictions.h" |
| #include "content/browser/renderer_host/render_process_host_impl.h" |
| #include "content/common/frame_messages.h" |
| +#include "content/public/browser/mhtml_extra_parts.h" |
| #include "content/public/browser/render_process_host.h" |
| #include "content/public/browser/web_contents.h" |
| #include "content/public/common/mhtml_generation_params.h" |
| @@ -672,4 +673,43 @@ IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, RemovePopupOverlay) { |
| EXPECT_THAT(mhtml, Not(HasSubstr("class=3D\"modal"))); |
| } |
| +IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLWithExtraData) { |
| + const char kFakeSignalData1[] = "FakeSignalData1"; |
| + const char kFakeSignalData2[] = "OtherMockDataForSignals"; |
| + const char kFakeContentType[] = "text/plain"; |
| + const char kFakeContentLocation[] = |
| + "cid:signal-data-62691-645341c4-62b3-478e-a8c5-e0dfccc3ca02@mhtml.blink"; |
| + base::FilePath path(temp_dir_.GetPath()); |
| + path = path.Append(FILE_PATH_LITERAL("test.mht")); |
| + GURL url(embedded_test_server()->GetURL("/page_with_image.html")); |
| + MHTMLGenerationParams params(path); |
| + |
| + // Place the extra data we need into the web contents user data. |
| + std::string signal_data1(kFakeSignalData1); |
|
David Trainor- moved to gerrit
2017/03/30 05:26:40
Do you need these?
Pete Williamson
2017/03/31 00:29:49
Removed
|
| + std::string signal_data2(kFakeSignalData2); |
| + std::string content_type(kFakeContentType); |
| + std::string content_location(kFakeContentLocation); |
| + |
| + // Get the MHTMLExtraParts |
| + MHTMLExtraParts* extra_parts = |
| + MHTMLExtraParts::FromWebContents(shell()->web_contents()); |
| + |
| + // Add two extra data parts to the MHTML. |
| + extra_parts->AddExtraMHTMLPart(content_type, content_location, signal_data1); |
| + extra_parts->AddExtraMHTMLPart(content_type, content_location, signal_data2); |
| + GenerateMHTML(params, url); |
| + |
| + EXPECT_TRUE(has_mhtml_callback_run()); |
| + |
| + std::string mhtml; |
| + { |
| + base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; |
| + ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); |
| + } |
| + |
| + // Make sure that both extra data parts made it into the mhtml. |
| + EXPECT_THAT(mhtml, HasSubstr(kFakeSignalData1)); |
| + EXPECT_THAT(mhtml, HasSubstr(kFakeSignalData2)); |
| +} |
| + |
| } // namespace content |