| 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 #include <memory> | 6 #include <memory> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/test/histogram_tester.h" | 16 #include "base/test/histogram_tester.h" |
| 17 #include "base/threading/thread_restrictions.h" | 17 #include "base/threading/thread_restrictions.h" |
| 18 #include "content/browser/renderer_host/render_process_host_impl.h" | 18 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 19 #include "content/common/frame_messages.h" | 19 #include "content/common/frame_messages.h" |
| 20 #include "content/public/browser/mhtml_extra_parts.h" | 20 #include "content/public/browser/mhtml_extra_parts.h" |
| 21 #include "content/public/browser/render_frame_host.h" |
| 21 #include "content/public/browser/render_process_host.h" | 22 #include "content/public/browser/render_process_host.h" |
| 22 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 23 #include "content/public/common/mhtml_generation_params.h" | 24 #include "content/public/common/mhtml_generation_params.h" |
| 24 #include "content/public/test/browser_test_utils.h" | 25 #include "content/public/test/browser_test_utils.h" |
| 25 #include "content/public/test/content_browser_test.h" | 26 #include "content/public/test/content_browser_test.h" |
| 26 #include "content/public/test/content_browser_test_utils.h" | 27 #include "content/public/test/content_browser_test_utils.h" |
| 27 #include "content/public/test/test_utils.h" | 28 #include "content/public/test/test_utils.h" |
| 28 #include "content/shell/browser/shell.h" | 29 #include "content/shell/browser/shell.h" |
| 29 #include "net/base/filename_util.h" | 30 #include "net/base/filename_util.h" |
| 30 #include "net/dns/mock_host_resolver.h" | 31 #include "net/dns/mock_host_resolver.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 histogram_tester_.reset(new base::HistogramTester()); | 118 histogram_tester_.reset(new base::HistogramTester()); |
| 118 | 119 |
| 119 shell()->web_contents()->GenerateMHTML( | 120 shell()->web_contents()->GenerateMHTML( |
| 120 params, base::Bind(&MHTMLGenerationTest::MHTMLGenerated, | 121 params, base::Bind(&MHTMLGenerationTest::MHTMLGenerated, |
| 121 base::Unretained(this), | 122 base::Unretained(this), |
| 122 run_loop.QuitClosure())); | 123 run_loop.QuitClosure())); |
| 123 | 124 |
| 124 // Block until the MHTML is generated. | 125 // Block until the MHTML is generated. |
| 125 run_loop.Run(); | 126 run_loop.Run(); |
| 126 | 127 |
| 127 EXPECT_TRUE(has_mhtml_callback_run()); | 128 ASSERT_TRUE(has_mhtml_callback_run()) << "Error generating MHTML file"; |
| 129 |
| 130 if (file_size() == -1) |
| 131 return; |
| 132 |
| 133 // Loads the generated file to check if it is well formed. |
| 134 WebContentsDelegate* old_delegate = shell()->web_contents()->GetDelegate(); |
| 135 ConsoleObserverDelegate console_delegate(shell()->web_contents(), |
| 136 "Malformed multipart archive: *"); |
| 137 shell()->web_contents()->SetDelegate(&console_delegate); |
| 138 |
| 139 EXPECT_TRUE( |
| 140 NavigateToURL(shell(), net::FilePathToFileURL(params.file_path))) |
| 141 << "Error navigating to the generated MHTML file"; |
| 142 EXPECT_EQ(0U, console_delegate.message().length()) |
| 143 << "The generated MHTML file is malformed"; |
| 144 |
| 145 shell()->web_contents()->SetDelegate(old_delegate); |
| 128 } | 146 } |
| 129 | 147 |
| 130 int64_t ReadFileSizeFromDisk(base::FilePath path) { | 148 int64_t ReadFileSizeFromDisk(base::FilePath path) { |
| 131 base::ThreadRestrictions::ScopedAllowIO allow_io_to_test_file_size; | 149 base::ThreadRestrictions::ScopedAllowIO allow_io_to_test_file_size; |
| 132 int64_t file_size; | 150 int64_t file_size; |
| 133 if (!base::GetFileSize(path, &file_size)) return -1; | 151 if (!base::GetFileSize(path, &file_size)) return -1; |
| 134 return file_size; | 152 return file_size; |
| 135 } | 153 } |
| 136 | 154 |
| 137 void TestOriginalVsSavedPage( | 155 void TestOriginalVsSavedPage( |
| 138 const GURL& url, | 156 const GURL& url, |
| 139 const MHTMLGenerationParams params, | 157 const MHTMLGenerationParams params, |
| 140 int expected_number_of_frames, | 158 int expected_number_of_frames, |
| 141 const std::vector<std::string>& expected_substrings, | 159 const std::vector<std::string>& expected_substrings, |
| 142 const std::vector<std::string>& forbidden_substrings_in_saved_page, | 160 const std::vector<std::string>& forbidden_substrings_in_saved_page, |
| 143 bool skip_verification_of_original_page = false) { | 161 bool skip_verification_of_original_page = false) { |
| 144 // Navigate to the test page and verify if test expectations | 162 // Navigate to the test page and verify if test expectations |
| 145 // are met (this is mostly a sanity check - a failure to meet | 163 // are met (this is mostly a sanity check - a failure to meet |
| 146 // expectations would probably mean that there is a test bug | 164 // expectations would probably mean that there is a test bug |
| 147 // (i.e. that we got called with wrong expected_foo argument). | 165 // (i.e. that we got called with wrong expected_foo argument). |
| 148 NavigateToURL(shell(), url); | 166 NavigateToURL(shell(), url); |
| 149 if (!skip_verification_of_original_page) { | 167 if (!skip_verification_of_original_page) { |
| 150 AssertExpectationsAboutCurrentTab(expected_number_of_frames, | 168 AssertExpectationsAboutCurrentTab(expected_number_of_frames, |
| 151 expected_substrings, | 169 expected_substrings, |
| 152 std::vector<std::string>()); | 170 std::vector<std::string>()); |
| 153 } | 171 } |
| 154 | 172 |
| 155 GenerateMHTML(params, url); | 173 GenerateMHTML(params, url); |
| 156 ASSERT_FALSE(HasFailure()); | |
| 157 | 174 |
| 158 // Stop the test server (to make sure the locally saved page | 175 // Stop the test server (to make sure the locally saved page |
| 159 // is self-contained / won't try to open original resources). | 176 // is self-contained / won't try to open original resources). |
| 160 ASSERT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete()); | 177 ASSERT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete()); |
| 161 | 178 |
| 162 // Open the saved page and verify if test expectations are | 179 // Open the saved page and verify if test expectations are |
| 163 // met (i.e. if the same expectations are met for "after" | 180 // met (i.e. if the same expectations are met for "after" |
| 164 // [saved version of the page] as for the "before" | 181 // [saved version of the page] as for the "before" |
| 165 // [the original version of the page]. | 182 // [the original version of the page]. |
| 166 NavigateToURL(shell(), net::FilePathToFileURL(params.file_path)); | 183 NavigateToURL(shell(), net::FilePathToFileURL(params.file_path)); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 233 |
| 217 // Tests that generating a MHTML does create contents. | 234 // Tests that generating a MHTML does create contents. |
| 218 // Note that the actual content of the file is not tested, the purpose of this | 235 // Note that the actual content of the file is not tested, the purpose of this |
| 219 // test is to ensure we were successful in creating the MHTML data from the | 236 // test is to ensure we were successful in creating the MHTML data from the |
| 220 // renderer. | 237 // renderer. |
| 221 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTML) { | 238 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTML) { |
| 222 base::FilePath path(temp_dir_.GetPath()); | 239 base::FilePath path(temp_dir_.GetPath()); |
| 223 path = path.Append(FILE_PATH_LITERAL("test.mht")); | 240 path = path.Append(FILE_PATH_LITERAL("test.mht")); |
| 224 | 241 |
| 225 GenerateMHTML(path, embedded_test_server()->GetURL("/simple_page.html")); | 242 GenerateMHTML(path, embedded_test_server()->GetURL("/simple_page.html")); |
| 226 ASSERT_FALSE(HasFailure()); | |
| 227 | 243 |
| 228 // Make sure the actual generated file has some contents. | 244 // Make sure the actual generated file has some contents. |
| 229 EXPECT_GT(file_size(), 0); // Verify the size reported by the callback. | 245 EXPECT_GT(file_size(), 0); // Verify the size reported by the callback. |
| 230 EXPECT_GT(ReadFileSizeFromDisk(path), 100); // Verify the actual file size. | 246 EXPECT_GT(ReadFileSizeFromDisk(path), 100); // Verify the actual file size. |
| 231 | 247 |
| 232 { | 248 { |
| 233 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; | 249 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; |
| 234 std::string mhtml; | 250 std::string mhtml; |
| 235 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); | 251 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); |
| 236 EXPECT_THAT(mhtml, | 252 EXPECT_THAT(mhtml, |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 GenerateMHTMLForCurrentPage(MHTMLGenerationParams(path)); | 372 GenerateMHTMLForCurrentPage(MHTMLGenerationParams(path)); |
| 357 | 373 |
| 358 EXPECT_GT(ReadFileSizeFromDisk(path), 100); // Verify the actual file size. | 374 EXPECT_GT(ReadFileSizeFromDisk(path), 100); // Verify the actual file size. |
| 359 } | 375 } |
| 360 | 376 |
| 361 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, InvalidPath) { | 377 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, InvalidPath) { |
| 362 base::FilePath path(FILE_PATH_LITERAL("/invalid/file/path")); | 378 base::FilePath path(FILE_PATH_LITERAL("/invalid/file/path")); |
| 363 | 379 |
| 364 GenerateMHTML(path, embedded_test_server()->GetURL( | 380 GenerateMHTML(path, embedded_test_server()->GetURL( |
| 365 "/download/local-about-blank-subframes.html")); | 381 "/download/local-about-blank-subframes.html")); |
| 366 ASSERT_FALSE(HasFailure()); // No failures with the invocation itself? | |
| 367 | 382 |
| 368 EXPECT_EQ(file_size(), -1); // Expecting that the callback reported failure. | 383 EXPECT_EQ(file_size(), -1); // Expecting that the callback reported failure. |
| 369 | 384 |
| 370 // Checks that the final status reported to UMA is correct. | 385 // Checks that the final status reported to UMA is correct. |
| 371 histogram_tester()->ExpectUniqueSample( | 386 histogram_tester()->ExpectUniqueSample( |
| 372 "PageSerialization.MhtmlGeneration.FinalSaveStatus", | 387 "PageSerialization.MhtmlGeneration.FinalSaveStatus", |
| 373 static_cast<int>(MhtmlSaveStatus::FILE_CREATION_ERROR), 1); | 388 static_cast<int>(MhtmlSaveStatus::FILE_CREATION_ERROR), 1); |
| 374 } | 389 } |
| 375 | 390 |
| 376 // Tests that MHTML generated using the default 'quoted-printable' encoding does | 391 // Tests that MHTML generated using the default 'quoted-printable' encoding does |
| 377 // not contain the 'binary' Content-Transfer-Encoding header, and generates | 392 // not contain the 'binary' Content-Transfer-Encoding header, and generates |
| 378 // base64 encoding for the image part. | 393 // base64 encoding for the image part. |
| 379 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateNonBinaryMHTMLWithImage) { | 394 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateNonBinaryMHTMLWithImage) { |
| 380 base::FilePath path(temp_dir_.GetPath()); | 395 base::FilePath path(temp_dir_.GetPath()); |
| 381 path = path.Append(FILE_PATH_LITERAL("test_binary.mht")); | 396 path = path.Append(FILE_PATH_LITERAL("test_binary.mht")); |
| 382 | 397 |
| 383 GURL url(embedded_test_server()->GetURL("/page_with_image.html")); | 398 GURL url(embedded_test_server()->GetURL("/page_with_image.html")); |
| 384 GenerateMHTML(path, url); | 399 GenerateMHTML(path, url); |
| 385 ASSERT_FALSE(HasFailure()); | |
| 386 EXPECT_GT(file_size(), 0); // Verify the size reported by the callback. | 400 EXPECT_GT(file_size(), 0); // Verify the size reported by the callback. |
| 387 EXPECT_GT(ReadFileSizeFromDisk(path), 100); // Verify the actual file size. | 401 EXPECT_GT(ReadFileSizeFromDisk(path), 100); // Verify the actual file size. |
| 388 | 402 |
| 389 { | 403 { |
| 390 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; | 404 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; |
| 391 std::string mhtml; | 405 std::string mhtml; |
| 392 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); | 406 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); |
| 393 EXPECT_THAT(mhtml, HasSubstr("Content-Transfer-Encoding: base64")); | 407 EXPECT_THAT(mhtml, HasSubstr("Content-Transfer-Encoding: base64")); |
| 394 EXPECT_THAT(mhtml, Not(HasSubstr("Content-Transfer-Encoding: binary"))); | 408 EXPECT_THAT(mhtml, Not(HasSubstr("Content-Transfer-Encoding: binary"))); |
| 395 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*blank.jpg")); | 409 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*blank.jpg")); |
| 396 } | 410 } |
| 397 } | 411 } |
| 398 | 412 |
| 399 // Tests that MHTML generated using the binary encoding contains the 'binary' | 413 // Tests that MHTML generated using the binary encoding contains the 'binary' |
| 400 // Content-Transfer-Encoding header, and does not contain any base64 encoded | 414 // Content-Transfer-Encoding header, and does not contain any base64 encoded |
| 401 // parts. | 415 // parts. |
| 402 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateBinaryMHTMLWithImage) { | 416 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateBinaryMHTMLWithImage) { |
| 403 base::FilePath path(temp_dir_.GetPath()); | 417 base::FilePath path(temp_dir_.GetPath()); |
| 404 path = path.Append(FILE_PATH_LITERAL("test_binary.mht")); | 418 path = path.Append(FILE_PATH_LITERAL("test_binary.mht")); |
| 405 | 419 |
| 406 GURL url(embedded_test_server()->GetURL("/page_with_image.html")); | 420 GURL url(embedded_test_server()->GetURL("/page_with_image.html")); |
| 407 MHTMLGenerationParams params(path); | 421 MHTMLGenerationParams params(path); |
| 408 params.use_binary_encoding = true; | 422 params.use_binary_encoding = true; |
| 409 | 423 |
| 410 GenerateMHTML(params, url); | 424 GenerateMHTML(params, url); |
| 411 ASSERT_FALSE(HasFailure()); | |
| 412 EXPECT_GT(file_size(), 0); // Verify the size reported by the callback. | 425 EXPECT_GT(file_size(), 0); // Verify the size reported by the callback. |
| 413 EXPECT_GT(ReadFileSizeFromDisk(path), 100); // Verify the actual file size. | 426 EXPECT_GT(ReadFileSizeFromDisk(path), 100); // Verify the actual file size. |
| 414 | 427 |
| 415 { | 428 { |
| 416 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; | 429 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; |
| 417 std::string mhtml; | 430 std::string mhtml; |
| 418 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); | 431 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); |
| 419 EXPECT_THAT(mhtml, HasSubstr("Content-Transfer-Encoding: binary")); | 432 EXPECT_THAT(mhtml, HasSubstr("Content-Transfer-Encoding: binary")); |
| 420 EXPECT_THAT(mhtml, Not(HasSubstr("Content-Transfer-Encoding: base64"))); | 433 EXPECT_THAT(mhtml, Not(HasSubstr("Content-Transfer-Encoding: base64"))); |
| 421 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*blank.jpg")); | 434 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*blank.jpg")); |
| 422 } | 435 } |
| 423 } | 436 } |
| 424 | 437 |
| 425 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLIgnoreNoStore) { | 438 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLIgnoreNoStore) { |
| 426 base::FilePath path(temp_dir_.GetPath()); | 439 base::FilePath path(temp_dir_.GetPath()); |
| 427 path = path.Append(FILE_PATH_LITERAL("test.mht")); | 440 path = path.Append(FILE_PATH_LITERAL("test.mht")); |
| 428 | 441 |
| 429 GURL url(embedded_test_server()->GetURL("/nostore.html")); | 442 GURL url(embedded_test_server()->GetURL("/nostore.html")); |
| 430 | 443 |
| 431 // Generate MHTML without specifying the FailForNoStoreMainFrame policy. | 444 // Generate MHTML without specifying the FailForNoStoreMainFrame policy. |
| 432 GenerateMHTML(path, url); | 445 GenerateMHTML(path, url); |
| 433 | 446 |
| 434 // We expect that there wasn't an error (file size -1 indicates an error.) | |
| 435 ASSERT_FALSE(HasFailure()); | |
| 436 | |
| 437 std::string mhtml; | 447 std::string mhtml; |
| 438 { | 448 { |
| 439 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; | 449 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; |
| 440 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); | 450 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); |
| 441 } | 451 } |
| 442 | 452 |
| 443 // Make sure the contents of the body are present. | 453 // Make sure the contents of the body are present. |
| 444 EXPECT_THAT(mhtml, HasSubstr("test body")); | 454 EXPECT_THAT(mhtml, HasSubstr("test body")); |
| 445 | 455 |
| 446 // Make sure that URL of the content is present. | 456 // Make sure that URL of the content is present. |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 }; | 633 }; |
| 624 | 634 |
| 625 // Test for crbug.com/538766. | 635 // Test for crbug.com/538766. |
| 626 IN_PROC_BROWSER_TEST_F(MHTMLGenerationSitePerProcessTest, GenerateMHTML) { | 636 IN_PROC_BROWSER_TEST_F(MHTMLGenerationSitePerProcessTest, GenerateMHTML) { |
| 627 base::FilePath path(temp_dir_.GetPath()); | 637 base::FilePath path(temp_dir_.GetPath()); |
| 628 path = path.Append(FILE_PATH_LITERAL("test.mht")); | 638 path = path.Append(FILE_PATH_LITERAL("test.mht")); |
| 629 | 639 |
| 630 GURL url(embedded_test_server()->GetURL( | 640 GURL url(embedded_test_server()->GetURL( |
| 631 "a.com", "/frame_tree/page_with_one_frame.html")); | 641 "a.com", "/frame_tree/page_with_one_frame.html")); |
| 632 GenerateMHTML(path, url); | 642 GenerateMHTML(path, url); |
| 633 ASSERT_FALSE(HasFailure()); | |
| 634 | 643 |
| 635 std::string mhtml; | 644 std::string mhtml; |
| 636 { | 645 { |
| 637 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; | 646 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; |
| 638 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); | 647 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); |
| 639 } | 648 } |
| 640 | 649 |
| 641 // Make sure the contents of both frames are present. | 650 // Make sure the contents of both frames are present. |
| 642 EXPECT_THAT(mhtml, HasSubstr("This page has one cross-site iframe")); | 651 EXPECT_THAT(mhtml, HasSubstr("This page has one cross-site iframe")); |
| 643 EXPECT_THAT(mhtml, HasSubstr("This page has no title")); // From title1.html. | 652 EXPECT_THAT(mhtml, HasSubstr("This page has no title")); // From title1.html. |
| 644 | 653 |
| 645 // Make sure that URLs of both frames are present | 654 // Make sure that URLs of both frames are present |
| 646 // (note that these are single-line regexes). | 655 // (note that these are single-line regexes). |
| 647 EXPECT_THAT( | 656 EXPECT_THAT( |
| 648 mhtml, | 657 mhtml, |
| 649 ContainsRegex("Content-Location:.*/frame_tree/page_with_one_frame.html")); | 658 ContainsRegex("Content-Location:.*/frame_tree/page_with_one_frame.html")); |
| 650 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*/title1.html")); | 659 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*/title1.html")); |
| 651 } | 660 } |
| 652 | 661 |
| 653 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, RemovePopupOverlay) { | 662 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, RemovePopupOverlay) { |
| 654 base::FilePath path(temp_dir_.GetPath()); | 663 base::FilePath path(temp_dir_.GetPath()); |
| 655 path = path.Append(FILE_PATH_LITERAL("test.mht")); | 664 path = path.Append(FILE_PATH_LITERAL("test.mht")); |
| 656 | 665 |
| 657 GURL url(embedded_test_server()->GetURL("/popup.html")); | 666 GURL url(embedded_test_server()->GetURL("/popup.html")); |
| 658 | 667 |
| 659 MHTMLGenerationParams params(path); | 668 MHTMLGenerationParams params(path); |
| 660 params.remove_popup_overlay = true; | 669 params.remove_popup_overlay = true; |
| 661 | 670 |
| 662 GenerateMHTML(params, url); | 671 GenerateMHTML(params, url); |
| 663 ASSERT_FALSE(HasFailure()); | |
| 664 | 672 |
| 665 std::string mhtml; | 673 std::string mhtml; |
| 666 { | 674 { |
| 667 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; | 675 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; |
| 668 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); | 676 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); |
| 669 } | 677 } |
| 670 | 678 |
| 671 // Make sure the overlay is removed. | 679 // Make sure the overlay is removed. |
| 672 EXPECT_THAT(mhtml, Not(HasSubstr("class=3D\"overlay"))); | 680 EXPECT_THAT(mhtml, Not(HasSubstr("class=3D\"overlay"))); |
| 673 EXPECT_THAT(mhtml, Not(HasSubstr("class=3D\"modal"))); | 681 EXPECT_THAT(mhtml, Not(HasSubstr("class=3D\"modal"))); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; | 716 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; |
| 709 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); | 717 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); |
| 710 } | 718 } |
| 711 | 719 |
| 712 // Make sure that both extra data parts made it into the mhtml. | 720 // Make sure that both extra data parts made it into the mhtml. |
| 713 EXPECT_THAT(mhtml, HasSubstr(kFakeSignalData1)); | 721 EXPECT_THAT(mhtml, HasSubstr(kFakeSignalData1)); |
| 714 EXPECT_THAT(mhtml, HasSubstr(kFakeSignalData2)); | 722 EXPECT_THAT(mhtml, HasSubstr(kFakeSignalData2)); |
| 715 } | 723 } |
| 716 | 724 |
| 717 } // namespace content | 725 } // namespace content |
| OLD | NEW |