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

Unified Diff: content/browser/download/mhtml_generation_browsertest.cc

Issue 2683493002: Get signals working in the EXTRA_DATA section of MHTML (Closed)
Patch Set: Attempt to clear trybots. Created 3 years, 9 months 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 side-by-side diff with in-line comments
Download patch
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..b2f8319a6d0fa1bbded241d228f959e9b7ae42c7 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_data.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,45 @@ 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);
+ std::string signal_data2(kFakeSignalData2);
+ std::string content_type(kFakeContentType);
+ std::string content_location(kFakeContentLocation);
+
+ // Get the MHTMLExtraData
+ MHTMLExtraData* extra_data =
+ MHTMLExtraData::FromWebContents(shell()->web_contents());
+
+ // Add two extra data parts to the MHTML.
+ extra_data->StashMHTMLPartForAdditionToPage(content_type, content_location,
+ signal_data1);
+ extra_data->StashMHTMLPartForAdditionToPage(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

Powered by Google App Engine
This is Rietveld 408576698