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