OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_enumerator.h" | 8 #include "base/files/file_enumerator.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 FinishAsynchronousTest(); | 710 FinishAsynchronousTest(); |
711 } | 711 } |
712 | 712 |
713 protected: | 713 protected: |
714 HeadlessBrowserContext* browser_context_ = nullptr; | 714 HeadlessBrowserContext* browser_context_ = nullptr; |
715 HeadlessWebContents* web_contents_ = nullptr; | 715 HeadlessWebContents* web_contents_ = nullptr; |
716 std::unique_ptr<HeadlessDevToolsClient> devtools_client_; | 716 std::unique_ptr<HeadlessDevToolsClient> devtools_client_; |
717 base::FilePath crash_dumps_dir_; | 717 base::FilePath crash_dumps_dir_; |
718 }; | 718 }; |
719 | 719 |
720 // TODO(skyostil): Minidump generation currently is only supported on Linux and | 720 // TODO(skyostil): Minidump generation currently is only supported on Linux. |
721 // Mac. | 721 #if defined(HEADLESS_USE_BREAKPAD) |
722 #if defined(HEADLESS_USE_BREAKPAD) || defined(OS_MACOSX) | |
723 #define MAYBE_GenerateMinidump GenerateMinidump | 722 #define MAYBE_GenerateMinidump GenerateMinidump |
724 #else | 723 #else |
725 #define MAYBE_GenerateMinidump DISABLED_GenerateMinidump | 724 #define MAYBE_GenerateMinidump DISABLED_GenerateMinidump |
726 #endif // defined(HEADLESS_USE_BREAKPAD) || defined(OS_MACOSX) | 725 #endif // defined(HEADLESS_USE_BREAKPAD) |
727 IN_PROC_BROWSER_TEST_F(CrashReporterTest, MAYBE_GenerateMinidump) { | 726 IN_PROC_BROWSER_TEST_F(CrashReporterTest, MAYBE_GenerateMinidump) { |
728 // Navigates a tab to chrome://crash and checks that a minidump is generated. | 727 // Navigates a tab to chrome://crash and checks that a minidump is generated. |
729 // Note that we only test renderer crashes here -- browser crashes need to be | 728 // Note that we only test renderer crashes here -- browser crashes need to be |
730 // tested with a separate harness. | 729 // tested with a separate harness. |
731 // | 730 // |
732 // The case where crash reporting is disabled is covered by | 731 // The case where crash reporting is disabled is covered by |
733 // HeadlessCrashObserverTest. | 732 // HeadlessCrashObserverTest. |
734 browser_context_ = browser()->CreateBrowserContextBuilder().Build(); | 733 browser_context_ = browser()->CreateBrowserContextBuilder().Build(); |
735 | 734 |
736 web_contents_ = browser_context_->CreateWebContentsBuilder() | 735 web_contents_ = browser_context_->CreateWebContentsBuilder() |
737 .SetInitialURL(GURL(content::kChromeUICrashURL)) | 736 .SetInitialURL(GURL(content::kChromeUICrashURL)) |
738 .Build(); | 737 .Build(); |
739 | 738 |
740 web_contents_->AddObserver(this); | 739 web_contents_->AddObserver(this); |
741 RunAsynchronousTest(); | 740 RunAsynchronousTest(); |
742 | 741 |
743 // The target has crashed and should no longer be there. | 742 // The target has crashed and should no longer be there. |
744 EXPECT_FALSE(web_contents_->GetDevToolsTarget()); | 743 EXPECT_FALSE(web_contents_->GetDevToolsTarget()); |
745 | 744 |
746 // Check that one minidump got created. | 745 // Check that one minidump got created. |
747 { | 746 { |
748 #if defined(OS_MACOSX) | |
749 // Mac outputs dumps in the 'completed' directory. | |
750 crash_dumps_dir_ = crash_dumps_dir_.Append("completed"); | |
751 #endif | |
752 base::ThreadRestrictions::SetIOAllowed(true); | 747 base::ThreadRestrictions::SetIOAllowed(true); |
753 base::FileEnumerator it(crash_dumps_dir_, /* recursive */ false, | 748 base::FileEnumerator it(crash_dumps_dir_, /* recursive */ false, |
754 base::FileEnumerator::FILES); | 749 base::FileEnumerator::FILES); |
755 base::FilePath minidump = it.Next(); | 750 base::FilePath minidump = it.Next(); |
756 EXPECT_FALSE(minidump.empty()); | 751 EXPECT_FALSE(minidump.empty()); |
757 EXPECT_EQ(".dmp", minidump.Extension()); | 752 EXPECT_EQ(".dmp", minidump.Extension()); |
758 EXPECT_TRUE(it.Next().empty()); | 753 EXPECT_TRUE(it.Next().empty()); |
759 } | 754 } |
760 | 755 |
761 web_contents_->RemoveObserver(this); | 756 web_contents_->RemoveObserver(this); |
(...skipping 21 matching lines...) Expand all Loading... |
783 web_contents->browser_context()->GetPermissionManager(); | 778 web_contents->browser_context()->GetPermissionManager(); |
784 EXPECT_NE(nullptr, permission_manager); | 779 EXPECT_NE(nullptr, permission_manager); |
785 | 780 |
786 // Check that the permission manager returns ASK for a given permission type. | 781 // Check that the permission manager returns ASK for a given permission type. |
787 EXPECT_EQ(blink::mojom::PermissionStatus::ASK, | 782 EXPECT_EQ(blink::mojom::PermissionStatus::ASK, |
788 permission_manager->GetPermissionStatus( | 783 permission_manager->GetPermissionStatus( |
789 content::PermissionType::NOTIFICATIONS, url, url)); | 784 content::PermissionType::NOTIFICATIONS, url, url)); |
790 } | 785 } |
791 | 786 |
792 } // namespace headless | 787 } // namespace headless |
OLD | NEW |