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