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

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

Issue 1977303003: Adds a feature to MHTML serialization that omits subframes and subresources marked no-store. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@no-store
Patch Set: Created 4 years, 7 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 00f3aeb1964ce93c82c864ee176517fb083ec02c..6b28397c13ce3408492b12d0f23196b803970401 100644
--- a/content/browser/download/mhtml_generation_browsertest.cc
+++ b/content/browser/download/mhtml_generation_browsertest.cc
@@ -199,6 +199,51 @@ IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLObeyNoStoreMainFrame) {
EXPECT_THAT(mhtml, Not(HasSubstr("test body")));
}
+IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest,
+ GenerateMHTMLIgnoreNoStoreSubFrame) {
+ base::FilePath path(temp_dir_.path());
+ path = path.Append(FILE_PATH_LITERAL("test.mht"));
+
+ GURL url(embedded_test_server()->GetURL("/contains_nostore_iframe.html"));
+
+ // Generate MHTML, specifying the FAIL_FOR_NO_STORE_MAIN_FRAME policy.
+ MHTMLGenerationParams params(path);
+ params.cache_control_policy =
+ content::MHTMLCacheControlPolicy::FAIL_FOR_NO_STORE_MAIN_FRAME;
+
+ GenerateMHTML(params, url);
+ // We expect that there was no error (file size -1 indicates an error.)
+ EXPECT_LT(0, file_size());
+
+ std::string mhtml;
+ ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
+
+ // Make sure that no-store subresources exist in this mode.
+ EXPECT_THAT(mhtml, HasSubstr("no-store test body"));
+}
+
+IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLObeyNoStoreSubFrame) {
+ base::FilePath path(temp_dir_.path());
+ path = path.Append(FILE_PATH_LITERAL("test.mht"));
+
+ GURL url(embedded_test_server()->GetURL("/contains_nostore_iframe.html"));
+
+ // Generate MHTML, specifying the FAIL_FOR_NO_STORE_MAIN_FRAME policy.
+ MHTMLGenerationParams params(path);
+ params.cache_control_policy = content::MHTMLCacheControlPolicy::
+ SKIP_ANY_FRAME_OR_RESOURCE_MARKED_NO_STORE;
+
+ GenerateMHTML(params, url);
+ // We expect that there was no error (file size -1 indicates an error.)
+ EXPECT_LT(0, file_size());
+
+ std::string mhtml;
+ ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
+
+ // Make sure the contents are missing.
+ EXPECT_THAT(mhtml, Not(HasSubstr("no-store test body")));
+}
+
Dmitry Titov 2016/05/18 00:18:47 it'd be nice to add a subresource test (css or ima
dewittj 2016/05/19 04:13:17 Done. Note that CSS is not covered by this CL (I
// Test suite that allows testing --site-per-process against cross-site frames.
// See http://dev.chromium.org/developers/design-documents/site-isolation.
class MHTMLGenerationSitePerProcessTest : public MHTMLGenerationTest {

Powered by Google App Engine
This is Rietveld 408576698