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