| 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 "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 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 EXPECT_TRUE(base::PathExists(full_file_name)); | 794 EXPECT_TRUE(base::PathExists(full_file_name)); |
| 795 } | 795 } |
| 796 | 796 |
| 797 class SavePageSitePerProcessBrowserTest : public SavePageBrowserTest { | 797 class SavePageSitePerProcessBrowserTest : public SavePageBrowserTest { |
| 798 public: | 798 public: |
| 799 SavePageSitePerProcessBrowserTest() {} | 799 SavePageSitePerProcessBrowserTest() {} |
| 800 | 800 |
| 801 protected: | 801 protected: |
| 802 void SetUpCommandLine(base::CommandLine* command_line) override { | 802 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 803 SavePageBrowserTest::SetUpCommandLine(command_line); | 803 SavePageBrowserTest::SetUpCommandLine(command_line); |
| 804 | 804 content::IsolateAllSitesForTesting(command_line); |
| 805 // TODO(lukasza): Enable --site-per-process once crbug.com/526786 is fixed. | |
| 806 // (currently, when the line below is uncommented out, the test crashes | |
| 807 // under blink::WebLocalFrameImpl::fromFrameOwnerElement called from | |
| 808 // blink::WebPageSerializerImpl::openTagToString). | |
| 809 // | |
| 810 // content::IsolateAllSitesForTesting(command_line); | |
| 811 } | 805 } |
| 812 | 806 |
| 813 void SetUpOnMainThread() override { | 807 void SetUpOnMainThread() override { |
| 814 SavePageBrowserTest::SetUpOnMainThread(); | 808 SavePageBrowserTest::SetUpOnMainThread(); |
| 815 | 809 |
| 816 host_resolver()->AddRule("*", "127.0.0.1"); | 810 host_resolver()->AddRule("*", "127.0.0.1"); |
| 817 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 811 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 818 content::SetupCrossSiteRedirector(embedded_test_server()); | 812 content::SetupCrossSiteRedirector(embedded_test_server()); |
| 819 } | 813 } |
| 820 | 814 |
| 821 private: | 815 private: |
| 822 DISALLOW_COPY_AND_ASSIGN(SavePageSitePerProcessBrowserTest); | 816 DISALLOW_COPY_AND_ASSIGN(SavePageSitePerProcessBrowserTest); |
| 823 }; | 817 }; |
| 824 | 818 |
| 825 // Test for crbug.com/526786. Without OOPIFs fixes, the test will trigger | 819 // Test for crbug.com/526786. Without OOPIFs fixes, the test will trigger |
| 826 // a crash in the renderer process. | 820 // a crash in the renderer process. |
| 827 IN_PROC_BROWSER_TEST_F(SavePageSitePerProcessBrowserTest, SaveCrossSitePage) { | 821 IN_PROC_BROWSER_TEST_F(SavePageSitePerProcessBrowserTest, SaveCrossSitePage) { |
| 828 // TODO(lukasza): Remove this check once crbug.com/526786 is fixed. | |
| 829 if (content::AreAllSitesIsolatedForTesting()) { | |
| 830 LOG(WARNING) << "Skipping the test."; | |
| 831 return; // Avoid failing on Site Isolation FYI bot. | |
| 832 } | |
| 833 | |
| 834 GURL url(embedded_test_server()->GetURL( | 822 GURL url(embedded_test_server()->GetURL( |
| 835 "a.com", "/frame_tree/page_with_two_frames_remote_and_local.html")); | 823 "a.com", "/frame_tree/page_with_two_frames_remote_and_local.html")); |
| 836 ui_test_utils::NavigateToURL(browser(), url); | 824 ui_test_utils::NavigateToURL(browser(), url); |
| 837 | 825 |
| 838 base::FilePath full_file_name, dir; | 826 base::FilePath full_file_name, dir; |
| 839 SaveCurrentTab(url, content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, "xsite1", 3, | 827 SaveCurrentTab(url, content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, "xsite1", 3, |
| 840 &dir, &full_file_name); | 828 &dir, &full_file_name); |
| 841 ASSERT_FALSE(HasFailure()); | 829 ASSERT_FALSE(HasFailure()); |
| 842 | 830 |
| 843 EXPECT_TRUE(base::DirectoryExists(dir)); | 831 EXPECT_TRUE(base::DirectoryExists(dir)); |
| 844 base::FilePath expected_files[] = { | 832 base::FilePath expected_files[] = { |
| 845 full_file_name, dir.AppendASCII("title1.html"), | 833 full_file_name, dir.AppendASCII("title1.html"), |
| 846 dir.AppendASCII("title1(1).html"), | 834 dir.AppendASCII("title1(1).html"), |
| 847 }; | 835 }; |
| 848 for (auto file_path : expected_files) { | 836 for (auto file_path : expected_files) { |
| 849 EXPECT_TRUE(base::PathExists(file_path)) << "Does " << file_path.value() | 837 EXPECT_TRUE(base::PathExists(file_path)) << "Does " << file_path.value() |
| 850 << " exist?"; | 838 << " exist?"; |
| 851 int64 actual_file_size = 0; | 839 int64 actual_file_size = 0; |
| 852 EXPECT_TRUE(base::GetFileSize(file_path, &actual_file_size)); | 840 EXPECT_TRUE(base::GetFileSize(file_path, &actual_file_size)); |
| 853 EXPECT_NE(0, actual_file_size) << "Is " << file_path.value() | 841 EXPECT_NE(0, actual_file_size) << "Is " << file_path.value() |
| 854 << " non-empty?"; | 842 << " non-empty?"; |
| 855 } | 843 } |
| 856 } | 844 } |
| 857 | 845 |
| 858 } // namespace | 846 } // namespace |
| OLD | NEW |