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

Side by Side Diff: chrome/browser/download/save_page_browsertest.cc

Issue 1362973003: Verify other multi-frame concerns in SaveCrossSitePage test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « no previous file | chrome/test/data/save_page/iframes.htm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 29 matching lines...) Expand all
40 #include "content/public/browser/notification_service.h" 40 #include "content/public/browser/notification_service.h"
41 #include "content/public/browser/notification_types.h" 41 #include "content/public/browser/notification_types.h"
42 #include "content/public/browser/web_contents.h" 42 #include "content/public/browser/web_contents.h"
43 #include "content/public/common/content_switches.h" 43 #include "content/public/common/content_switches.h"
44 #include "content/public/common/url_constants.h" 44 #include "content/public/common/url_constants.h"
45 #include "content/public/test/browser_test_utils.h" 45 #include "content/public/test/browser_test_utils.h"
46 #include "content/public/test/test_utils.h" 46 #include "content/public/test/test_utils.h"
47 #include "net/dns/mock_host_resolver.h" 47 #include "net/dns/mock_host_resolver.h"
48 #include "net/test/embedded_test_server/embedded_test_server.h" 48 #include "net/test/embedded_test_server/embedded_test_server.h"
49 #include "net/test/url_request/url_request_mock_http_job.h" 49 #include "net/test/url_request/url_request_mock_http_job.h"
50 #include "testing/gmock/include/gmock/gmock.h"
50 #include "testing/gtest/include/gtest/gtest.h" 51 #include "testing/gtest/include/gtest/gtest.h"
51 52
52 using content::BrowserContext; 53 using content::BrowserContext;
53 using content::BrowserThread; 54 using content::BrowserThread;
54 using content::DownloadItem; 55 using content::DownloadItem;
55 using content::DownloadManager; 56 using content::DownloadManager;
56 using content::WebContents; 57 using content::WebContents;
57 using net::URLRequestMockHTTPJob; 58 using net::URLRequestMockHTTPJob;
59 using testing::HasSubstr;
58 60
59 namespace { 61 namespace {
60 62
61 // Waits for an item record in the downloads database to match |filter|. See 63 // Waits for an item record in the downloads database to match |filter|. See
62 // DownloadStoredProperly() below for an example filter. 64 // DownloadStoredProperly() below for an example filter.
63 class DownloadPersistedObserver : public DownloadHistory::Observer { 65 class DownloadPersistedObserver : public DownloadHistory::Observer {
64 public: 66 public:
65 typedef base::Callback<bool( 67 typedef base::Callback<bool(
66 DownloadItem* item, 68 DownloadItem* item,
67 const history::DownloadRow&)> PersistedFilter; 69 const history::DownloadRow&)> PersistedFilter;
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 804
803 // Test for crbug.com/526786. Without OOPIFs fixes, the test will trigger 805 // Test for crbug.com/526786. Without OOPIFs fixes, the test will trigger
804 // a crash in the renderer process. 806 // a crash in the renderer process.
805 IN_PROC_BROWSER_TEST_F(SavePageSitePerProcessBrowserTest, SaveCrossSitePage) { 807 IN_PROC_BROWSER_TEST_F(SavePageSitePerProcessBrowserTest, SaveCrossSitePage) {
806 // TODO(lukasza): Remove this check once crbug.com/526786 is fixed. 808 // TODO(lukasza): Remove this check once crbug.com/526786 is fixed.
807 if (content::AreAllSitesIsolatedForTesting()) { 809 if (content::AreAllSitesIsolatedForTesting()) {
808 LOG(WARNING) << "Skipping the test."; 810 LOG(WARNING) << "Skipping the test.";
809 return; // Avoid failing on Site Isolation FYI bot. 811 return; // Avoid failing on Site Isolation FYI bot.
810 } 812 }
811 813
812 GURL url(embedded_test_server()->GetURL( 814 GURL url(embedded_test_server()->GetURL("a.com", "/save_page/iframes.htm"));
813 "a.com", "/frame_tree/page_with_two_frames_remote_and_local.html"));
814 ui_test_utils::NavigateToURL(browser(), url); 815 ui_test_utils::NavigateToURL(browser(), url);
815 816
816 base::FilePath full_file_name, dir; 817 base::FilePath full_file_name, dir;
817 SaveCurrentTab(url, content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, "xsite1", 3, 818 SaveCurrentTab(url, content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, "iframes", 5,
818 &dir, &full_file_name); 819 &dir, &full_file_name);
819 ASSERT_FALSE(HasFailure()); 820 ASSERT_FALSE(HasFailure());
820 821
821 EXPECT_TRUE(base::DirectoryExists(dir)); 822 EXPECT_TRUE(base::DirectoryExists(dir));
822 base::FilePath expected_files[] = { 823 base::FilePath expected_files[] = {
823 full_file_name, dir.AppendASCII("title1.html"), 824 full_file_name,
824 dir.AppendASCII("title1(1).html"), 825 dir.AppendASCII("a.html"), // From iframes.htm
826 dir.AppendASCII("b.html"), // From iframes.htm
827 dir.AppendASCII("1.css"), // From b.htm
828 dir.AppendASCII("1.png"), // Deduplicated from iframes.htm and b.htm.
825 }; 829 };
826 for (auto file_path : expected_files) { 830 for (auto file_path : expected_files) {
827 EXPECT_TRUE(base::PathExists(file_path)) << "Does " << file_path.value() 831 EXPECT_TRUE(base::PathExists(file_path)) << "Does " << file_path.value()
828 << " exist?"; 832 << " exist?";
829 int64 actual_file_size = 0; 833 int64 actual_file_size = 0;
830 EXPECT_TRUE(base::GetFileSize(file_path, &actual_file_size)); 834 EXPECT_TRUE(base::GetFileSize(file_path, &actual_file_size));
831 EXPECT_NE(0, actual_file_size) << "Is " << file_path.value() 835 EXPECT_NE(0, actual_file_size) << "Is " << file_path.value()
832 << " non-empty?"; 836 << " non-empty?";
833 } 837 }
838
839 // Verify that local links got correctly replaced with local paths
840 // (most importantly for iframe elements, which are only exercised
841 // by this particular test).
842 std::string main_contents;
843 ASSERT_TRUE(base::ReadFileToString(full_file_name, &main_contents));
844 EXPECT_THAT(main_contents,
845 HasSubstr("<iframe src=\"./iframes_files/a.html\"></iframe>"));
846 EXPECT_THAT(main_contents,
847 HasSubstr("<iframe src=\"./iframes_files/b.html\"></iframe>"));
848 EXPECT_THAT(main_contents,
849 HasSubstr("<img src=\"./iframes_files/1.png\">"));
834 } 850 }
835 851
836 } // namespace 852 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/save_page/iframes.htm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698