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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 206 |
207 bool has_mhtml_callback_run_; | 207 bool has_mhtml_callback_run_; |
208 int64_t file_size_; | 208 int64_t file_size_; |
209 }; | 209 }; |
210 | 210 |
211 // Tests that generating a MHTML does create contents. | 211 // Tests that generating a MHTML does create contents. |
212 // Note that the actual content of the file is not tested, the purpose of this | 212 // Note that the actual content of the file is not tested, the purpose of this |
213 // test is to ensure we were successful in creating the MHTML data from the | 213 // test is to ensure we were successful in creating the MHTML data from the |
214 // renderer. | 214 // renderer. |
215 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTML) { | 215 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTML) { |
216 base::FilePath path(temp_dir_.path()); | 216 base::FilePath path(temp_dir_.GetPath()); |
217 path = path.Append(FILE_PATH_LITERAL("test.mht")); | 217 path = path.Append(FILE_PATH_LITERAL("test.mht")); |
218 | 218 |
219 GenerateMHTML(path, embedded_test_server()->GetURL("/simple_page.html")); | 219 GenerateMHTML(path, embedded_test_server()->GetURL("/simple_page.html")); |
220 ASSERT_FALSE(HasFailure()); | 220 ASSERT_FALSE(HasFailure()); |
221 | 221 |
222 // Make sure the actual generated file has some contents. | 222 // Make sure the actual generated file has some contents. |
223 EXPECT_GT(file_size(), 0); // Verify the size reported by the callback. | 223 EXPECT_GT(file_size(), 0); // Verify the size reported by the callback. |
224 EXPECT_GT(ReadFileSizeFromDisk(path), 100); // Verify the actual file size. | 224 EXPECT_GT(ReadFileSizeFromDisk(path), 100); // Verify the actual file size. |
225 | 225 |
226 { | 226 { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLAndExitRenderer) { | 333 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLAndExitRenderer) { |
334 NavigateToURL(shell(), embedded_test_server()->GetURL("/simple_page.html")); | 334 NavigateToURL(shell(), embedded_test_server()->GetURL("/simple_page.html")); |
335 | 335 |
336 RenderProcessHostImpl* render_process_host = | 336 RenderProcessHostImpl* render_process_host = |
337 static_cast<RenderProcessHostImpl*>( | 337 static_cast<RenderProcessHostImpl*>( |
338 shell()->web_contents()->GetRenderProcessHost()); | 338 shell()->web_contents()->GetRenderProcessHost()); |
339 scoped_refptr<BrowserMessageFilter> filter = | 339 scoped_refptr<BrowserMessageFilter> filter = |
340 new GenerateMHTMLAndExitRendererMessageFilter(render_process_host); | 340 new GenerateMHTMLAndExitRendererMessageFilter(render_process_host); |
341 render_process_host->AddFilter(filter.get()); | 341 render_process_host->AddFilter(filter.get()); |
342 | 342 |
343 base::FilePath path(temp_dir_.path()); | 343 base::FilePath path(temp_dir_.GetPath()); |
344 path = path.Append(FILE_PATH_LITERAL("test.mht")); | 344 path = path.Append(FILE_PATH_LITERAL("test.mht")); |
345 GenerateMHTMLForCurrentPage(MHTMLGenerationParams(path)); | 345 GenerateMHTMLForCurrentPage(MHTMLGenerationParams(path)); |
346 | 346 |
347 EXPECT_GT(ReadFileSizeFromDisk(path), 100); // Verify the actual file size. | 347 EXPECT_GT(ReadFileSizeFromDisk(path), 100); // Verify the actual file size. |
348 } | 348 } |
349 | 349 |
350 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, InvalidPath) { | 350 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, InvalidPath) { |
351 base::FilePath path(FILE_PATH_LITERAL("/invalid/file/path")); | 351 base::FilePath path(FILE_PATH_LITERAL("/invalid/file/path")); |
352 | 352 |
353 GenerateMHTML(path, embedded_test_server()->GetURL( | 353 GenerateMHTML(path, embedded_test_server()->GetURL( |
354 "/download/local-about-blank-subframes.html")); | 354 "/download/local-about-blank-subframes.html")); |
355 ASSERT_FALSE(HasFailure()); // No failures with the invocation itself? | 355 ASSERT_FALSE(HasFailure()); // No failures with the invocation itself? |
356 | 356 |
357 EXPECT_EQ(file_size(), -1); // Expecting that the callback reported failure. | 357 EXPECT_EQ(file_size(), -1); // Expecting that the callback reported failure. |
358 } | 358 } |
359 | 359 |
360 // Tests that MHTML generated using the default 'quoted-printable' encoding does | 360 // Tests that MHTML generated using the default 'quoted-printable' encoding does |
361 // not contain the 'binary' Content-Transfer-Encoding header, and generates | 361 // not contain the 'binary' Content-Transfer-Encoding header, and generates |
362 // base64 encoding for the image part. | 362 // base64 encoding for the image part. |
363 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateNonBinaryMHTMLWithImage) { | 363 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateNonBinaryMHTMLWithImage) { |
364 base::FilePath path(temp_dir_.path()); | 364 base::FilePath path(temp_dir_.GetPath()); |
365 path = path.Append(FILE_PATH_LITERAL("test_binary.mht")); | 365 path = path.Append(FILE_PATH_LITERAL("test_binary.mht")); |
366 | 366 |
367 GURL url(embedded_test_server()->GetURL("/page_with_image.html")); | 367 GURL url(embedded_test_server()->GetURL("/page_with_image.html")); |
368 GenerateMHTML(path, url); | 368 GenerateMHTML(path, url); |
369 ASSERT_FALSE(HasFailure()); | 369 ASSERT_FALSE(HasFailure()); |
370 EXPECT_GT(file_size(), 0); // Verify the size reported by the callback. | 370 EXPECT_GT(file_size(), 0); // Verify the size reported by the callback. |
371 EXPECT_GT(ReadFileSizeFromDisk(path), 100); // Verify the actual file size. | 371 EXPECT_GT(ReadFileSizeFromDisk(path), 100); // Verify the actual file size. |
372 | 372 |
373 { | 373 { |
374 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; | 374 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; |
375 std::string mhtml; | 375 std::string mhtml; |
376 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); | 376 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); |
377 EXPECT_THAT(mhtml, HasSubstr("Content-Transfer-Encoding: base64")); | 377 EXPECT_THAT(mhtml, HasSubstr("Content-Transfer-Encoding: base64")); |
378 EXPECT_THAT(mhtml, Not(HasSubstr("Content-Transfer-Encoding: binary"))); | 378 EXPECT_THAT(mhtml, Not(HasSubstr("Content-Transfer-Encoding: binary"))); |
379 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*blank.jpg")); | 379 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*blank.jpg")); |
380 } | 380 } |
381 } | 381 } |
382 | 382 |
383 // Tests that MHTML generated using the binary encoding contains the 'binary' | 383 // Tests that MHTML generated using the binary encoding contains the 'binary' |
384 // Content-Transfer-Encoding header, and does not contain any base64 encoded | 384 // Content-Transfer-Encoding header, and does not contain any base64 encoded |
385 // parts. | 385 // parts. |
386 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateBinaryMHTMLWithImage) { | 386 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateBinaryMHTMLWithImage) { |
387 base::FilePath path(temp_dir_.path()); | 387 base::FilePath path(temp_dir_.GetPath()); |
388 path = path.Append(FILE_PATH_LITERAL("test_binary.mht")); | 388 path = path.Append(FILE_PATH_LITERAL("test_binary.mht")); |
389 | 389 |
390 GURL url(embedded_test_server()->GetURL("/page_with_image.html")); | 390 GURL url(embedded_test_server()->GetURL("/page_with_image.html")); |
391 MHTMLGenerationParams params(path); | 391 MHTMLGenerationParams params(path); |
392 params.use_binary_encoding = true; | 392 params.use_binary_encoding = true; |
393 | 393 |
394 GenerateMHTML(params, url); | 394 GenerateMHTML(params, url); |
395 ASSERT_FALSE(HasFailure()); | 395 ASSERT_FALSE(HasFailure()); |
396 EXPECT_GT(file_size(), 0); // Verify the size reported by the callback. | 396 EXPECT_GT(file_size(), 0); // Verify the size reported by the callback. |
397 EXPECT_GT(ReadFileSizeFromDisk(path), 100); // Verify the actual file size. | 397 EXPECT_GT(ReadFileSizeFromDisk(path), 100); // Verify the actual file size. |
398 | 398 |
399 { | 399 { |
400 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; | 400 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; |
401 std::string mhtml; | 401 std::string mhtml; |
402 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); | 402 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); |
403 EXPECT_THAT(mhtml, HasSubstr("Content-Transfer-Encoding: binary")); | 403 EXPECT_THAT(mhtml, HasSubstr("Content-Transfer-Encoding: binary")); |
404 EXPECT_THAT(mhtml, Not(HasSubstr("Content-Transfer-Encoding: base64"))); | 404 EXPECT_THAT(mhtml, Not(HasSubstr("Content-Transfer-Encoding: base64"))); |
405 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*blank.jpg")); | 405 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*blank.jpg")); |
406 } | 406 } |
407 } | 407 } |
408 | 408 |
409 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLIgnoreNoStore) { | 409 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLIgnoreNoStore) { |
410 base::FilePath path(temp_dir_.path()); | 410 base::FilePath path(temp_dir_.GetPath()); |
411 path = path.Append(FILE_PATH_LITERAL("test.mht")); | 411 path = path.Append(FILE_PATH_LITERAL("test.mht")); |
412 | 412 |
413 GURL url(embedded_test_server()->GetURL("/nostore.html")); | 413 GURL url(embedded_test_server()->GetURL("/nostore.html")); |
414 | 414 |
415 // Generate MHTML without specifying the FailForNoStoreMainFrame policy. | 415 // Generate MHTML without specifying the FailForNoStoreMainFrame policy. |
416 GenerateMHTML(path, url); | 416 GenerateMHTML(path, url); |
417 | 417 |
418 // We expect that there wasn't an error (file size -1 indicates an error.) | 418 // We expect that there wasn't an error (file size -1 indicates an error.) |
419 ASSERT_FALSE(HasFailure()); | 419 ASSERT_FALSE(HasFailure()); |
420 | 420 |
421 std::string mhtml; | 421 std::string mhtml; |
422 { | 422 { |
423 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; | 423 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; |
424 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); | 424 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); |
425 } | 425 } |
426 | 426 |
427 // Make sure the contents of the body are present. | 427 // Make sure the contents of the body are present. |
428 EXPECT_THAT(mhtml, HasSubstr("test body")); | 428 EXPECT_THAT(mhtml, HasSubstr("test body")); |
429 | 429 |
430 // Make sure that URL of the content is present. | 430 // Make sure that URL of the content is present. |
431 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*/nostore.html")); | 431 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*/nostore.html")); |
432 } | 432 } |
433 | 433 |
434 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLObeyNoStoreMainFrame) { | 434 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLObeyNoStoreMainFrame) { |
435 base::FilePath path(temp_dir_.path()); | 435 base::FilePath path(temp_dir_.GetPath()); |
436 path = path.Append(FILE_PATH_LITERAL("test.mht")); | 436 path = path.Append(FILE_PATH_LITERAL("test.mht")); |
437 | 437 |
438 GURL url(embedded_test_server()->GetURL("/nostore.html")); | 438 GURL url(embedded_test_server()->GetURL("/nostore.html")); |
439 | 439 |
440 // Generate MHTML, specifying the FailForNoStoreMainFrame policy. | 440 // Generate MHTML, specifying the FailForNoStoreMainFrame policy. |
441 MHTMLGenerationParams params(path); | 441 MHTMLGenerationParams params(path); |
442 params.cache_control_policy = | 442 params.cache_control_policy = |
443 blink::WebFrameSerializerCacheControlPolicy::FailForNoStoreMainFrame; | 443 blink::WebFrameSerializerCacheControlPolicy::FailForNoStoreMainFrame; |
444 | 444 |
445 GenerateMHTML(params, url); | 445 GenerateMHTML(params, url); |
446 // We expect that there was an error (file size -1 indicates an error.) | 446 // We expect that there was an error (file size -1 indicates an error.) |
447 EXPECT_EQ(-1, file_size()); | 447 EXPECT_EQ(-1, file_size()); |
448 | 448 |
449 std::string mhtml; | 449 std::string mhtml; |
450 { | 450 { |
451 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; | 451 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; |
452 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); | 452 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); |
453 } | 453 } |
454 | 454 |
455 // Make sure the contents are missing. | 455 // Make sure the contents are missing. |
456 EXPECT_THAT(mhtml, Not(HasSubstr("test body"))); | 456 EXPECT_THAT(mhtml, Not(HasSubstr("test body"))); |
457 } | 457 } |
458 | 458 |
459 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, | 459 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, |
460 GenerateMHTMLIgnoreNoStoreSubFrame) { | 460 GenerateMHTMLIgnoreNoStoreSubFrame) { |
461 base::FilePath path(temp_dir_.path()); | 461 base::FilePath path(temp_dir_.GetPath()); |
462 path = path.Append(FILE_PATH_LITERAL("test.mht")); | 462 path = path.Append(FILE_PATH_LITERAL("test.mht")); |
463 | 463 |
464 GURL url(embedded_test_server()->GetURL("/page_with_nostore_iframe.html")); | 464 GURL url(embedded_test_server()->GetURL("/page_with_nostore_iframe.html")); |
465 | 465 |
466 // Generate MHTML, specifying the FailForNoStoreMainFrame policy. | 466 // Generate MHTML, specifying the FailForNoStoreMainFrame policy. |
467 MHTMLGenerationParams params(path); | 467 MHTMLGenerationParams params(path); |
468 params.cache_control_policy = | 468 params.cache_control_policy = |
469 blink::WebFrameSerializerCacheControlPolicy::FailForNoStoreMainFrame; | 469 blink::WebFrameSerializerCacheControlPolicy::FailForNoStoreMainFrame; |
470 | 470 |
471 GenerateMHTML(params, url); | 471 GenerateMHTML(params, url); |
472 // We expect that there was no error (file size -1 indicates an error.) | 472 // We expect that there was no error (file size -1 indicates an error.) |
473 EXPECT_LT(0, file_size()); | 473 EXPECT_LT(0, file_size()); |
474 | 474 |
475 std::string mhtml; | 475 std::string mhtml; |
476 { | 476 { |
477 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; | 477 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; |
478 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); | 478 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); |
479 } | 479 } |
480 | 480 |
481 EXPECT_THAT(mhtml, HasSubstr("Main Frame")); | 481 EXPECT_THAT(mhtml, HasSubstr("Main Frame")); |
482 // Make sure that no-store subresources exist in this mode. | 482 // Make sure that no-store subresources exist in this mode. |
483 EXPECT_THAT(mhtml, HasSubstr("no-store test body")); | 483 EXPECT_THAT(mhtml, HasSubstr("no-store test body")); |
484 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*nostore.jpg")); | 484 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*nostore.jpg")); |
485 } | 485 } |
486 | 486 |
487 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLObeyNoStoreSubFrame) { | 487 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLObeyNoStoreSubFrame) { |
488 base::FilePath path(temp_dir_.path()); | 488 base::FilePath path(temp_dir_.GetPath()); |
489 path = path.Append(FILE_PATH_LITERAL("test.mht")); | 489 path = path.Append(FILE_PATH_LITERAL("test.mht")); |
490 | 490 |
491 GURL url(embedded_test_server()->GetURL("/page_with_nostore_iframe.html")); | 491 GURL url(embedded_test_server()->GetURL("/page_with_nostore_iframe.html")); |
492 | 492 |
493 // Generate MHTML, specifying the FailForNoStoreMainFrame policy. | 493 // Generate MHTML, specifying the FailForNoStoreMainFrame policy. |
494 MHTMLGenerationParams params(path); | 494 MHTMLGenerationParams params(path); |
495 params.cache_control_policy = blink::WebFrameSerializerCacheControlPolicy:: | 495 params.cache_control_policy = blink::WebFrameSerializerCacheControlPolicy:: |
496 SkipAnyFrameOrResourceMarkedNoStore; | 496 SkipAnyFrameOrResourceMarkedNoStore; |
497 | 497 |
498 GenerateMHTML(params, url); | 498 GenerateMHTML(params, url); |
(...skipping 23 matching lines...) Expand all Loading... |
522 #define MAYBE_ViewedMHTMLContainsNoStoreContentIfNoCacheControlPolicy \ | 522 #define MAYBE_ViewedMHTMLContainsNoStoreContentIfNoCacheControlPolicy \ |
523 ViewedMHTMLContainsNoStoreContentIfNoCacheControlPolicy | 523 ViewedMHTMLContainsNoStoreContentIfNoCacheControlPolicy |
524 #define MAYBE_ViewedMHTMLDoesNotContainNoStoreContent \ | 524 #define MAYBE_ViewedMHTMLDoesNotContainNoStoreContent \ |
525 ViewedMHTMLDoesNotContainNoStoreContent | 525 ViewedMHTMLDoesNotContainNoStoreContent |
526 #endif | 526 #endif |
527 | 527 |
528 IN_PROC_BROWSER_TEST_F( | 528 IN_PROC_BROWSER_TEST_F( |
529 MHTMLGenerationTest, | 529 MHTMLGenerationTest, |
530 MAYBE_ViewedMHTMLContainsNoStoreContentIfNoCacheControlPolicy) { | 530 MAYBE_ViewedMHTMLContainsNoStoreContentIfNoCacheControlPolicy) { |
531 // Generate MHTML, specifying the FailForNoStoreMainFrame policy. | 531 // Generate MHTML, specifying the FailForNoStoreMainFrame policy. |
532 base::FilePath path(temp_dir_.path()); | 532 base::FilePath path(temp_dir_.GetPath()); |
533 path = path.Append(FILE_PATH_LITERAL("test.mht")); | 533 path = path.Append(FILE_PATH_LITERAL("test.mht")); |
534 MHTMLGenerationParams params(path); | 534 MHTMLGenerationParams params(path); |
535 | 535 |
536 // No special cache control options so we should see both frames. | 536 // No special cache control options so we should see both frames. |
537 std::vector<std::string> expectations = { | 537 std::vector<std::string> expectations = { |
538 "Main Frame, normal headers.", "Cache-Control: no-store test body", | 538 "Main Frame, normal headers.", "Cache-Control: no-store test body", |
539 }; | 539 }; |
540 std::vector<std::string> forbidden; | 540 std::vector<std::string> forbidden; |
541 TestOriginalVsSavedPage( | 541 TestOriginalVsSavedPage( |
542 embedded_test_server()->GetURL("/page_with_nostore_iframe.html"), params, | 542 embedded_test_server()->GetURL("/page_with_nostore_iframe.html"), params, |
543 2 /* expected number of frames */, expectations, forbidden); | 543 2 /* expected number of frames */, expectations, forbidden); |
544 | 544 |
545 std::string mhtml; | 545 std::string mhtml; |
546 { | 546 { |
547 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; | 547 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; |
548 ASSERT_TRUE(base::ReadFileToString(params.file_path, &mhtml)); | 548 ASSERT_TRUE(base::ReadFileToString(params.file_path, &mhtml)); |
549 } | 549 } |
550 } | 550 } |
551 | 551 |
552 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, | 552 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, |
553 MAYBE_ViewedMHTMLDoesNotContainNoStoreContent) { | 553 MAYBE_ViewedMHTMLDoesNotContainNoStoreContent) { |
554 // Generate MHTML, specifying the FailForNoStoreMainFrame policy. | 554 // Generate MHTML, specifying the FailForNoStoreMainFrame policy. |
555 base::FilePath path(temp_dir_.path()); | 555 base::FilePath path(temp_dir_.GetPath()); |
556 path = path.Append(FILE_PATH_LITERAL("test.mht")); | 556 path = path.Append(FILE_PATH_LITERAL("test.mht")); |
557 MHTMLGenerationParams params(path); | 557 MHTMLGenerationParams params(path); |
558 params.cache_control_policy = blink::WebFrameSerializerCacheControlPolicy:: | 558 params.cache_control_policy = blink::WebFrameSerializerCacheControlPolicy:: |
559 SkipAnyFrameOrResourceMarkedNoStore; | 559 SkipAnyFrameOrResourceMarkedNoStore; |
560 | 560 |
561 // No special cache control options so we should see both frames. | 561 // No special cache control options so we should see both frames. |
562 std::vector<std::string> expectations = { | 562 std::vector<std::string> expectations = { |
563 "Main Frame, normal headers.", | 563 "Main Frame, normal headers.", |
564 }; | 564 }; |
565 std::vector<std::string> forbidden = { | 565 std::vector<std::string> forbidden = { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 ASSERT_TRUE(embedded_test_server()->Started()); | 597 ASSERT_TRUE(embedded_test_server()->Started()); |
598 content::SetupCrossSiteRedirector(embedded_test_server()); | 598 content::SetupCrossSiteRedirector(embedded_test_server()); |
599 } | 599 } |
600 | 600 |
601 private: | 601 private: |
602 DISALLOW_COPY_AND_ASSIGN(MHTMLGenerationSitePerProcessTest); | 602 DISALLOW_COPY_AND_ASSIGN(MHTMLGenerationSitePerProcessTest); |
603 }; | 603 }; |
604 | 604 |
605 // Test for crbug.com/538766. | 605 // Test for crbug.com/538766. |
606 IN_PROC_BROWSER_TEST_F(MHTMLGenerationSitePerProcessTest, GenerateMHTML) { | 606 IN_PROC_BROWSER_TEST_F(MHTMLGenerationSitePerProcessTest, GenerateMHTML) { |
607 base::FilePath path(temp_dir_.path()); | 607 base::FilePath path(temp_dir_.GetPath()); |
608 path = path.Append(FILE_PATH_LITERAL("test.mht")); | 608 path = path.Append(FILE_PATH_LITERAL("test.mht")); |
609 | 609 |
610 GURL url(embedded_test_server()->GetURL( | 610 GURL url(embedded_test_server()->GetURL( |
611 "a.com", "/frame_tree/page_with_one_frame.html")); | 611 "a.com", "/frame_tree/page_with_one_frame.html")); |
612 GenerateMHTML(path, url); | 612 GenerateMHTML(path, url); |
613 ASSERT_FALSE(HasFailure()); | 613 ASSERT_FALSE(HasFailure()); |
614 | 614 |
615 std::string mhtml; | 615 std::string mhtml; |
616 { | 616 { |
617 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; | 617 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; |
618 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); | 618 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); |
619 } | 619 } |
620 | 620 |
621 // Make sure the contents of both frames are present. | 621 // Make sure the contents of both frames are present. |
622 EXPECT_THAT(mhtml, HasSubstr("This page has one cross-site iframe")); | 622 EXPECT_THAT(mhtml, HasSubstr("This page has one cross-site iframe")); |
623 EXPECT_THAT(mhtml, HasSubstr("This page has no title")); // From title1.html. | 623 EXPECT_THAT(mhtml, HasSubstr("This page has no title")); // From title1.html. |
624 | 624 |
625 // Make sure that URLs of both frames are present | 625 // Make sure that URLs of both frames are present |
626 // (note that these are single-line regexes). | 626 // (note that these are single-line regexes). |
627 EXPECT_THAT( | 627 EXPECT_THAT( |
628 mhtml, | 628 mhtml, |
629 ContainsRegex("Content-Location:.*/frame_tree/page_with_one_frame.html")); | 629 ContainsRegex("Content-Location:.*/frame_tree/page_with_one_frame.html")); |
630 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*/title1.html")); | 630 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*/title1.html")); |
631 } | 631 } |
632 | 632 |
633 } // namespace content | 633 } // namespace content |
OLD | NEW |