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..af1f00b28e53a4dd4f23672f2e540730a17b189b 100644 |
--- a/content/browser/download/mhtml_generation_browsertest.cc |
+++ b/content/browser/download/mhtml_generation_browsertest.cc |
@@ -15,6 +15,7 @@ |
#include "base/strings/utf_string_conversions.h" |
#include "base/test/histogram_tester.h" |
#include "base/threading/thread_restrictions.h" |
+#include "content/browser/download/mhtml_extra_data.h" |
#include "content/browser/renderer_host/render_process_host_impl.h" |
#include "content/common/frame_messages.h" |
#include "content/public/browser/render_process_host.h" |
@@ -672,4 +673,35 @@ IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, RemovePopupOverlay) { |
EXPECT_THAT(mhtml, Not(HasSubstr("class=3D\"modal"))); |
} |
+IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLWithExtraData) { |
+ const char kFakeSignalData[] = "FakeSignalData"; |
+ 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_string(kFakeSignalData); |
+ shell()->web_contents()->SetUserData( |
+ content::kMHTMLExtraDataKey, |
+ std::unique_ptr<base::SupportsUserData::Data>( |
+ new content::MHTMLExtraData(std::string(signal_string)))); |
+ |
+ // Make the user data available on other threads by promising we are done |
+ // here. shell()->web_contents()->DetachFromSequence(); |
fgorski
2017/03/16 17:46:31
What exactly happens here? Comment does not help,
Pete Williamson
2017/03/17 23:28:32
Oops, leftover code, removed.
|
+ |
+ 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 extra data made it into the mhtml. |
+ EXPECT_THAT(mhtml, HasSubstr(kFakeSignalData)); |
+} |
+ |
} // namespace content |