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 71845c3fdc703e1a6b43bcc61af93bc9cd4ac334..343e38614d639ae236aaac88ee38d30d97695394 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,44 @@ 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 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, |
+ kFakeSignalData1); |
+ extra_parts->AddExtraMHTMLPart(content_type, content_location, |
+ kFakeSignalData2); |
+ EXPECT_EQ(extra_parts->size(), 2); |
+ 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 |