OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 // We expect that there was an error (file size -1 indicates an error.) | 192 // We expect that there was an error (file size -1 indicates an error.) |
193 EXPECT_EQ(-1, file_size()); | 193 EXPECT_EQ(-1, file_size()); |
194 | 194 |
195 std::string mhtml; | 195 std::string mhtml; |
196 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); | 196 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); |
197 | 197 |
198 // Make sure the contents are missing. | 198 // Make sure the contents are missing. |
199 EXPECT_THAT(mhtml, Not(HasSubstr("test body"))); | 199 EXPECT_THAT(mhtml, Not(HasSubstr("test body"))); |
200 } | 200 } |
201 | 201 |
202 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, | |
203 GenerateMHTMLIgnoreNoStoreSubFrame) { | |
204 base::FilePath path(temp_dir_.path()); | |
205 path = path.Append(FILE_PATH_LITERAL("test.mht")); | |
206 | |
207 GURL url(embedded_test_server()->GetURL("/contains_nostore_iframe.html")); | |
208 | |
209 // Generate MHTML, specifying the FAIL_FOR_NO_STORE_MAIN_FRAME policy. | |
210 MHTMLGenerationParams params(path); | |
211 params.cache_control_policy = | |
212 content::MHTMLCacheControlPolicy::FAIL_FOR_NO_STORE_MAIN_FRAME; | |
213 | |
214 GenerateMHTML(params, url); | |
215 // We expect that there was no error (file size -1 indicates an error.) | |
216 EXPECT_LT(0, file_size()); | |
217 | |
218 std::string mhtml; | |
219 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); | |
220 | |
221 // Make sure that no-store subresources exist in this mode. | |
222 EXPECT_THAT(mhtml, HasSubstr("no-store test body")); | |
223 } | |
224 | |
225 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLObeyNoStoreSubFrame) { | |
226 base::FilePath path(temp_dir_.path()); | |
227 path = path.Append(FILE_PATH_LITERAL("test.mht")); | |
228 | |
229 GURL url(embedded_test_server()->GetURL("/contains_nostore_iframe.html")); | |
230 | |
231 // Generate MHTML, specifying the FAIL_FOR_NO_STORE_MAIN_FRAME policy. | |
232 MHTMLGenerationParams params(path); | |
233 params.cache_control_policy = content::MHTMLCacheControlPolicy:: | |
234 SKIP_ANY_FRAME_OR_RESOURCE_MARKED_NO_STORE; | |
235 | |
236 GenerateMHTML(params, url); | |
237 // We expect that there was no error (file size -1 indicates an error.) | |
238 EXPECT_LT(0, file_size()); | |
239 | |
240 std::string mhtml; | |
241 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); | |
242 | |
243 // Make sure the contents are missing. | |
244 EXPECT_THAT(mhtml, Not(HasSubstr("no-store test body"))); | |
245 } | |
246 | |
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
| |
202 // Test suite that allows testing --site-per-process against cross-site frames. | 247 // Test suite that allows testing --site-per-process against cross-site frames. |
203 // See http://dev.chromium.org/developers/design-documents/site-isolation. | 248 // See http://dev.chromium.org/developers/design-documents/site-isolation. |
204 class MHTMLGenerationSitePerProcessTest : public MHTMLGenerationTest { | 249 class MHTMLGenerationSitePerProcessTest : public MHTMLGenerationTest { |
205 public: | 250 public: |
206 MHTMLGenerationSitePerProcessTest() {} | 251 MHTMLGenerationSitePerProcessTest() {} |
207 | 252 |
208 protected: | 253 protected: |
209 void SetUpCommandLine(base::CommandLine* command_line) override { | 254 void SetUpCommandLine(base::CommandLine* command_line) override { |
210 MHTMLGenerationTest::SetUpCommandLine(command_line); | 255 MHTMLGenerationTest::SetUpCommandLine(command_line); |
211 | 256 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 | 289 |
245 // Make sure that URLs of both frames are present | 290 // Make sure that URLs of both frames are present |
246 // (note that these are single-line regexes). | 291 // (note that these are single-line regexes). |
247 EXPECT_THAT( | 292 EXPECT_THAT( |
248 mhtml, | 293 mhtml, |
249 ContainsRegex("Content-Location:.*/frame_tree/page_with_one_frame.html")); | 294 ContainsRegex("Content-Location:.*/frame_tree/page_with_one_frame.html")); |
250 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*/title1.html")); | 295 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*/title1.html")); |
251 } | 296 } |
252 | 297 |
253 } // namespace content | 298 } // namespace content |
OLD | NEW |