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

Side by Side Diff: content/browser/download/mhtml_generation_browsertest.cc

Issue 2175933002: More aggressive IO asserts in content_browsertests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use 1 less instance of ScopedAllowIO in DumpAccessibilityTestBase::RunTestForPlatform. Created 4 years, 4 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 unified diff | Download patch
OLDNEW
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"
11 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "base/threading/thread_restrictions.h"
15 #include "content/browser/renderer_host/render_process_host_impl.h" 16 #include "content/browser/renderer_host/render_process_host_impl.h"
16 #include "content/common/frame_messages.h" 17 #include "content/common/frame_messages.h"
17 #include "content/public/browser/render_process_host.h" 18 #include "content/public/browser/render_process_host.h"
18 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
19 #include "content/public/common/mhtml_generation_params.h" 20 #include "content/public/common/mhtml_generation_params.h"
20 #include "content/public/test/browser_test_utils.h" 21 #include "content/public/test/browser_test_utils.h"
21 #include "content/public/test/content_browser_test.h" 22 #include "content/public/test/content_browser_test.h"
22 #include "content/public/test/content_browser_test_utils.h" 23 #include "content/public/test/content_browser_test_utils.h"
23 #include "content/public/test/test_utils.h" 24 #include "content/public/test/test_utils.h"
24 #include "content/shell/browser/shell.h" 25 #include "content/shell/browser/shell.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 params, base::Bind(&MHTMLGenerationTest::MHTMLGenerated, this, 116 params, base::Bind(&MHTMLGenerationTest::MHTMLGenerated, this,
116 run_loop.QuitClosure())); 117 run_loop.QuitClosure()));
117 118
118 // Block until the MHTML is generated. 119 // Block until the MHTML is generated.
119 run_loop.Run(); 120 run_loop.Run();
120 121
121 EXPECT_TRUE(has_mhtml_callback_run()); 122 EXPECT_TRUE(has_mhtml_callback_run());
122 } 123 }
123 124
124 int64_t ReadFileSizeFromDisk(base::FilePath path) { 125 int64_t ReadFileSizeFromDisk(base::FilePath path) {
126 base::ThreadRestrictions::ScopedAllowIO allow_io_to_test_file_size;
125 int64_t file_size; 127 int64_t file_size;
126 if (!base::GetFileSize(path, &file_size)) return -1; 128 if (!base::GetFileSize(path, &file_size)) return -1;
127 return file_size; 129 return file_size;
128 } 130 }
129 131
130 void TestOriginalVsSavedPage( 132 void TestOriginalVsSavedPage(
131 const GURL& url, 133 const GURL& url,
132 const MHTMLGenerationParams params, 134 const MHTMLGenerationParams params,
133 int expected_number_of_frames, 135 int expected_number_of_frames,
134 const std::vector<std::string>& expected_substrings, 136 const std::vector<std::string>& expected_substrings,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 base::FilePath path(temp_dir_.path()); 215 base::FilePath path(temp_dir_.path());
214 path = path.Append(FILE_PATH_LITERAL("test.mht")); 216 path = path.Append(FILE_PATH_LITERAL("test.mht"));
215 217
216 GenerateMHTML(path, embedded_test_server()->GetURL("/simple_page.html")); 218 GenerateMHTML(path, embedded_test_server()->GetURL("/simple_page.html"));
217 ASSERT_FALSE(HasFailure()); 219 ASSERT_FALSE(HasFailure());
218 220
219 // Make sure the actual generated file has some contents. 221 // Make sure the actual generated file has some contents.
220 EXPECT_GT(file_size(), 0); // Verify the size reported by the callback. 222 EXPECT_GT(file_size(), 0); // Verify the size reported by the callback.
221 EXPECT_GT(ReadFileSizeFromDisk(path), 100); // Verify the actual file size. 223 EXPECT_GT(ReadFileSizeFromDisk(path), 100); // Verify the actual file size.
222 224
223 std::string mhtml; 225 {
224 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); 226 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification;
225 EXPECT_THAT(mhtml, 227 std::string mhtml;
226 HasSubstr("Content-Transfer-Encoding: quoted-printable")); 228 ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
229 EXPECT_THAT(mhtml,
230 HasSubstr("Content-Transfer-Encoding: quoted-printable"));
231 }
227 } 232 }
228 233
229 class GenerateMHTMLAndExitRendererMessageFilter : public BrowserMessageFilter { 234 class GenerateMHTMLAndExitRendererMessageFilter : public BrowserMessageFilter {
230 public: 235 public:
231 GenerateMHTMLAndExitRendererMessageFilter( 236 GenerateMHTMLAndExitRendererMessageFilter(
232 RenderProcessHostImpl* render_process_host) 237 RenderProcessHostImpl* render_process_host)
233 : BrowserMessageFilter(FrameMsgStart), 238 : BrowserMessageFilter(FrameMsgStart),
234 render_process_host_(render_process_host) {} 239 render_process_host_(render_process_host) {}
235 240
236 protected: 241 protected:
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateNonBinaryMHTMLWithImage) { 362 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateNonBinaryMHTMLWithImage) {
358 base::FilePath path(temp_dir_.path()); 363 base::FilePath path(temp_dir_.path());
359 path = path.Append(FILE_PATH_LITERAL("test_binary.mht")); 364 path = path.Append(FILE_PATH_LITERAL("test_binary.mht"));
360 365
361 GURL url(embedded_test_server()->GetURL("/page_with_image.html")); 366 GURL url(embedded_test_server()->GetURL("/page_with_image.html"));
362 GenerateMHTML(path, url); 367 GenerateMHTML(path, url);
363 ASSERT_FALSE(HasFailure()); 368 ASSERT_FALSE(HasFailure());
364 EXPECT_GT(file_size(), 0); // Verify the size reported by the callback. 369 EXPECT_GT(file_size(), 0); // Verify the size reported by the callback.
365 EXPECT_GT(ReadFileSizeFromDisk(path), 100); // Verify the actual file size. 370 EXPECT_GT(ReadFileSizeFromDisk(path), 100); // Verify the actual file size.
366 371
367 std::string mhtml; 372 {
368 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); 373 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification;
369 EXPECT_THAT(mhtml, HasSubstr("Content-Transfer-Encoding: base64")); 374 std::string mhtml;
370 EXPECT_THAT(mhtml, Not(HasSubstr("Content-Transfer-Encoding: binary"))); 375 ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
371 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*blank.jpg")); 376 EXPECT_THAT(mhtml, HasSubstr("Content-Transfer-Encoding: base64"));
377 EXPECT_THAT(mhtml, Not(HasSubstr("Content-Transfer-Encoding: binary")));
378 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*blank.jpg"));
379 }
372 } 380 }
373 381
374 // Tests that MHTML generated using the binary encoding contains the 'binary' 382 // Tests that MHTML generated using the binary encoding contains the 'binary'
375 // Content-Transfer-Encoding header, and does not contain any base64 encoded 383 // Content-Transfer-Encoding header, and does not contain any base64 encoded
376 // parts. 384 // parts.
377 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateBinaryMHTMLWithImage) { 385 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateBinaryMHTMLWithImage) {
378 base::FilePath path(temp_dir_.path()); 386 base::FilePath path(temp_dir_.path());
379 path = path.Append(FILE_PATH_LITERAL("test_binary.mht")); 387 path = path.Append(FILE_PATH_LITERAL("test_binary.mht"));
380 388
381 GURL url(embedded_test_server()->GetURL("/page_with_image.html")); 389 GURL url(embedded_test_server()->GetURL("/page_with_image.html"));
382 MHTMLGenerationParams params(path); 390 MHTMLGenerationParams params(path);
383 params.use_binary_encoding = true; 391 params.use_binary_encoding = true;
384 392
385 GenerateMHTML(params, url); 393 GenerateMHTML(params, url);
386 ASSERT_FALSE(HasFailure()); 394 ASSERT_FALSE(HasFailure());
387 EXPECT_GT(file_size(), 0); // Verify the size reported by the callback. 395 EXPECT_GT(file_size(), 0); // Verify the size reported by the callback.
388 EXPECT_GT(ReadFileSizeFromDisk(path), 100); // Verify the actual file size. 396 EXPECT_GT(ReadFileSizeFromDisk(path), 100); // Verify the actual file size.
389 397
390 std::string mhtml; 398 {
391 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); 399 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification;
392 EXPECT_THAT(mhtml, HasSubstr("Content-Transfer-Encoding: binary")); 400 std::string mhtml;
393 EXPECT_THAT(mhtml, Not(HasSubstr("Content-Transfer-Encoding: base64"))); 401 ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
394 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*blank.jpg")); 402 EXPECT_THAT(mhtml, HasSubstr("Content-Transfer-Encoding: binary"));
403 EXPECT_THAT(mhtml, Not(HasSubstr("Content-Transfer-Encoding: base64")));
404 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*blank.jpg"));
405 }
395 } 406 }
396 407
397 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLIgnoreNoStore) { 408 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLIgnoreNoStore) {
398 base::FilePath path(temp_dir_.path()); 409 base::FilePath path(temp_dir_.path());
399 path = path.Append(FILE_PATH_LITERAL("test.mht")); 410 path = path.Append(FILE_PATH_LITERAL("test.mht"));
400 411
401 GURL url(embedded_test_server()->GetURL("/nostore.html")); 412 GURL url(embedded_test_server()->GetURL("/nostore.html"));
402 413
403 // Generate MHTML without specifying the FailForNoStoreMainFrame policy. 414 // Generate MHTML without specifying the FailForNoStoreMainFrame policy.
404 GenerateMHTML(path, url); 415 GenerateMHTML(path, url);
405 416
406 // We expect that there wasn't an error (file size -1 indicates an error.) 417 // We expect that there wasn't an error (file size -1 indicates an error.)
407 ASSERT_FALSE(HasFailure()); 418 ASSERT_FALSE(HasFailure());
408 419
409 std::string mhtml; 420 std::string mhtml;
410 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); 421 {
422 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification;
423 ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
424 }
411 425
412 // Make sure the contents of the body are present. 426 // Make sure the contents of the body are present.
413 EXPECT_THAT(mhtml, HasSubstr("test body")); 427 EXPECT_THAT(mhtml, HasSubstr("test body"));
414 428
415 // Make sure that URL of the content is present. 429 // Make sure that URL of the content is present.
416 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*/nostore.html")); 430 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*/nostore.html"));
417 } 431 }
418 432
419 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLObeyNoStoreMainFrame) { 433 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLObeyNoStoreMainFrame) {
420 base::FilePath path(temp_dir_.path()); 434 base::FilePath path(temp_dir_.path());
421 path = path.Append(FILE_PATH_LITERAL("test.mht")); 435 path = path.Append(FILE_PATH_LITERAL("test.mht"));
422 436
423 GURL url(embedded_test_server()->GetURL("/nostore.html")); 437 GURL url(embedded_test_server()->GetURL("/nostore.html"));
424 438
425 // Generate MHTML, specifying the FailForNoStoreMainFrame policy. 439 // Generate MHTML, specifying the FailForNoStoreMainFrame policy.
426 MHTMLGenerationParams params(path); 440 MHTMLGenerationParams params(path);
427 params.cache_control_policy = 441 params.cache_control_policy =
428 blink::WebFrameSerializerCacheControlPolicy::FailForNoStoreMainFrame; 442 blink::WebFrameSerializerCacheControlPolicy::FailForNoStoreMainFrame;
429 443
430 GenerateMHTML(params, url); 444 GenerateMHTML(params, url);
431 // We expect that there was an error (file size -1 indicates an error.) 445 // We expect that there was an error (file size -1 indicates an error.)
432 EXPECT_EQ(-1, file_size()); 446 EXPECT_EQ(-1, file_size());
433 447
434 std::string mhtml; 448 std::string mhtml;
435 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); 449 {
450 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification;
451 ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
452 }
436 453
437 // Make sure the contents are missing. 454 // Make sure the contents are missing.
438 EXPECT_THAT(mhtml, Not(HasSubstr("test body"))); 455 EXPECT_THAT(mhtml, Not(HasSubstr("test body")));
439 } 456 }
440 457
441 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, 458 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest,
442 GenerateMHTMLIgnoreNoStoreSubFrame) { 459 GenerateMHTMLIgnoreNoStoreSubFrame) {
443 base::FilePath path(temp_dir_.path()); 460 base::FilePath path(temp_dir_.path());
444 path = path.Append(FILE_PATH_LITERAL("test.mht")); 461 path = path.Append(FILE_PATH_LITERAL("test.mht"));
445 462
446 GURL url(embedded_test_server()->GetURL("/page_with_nostore_iframe.html")); 463 GURL url(embedded_test_server()->GetURL("/page_with_nostore_iframe.html"));
447 464
448 // Generate MHTML, specifying the FailForNoStoreMainFrame policy. 465 // Generate MHTML, specifying the FailForNoStoreMainFrame policy.
449 MHTMLGenerationParams params(path); 466 MHTMLGenerationParams params(path);
450 params.cache_control_policy = 467 params.cache_control_policy =
451 blink::WebFrameSerializerCacheControlPolicy::FailForNoStoreMainFrame; 468 blink::WebFrameSerializerCacheControlPolicy::FailForNoStoreMainFrame;
452 469
453 GenerateMHTML(params, url); 470 GenerateMHTML(params, url);
454 // We expect that there was no error (file size -1 indicates an error.) 471 // We expect that there was no error (file size -1 indicates an error.)
455 EXPECT_LT(0, file_size()); 472 EXPECT_LT(0, file_size());
456 473
457 std::string mhtml; 474 std::string mhtml;
458 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); 475 {
476 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification;
477 ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
478 }
459 479
460 EXPECT_THAT(mhtml, HasSubstr("Main Frame")); 480 EXPECT_THAT(mhtml, HasSubstr("Main Frame"));
461 // Make sure that no-store subresources exist in this mode. 481 // Make sure that no-store subresources exist in this mode.
462 EXPECT_THAT(mhtml, HasSubstr("no-store test body")); 482 EXPECT_THAT(mhtml, HasSubstr("no-store test body"));
463 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*nostore.jpg")); 483 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*nostore.jpg"));
464 } 484 }
465 485
466 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLObeyNoStoreSubFrame) { 486 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLObeyNoStoreSubFrame) {
467 base::FilePath path(temp_dir_.path()); 487 base::FilePath path(temp_dir_.path());
468 path = path.Append(FILE_PATH_LITERAL("test.mht")); 488 path = path.Append(FILE_PATH_LITERAL("test.mht"));
469 489
470 GURL url(embedded_test_server()->GetURL("/page_with_nostore_iframe.html")); 490 GURL url(embedded_test_server()->GetURL("/page_with_nostore_iframe.html"));
471 491
472 // Generate MHTML, specifying the FailForNoStoreMainFrame policy. 492 // Generate MHTML, specifying the FailForNoStoreMainFrame policy.
473 MHTMLGenerationParams params(path); 493 MHTMLGenerationParams params(path);
474 params.cache_control_policy = blink::WebFrameSerializerCacheControlPolicy:: 494 params.cache_control_policy = blink::WebFrameSerializerCacheControlPolicy::
475 SkipAnyFrameOrResourceMarkedNoStore; 495 SkipAnyFrameOrResourceMarkedNoStore;
476 496
477 GenerateMHTML(params, url); 497 GenerateMHTML(params, url);
478 // We expect that there was no error (file size -1 indicates an error.) 498 // We expect that there was no error (file size -1 indicates an error.)
479 EXPECT_LT(0, file_size()); 499 EXPECT_LT(0, file_size());
480 500
481 std::string mhtml; 501 std::string mhtml;
482 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); 502 {
503 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification;
504 ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
505 }
483 506
484 EXPECT_THAT(mhtml, HasSubstr("Main Frame")); 507 EXPECT_THAT(mhtml, HasSubstr("Main Frame"));
485 // Make sure the contents are missing. 508 // Make sure the contents are missing.
486 EXPECT_THAT(mhtml, Not(HasSubstr("no-store test body"))); 509 EXPECT_THAT(mhtml, Not(HasSubstr("no-store test body")));
487 // This image comes from a resource marked no-store. 510 // This image comes from a resource marked no-store.
488 EXPECT_THAT(mhtml, Not(ContainsRegex("Content-Location:.*nostore.jpg"))); 511 EXPECT_THAT(mhtml, Not(ContainsRegex("Content-Location:.*nostore.jpg")));
489 } 512 }
490 513
491 // TODO(crbug.com/615291): These fail on Android under some circumstances. 514 // TODO(crbug.com/615291): These fail on Android under some circumstances.
492 #if defined(OS_ANDROID) 515 #if defined(OS_ANDROID)
(...skipping 19 matching lines...) Expand all
512 // No special cache control options so we should see both frames. 535 // No special cache control options so we should see both frames.
513 std::vector<std::string> expectations = { 536 std::vector<std::string> expectations = {
514 "Main Frame, normal headers.", "Cache-Control: no-store test body", 537 "Main Frame, normal headers.", "Cache-Control: no-store test body",
515 }; 538 };
516 std::vector<std::string> forbidden; 539 std::vector<std::string> forbidden;
517 TestOriginalVsSavedPage( 540 TestOriginalVsSavedPage(
518 embedded_test_server()->GetURL("/page_with_nostore_iframe.html"), params, 541 embedded_test_server()->GetURL("/page_with_nostore_iframe.html"), params,
519 2 /* expected number of frames */, expectations, forbidden); 542 2 /* expected number of frames */, expectations, forbidden);
520 543
521 std::string mhtml; 544 std::string mhtml;
522 ASSERT_TRUE(base::ReadFileToString(params.file_path, &mhtml)); 545 {
546 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification;
547 ASSERT_TRUE(base::ReadFileToString(params.file_path, &mhtml));
548 }
523 } 549 }
524 550
525 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, 551 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest,
526 MAYBE_ViewedMHTMLDoesNotContainNoStoreContent) { 552 MAYBE_ViewedMHTMLDoesNotContainNoStoreContent) {
527 // Generate MHTML, specifying the FailForNoStoreMainFrame policy. 553 // Generate MHTML, specifying the FailForNoStoreMainFrame policy.
528 base::FilePath path(temp_dir_.path()); 554 base::FilePath path(temp_dir_.path());
529 path = path.Append(FILE_PATH_LITERAL("test.mht")); 555 path = path.Append(FILE_PATH_LITERAL("test.mht"));
530 MHTMLGenerationParams params(path); 556 MHTMLGenerationParams params(path);
531 params.cache_control_policy = blink::WebFrameSerializerCacheControlPolicy:: 557 params.cache_control_policy = blink::WebFrameSerializerCacheControlPolicy::
532 SkipAnyFrameOrResourceMarkedNoStore; 558 SkipAnyFrameOrResourceMarkedNoStore;
533 559
534 // No special cache control options so we should see both frames. 560 // No special cache control options so we should see both frames.
535 std::vector<std::string> expectations = { 561 std::vector<std::string> expectations = {
536 "Main Frame, normal headers.", 562 "Main Frame, normal headers.",
537 }; 563 };
538 std::vector<std::string> forbidden = { 564 std::vector<std::string> forbidden = {
539 "Cache-Control: no-store test body", 565 "Cache-Control: no-store test body",
540 }; 566 };
541 TestOriginalVsSavedPage( 567 TestOriginalVsSavedPage(
542 embedded_test_server()->GetURL("/page_with_nostore_iframe.html"), params, 568 embedded_test_server()->GetURL("/page_with_nostore_iframe.html"), params,
543 2 /* expected number of frames */, expectations, forbidden); 569 2 /* expected number of frames */, expectations, forbidden);
544 570
545 std::string mhtml; 571 std::string mhtml;
546 ASSERT_TRUE(base::ReadFileToString(params.file_path, &mhtml)); 572 {
573 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification;
574 ASSERT_TRUE(base::ReadFileToString(params.file_path, &mhtml));
575 }
547 } 576 }
548 577
549 // Test suite that allows testing --site-per-process against cross-site frames. 578 // Test suite that allows testing --site-per-process against cross-site frames.
550 // See http://dev.chromium.org/developers/design-documents/site-isolation. 579 // See http://dev.chromium.org/developers/design-documents/site-isolation.
551 class MHTMLGenerationSitePerProcessTest : public MHTMLGenerationTest { 580 class MHTMLGenerationSitePerProcessTest : public MHTMLGenerationTest {
552 public: 581 public:
553 MHTMLGenerationSitePerProcessTest() {} 582 MHTMLGenerationSitePerProcessTest() {}
554 583
555 protected: 584 protected:
556 void SetUpCommandLine(base::CommandLine* command_line) override { 585 void SetUpCommandLine(base::CommandLine* command_line) override {
(...skipping 19 matching lines...) Expand all
576 IN_PROC_BROWSER_TEST_F(MHTMLGenerationSitePerProcessTest, GenerateMHTML) { 605 IN_PROC_BROWSER_TEST_F(MHTMLGenerationSitePerProcessTest, GenerateMHTML) {
577 base::FilePath path(temp_dir_.path()); 606 base::FilePath path(temp_dir_.path());
578 path = path.Append(FILE_PATH_LITERAL("test.mht")); 607 path = path.Append(FILE_PATH_LITERAL("test.mht"));
579 608
580 GURL url(embedded_test_server()->GetURL( 609 GURL url(embedded_test_server()->GetURL(
581 "a.com", "/frame_tree/page_with_one_frame.html")); 610 "a.com", "/frame_tree/page_with_one_frame.html"));
582 GenerateMHTML(path, url); 611 GenerateMHTML(path, url);
583 ASSERT_FALSE(HasFailure()); 612 ASSERT_FALSE(HasFailure());
584 613
585 std::string mhtml; 614 std::string mhtml;
586 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); 615 {
616 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification;
617 ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
618 }
587 619
588 // Make sure the contents of both frames are present. 620 // Make sure the contents of both frames are present.
589 EXPECT_THAT(mhtml, HasSubstr("This page has one cross-site iframe")); 621 EXPECT_THAT(mhtml, HasSubstr("This page has one cross-site iframe"));
590 EXPECT_THAT(mhtml, HasSubstr("This page has no title")); // From title1.html. 622 EXPECT_THAT(mhtml, HasSubstr("This page has no title")); // From title1.html.
591 623
592 // Make sure that URLs of both frames are present 624 // Make sure that URLs of both frames are present
593 // (note that these are single-line regexes). 625 // (note that these are single-line regexes).
594 EXPECT_THAT( 626 EXPECT_THAT(
595 mhtml, 627 mhtml,
596 ContainsRegex("Content-Location:.*/frame_tree/page_with_one_frame.html")); 628 ContainsRegex("Content-Location:.*/frame_tree/page_with_one_frame.html"));
597 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*/title1.html")); 629 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*/title1.html"));
598 } 630 }
599 631
600 } // namespace content 632 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_browsertest.cc ('k') | content/browser/indexed_db/indexed_db_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698