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