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

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

Issue 2683493002: Get signals working in the EXTRA_DATA section of MHTML (Closed)
Patch Set: Don't forget the new .h file Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdint.h> 5 #include <stdint.h>
6 #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/download/mhtml_extra_data.h"
18 #include "content/browser/renderer_host/render_process_host_impl.h" 19 #include "content/browser/renderer_host/render_process_host_impl.h"
19 #include "content/common/frame_messages.h" 20 #include "content/common/frame_messages.h"
20 #include "content/public/browser/render_process_host.h" 21 #include "content/public/browser/render_process_host.h"
21 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
22 #include "content/public/common/mhtml_generation_params.h" 23 #include "content/public/common/mhtml_generation_params.h"
23 #include "content/public/test/browser_test_utils.h" 24 #include "content/public/test/browser_test_utils.h"
24 #include "content/public/test/content_browser_test.h" 25 #include "content/public/test/content_browser_test.h"
25 #include "content/public/test/content_browser_test_utils.h" 26 #include "content/public/test/content_browser_test_utils.h"
26 #include "content/public/test/test_utils.h" 27 #include "content/public/test/test_utils.h"
27 #include "content/shell/browser/shell.h" 28 #include "content/shell/browser/shell.h"
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 { 666 {
666 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification; 667 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification;
667 ASSERT_TRUE(base::ReadFileToString(path, &mhtml)); 668 ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
668 } 669 }
669 670
670 // Make sure the overlay is removed. 671 // Make sure the overlay is removed.
671 EXPECT_THAT(mhtml, Not(HasSubstr("class=3D\"overlay"))); 672 EXPECT_THAT(mhtml, Not(HasSubstr("class=3D\"overlay")));
672 EXPECT_THAT(mhtml, Not(HasSubstr("class=3D\"modal"))); 673 EXPECT_THAT(mhtml, Not(HasSubstr("class=3D\"modal")));
673 } 674 }
674 675
676 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLWithExtraData) {
677 const char kFakeSignalData[] = "FakeSignalData";
678 base::FilePath path(temp_dir_.GetPath());
679 path = path.Append(FILE_PATH_LITERAL("test.mht"));
680 GURL url(embedded_test_server()->GetURL("/page_with_image.html"));
681 MHTMLGenerationParams params(path);
682
683 // Place the extra data we need into the web contents user data.
684 std::string signal_string(kFakeSignalData);
685 shell()->web_contents()->SetUserData(
686 content::kMHTMLExtraDataKey,
687 std::unique_ptr<base::SupportsUserData::Data>(
688 new content::MHTMLExtraData(std::string(signal_string))));
689
690 // Make the user data available on other threads by promising we are done
691 // here. shell()->web_contents()->DetachFromSequence();
fgorski 2017/03/16 17:46:31 What exactly happens here? Comment does not help,
Pete Williamson 2017/03/17 23:28:32 Oops, leftover code, removed.
692
693 GenerateMHTML(params, url);
694
695 EXPECT_TRUE(has_mhtml_callback_run());
696
697 std::string mhtml;
698 {
699 base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification;
700 ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
701 }
702
703 // Make sure that extra data made it into the mhtml.
704 EXPECT_THAT(mhtml, HasSubstr(kFakeSignalData));
705 }
706
675 } // namespace content 707 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698