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 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
618 EXPECT_TRUE(WaitForLoad(web_contents)); | 618 EXPECT_TRUE(WaitForLoad(web_contents)); |
619 | 619 |
620 // We should have sent the matching cookies this time. | 620 // We should have sent the matching cookies this time. |
621 EXPECT_EQ(1u, sent_cookies.size()); | 621 EXPECT_EQ(1u, sent_cookies.size()); |
622 EXPECT_EQ("shape", sent_cookies[0].Name()); | 622 EXPECT_EQ("shape", sent_cookies[0].Name()); |
623 EXPECT_EQ("oblong", sent_cookies[0].Value()); | 623 EXPECT_EQ("oblong", sent_cookies[0].Value()); |
624 } | 624 } |
625 | 625 |
626 // TODO(skyostil): This test currently relies on being able to run a shell | 626 // TODO(skyostil): This test currently relies on being able to run a shell |
627 // script. | 627 // script. |
628 #if defined(OS_POSIX) | 628 #if defined(OS_POSIX) |
Sami
2017/03/22 19:46:25
If this doesn't build on Windows, let's just put t
dvallet
2017/03/27 05:59:50
Done
| |
629 #define MAYBE_RendererCommandPrefixTest RendererCommandPrefixTest | 629 #define MAYBE_RendererCommandPrefixTest RendererCommandPrefixTest |
630 #else | |
631 #define MAYBE_RendererCommandPrefixTest DISABLED_RendererCommandPrefixTest | |
632 #endif // defined(OS_POSIX) | |
633 IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, MAYBE_RendererCommandPrefixTest) { | 630 IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, MAYBE_RendererCommandPrefixTest) { |
634 base::ThreadRestrictions::SetIOAllowed(true); | 631 base::ThreadRestrictions::SetIOAllowed(true); |
635 base::FilePath launcher_stamp; | 632 base::FilePath launcher_stamp; |
636 base::CreateTemporaryFile(&launcher_stamp); | 633 base::CreateTemporaryFile(&launcher_stamp); |
637 | 634 |
638 base::FilePath launcher_script; | 635 base::FilePath launcher_script; |
639 FILE* launcher_file = base::CreateAndOpenTemporaryFile(&launcher_script); | 636 FILE* launcher_file = base::CreateAndOpenTemporaryFile(&launcher_script); |
640 fprintf(launcher_file, "#!/bin/sh\n"); | 637 fprintf(launcher_file, "#!/bin/sh\n"); |
641 fprintf(launcher_file, "echo $@ > %s\n", launcher_stamp.value().c_str()); | 638 fprintf(launcher_file, "echo $@ > %s\n", launcher_stamp.value().c_str()); |
642 fprintf(launcher_file, "exec $@\n"); | 639 fprintf(launcher_file, "exec $@\n"); |
(...skipping 18 matching lines...) Expand all Loading... | |
661 EXPECT_TRUE(WaitForLoad(web_contents)); | 658 EXPECT_TRUE(WaitForLoad(web_contents)); |
662 | 659 |
663 // Make sure the launcher was invoked when starting the renderer. | 660 // Make sure the launcher was invoked when starting the renderer. |
664 std::string stamp; | 661 std::string stamp; |
665 EXPECT_TRUE(base::ReadFileToString(launcher_stamp, &stamp)); | 662 EXPECT_TRUE(base::ReadFileToString(launcher_stamp, &stamp)); |
666 EXPECT_GE(stamp.find("--type=renderer"), 0u); | 663 EXPECT_GE(stamp.find("--type=renderer"), 0u); |
667 | 664 |
668 base::DeleteFile(launcher_script, false); | 665 base::DeleteFile(launcher_script, false); |
669 base::DeleteFile(launcher_stamp, false); | 666 base::DeleteFile(launcher_stamp, false); |
670 } | 667 } |
671 | 668 #else |
669 #define MAYBE_RendererCommandPrefixTest DISABLED_RendererCommandPrefixTest | |
670 #endif // defined(OS_POSIX) | |
672 class CrashReporterTest : public HeadlessBrowserTest, | 671 class CrashReporterTest : public HeadlessBrowserTest, |
673 public HeadlessWebContents::Observer, | 672 public HeadlessWebContents::Observer, |
674 inspector::ExperimentalObserver { | 673 inspector::ExperimentalObserver { |
675 public: | 674 public: |
676 CrashReporterTest() : devtools_client_(HeadlessDevToolsClient::Create()) {} | 675 CrashReporterTest() : devtools_client_(HeadlessDevToolsClient::Create()) {} |
677 ~CrashReporterTest() override {} | 676 ~CrashReporterTest() override {} |
678 | 677 |
679 void SetUp() override { | 678 void SetUp() override { |
680 base::ThreadRestrictions::SetIOAllowed(true); | 679 base::ThreadRestrictions::SetIOAllowed(true); |
681 base::CreateNewTempDirectory("CrashReporterTest", &crash_dumps_dir_); | 680 base::CreateNewTempDirectory(FILE_PATH_LITERAL("CrashReporterTest"), |
681 &crash_dumps_dir_); | |
682 EXPECT_FALSE(options()->enable_crash_reporter); | 682 EXPECT_FALSE(options()->enable_crash_reporter); |
683 options()->enable_crash_reporter = true; | 683 options()->enable_crash_reporter = true; |
684 options()->crash_dumps_dir = crash_dumps_dir_; | 684 options()->crash_dumps_dir = crash_dumps_dir_; |
685 HeadlessBrowserTest::SetUp(); | 685 HeadlessBrowserTest::SetUp(); |
686 } | 686 } |
687 | 687 |
688 void TearDown() override { | 688 void TearDown() override { |
689 base::ThreadRestrictions::SetIOAllowed(true); | 689 base::ThreadRestrictions::SetIOAllowed(true); |
690 base::DeleteFile(crash_dumps_dir_, /* recursive */ false); | 690 base::DeleteFile(crash_dumps_dir_, /* recursive */ false); |
691 } | 691 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
734 // The target has crashed and should no longer be there. | 734 // The target has crashed and should no longer be there. |
735 EXPECT_FALSE(web_contents_->GetDevToolsTarget()); | 735 EXPECT_FALSE(web_contents_->GetDevToolsTarget()); |
736 | 736 |
737 // Check that one minidump got created. | 737 // Check that one minidump got created. |
738 { | 738 { |
739 base::ThreadRestrictions::SetIOAllowed(true); | 739 base::ThreadRestrictions::SetIOAllowed(true); |
740 base::FileEnumerator it(crash_dumps_dir_, /* recursive */ false, | 740 base::FileEnumerator it(crash_dumps_dir_, /* recursive */ false, |
741 base::FileEnumerator::FILES); | 741 base::FileEnumerator::FILES); |
742 base::FilePath minidump = it.Next(); | 742 base::FilePath minidump = it.Next(); |
743 EXPECT_FALSE(minidump.empty()); | 743 EXPECT_FALSE(minidump.empty()); |
744 EXPECT_EQ(".dmp", minidump.Extension()); | 744 EXPECT_EQ(FILE_PATH_LITERAL(".dmp"), minidump.Extension()); |
745 EXPECT_TRUE(it.Next().empty()); | 745 EXPECT_TRUE(it.Next().empty()); |
746 } | 746 } |
747 | 747 |
748 web_contents_->RemoveObserver(this); | 748 web_contents_->RemoveObserver(this); |
749 web_contents_->Close(); | 749 web_contents_->Close(); |
750 web_contents_ = nullptr; | 750 web_contents_ = nullptr; |
751 | 751 |
752 browser_context_->Close(); | 752 browser_context_->Close(); |
753 browser_context_ = nullptr; | 753 browser_context_ = nullptr; |
754 } | 754 } |
755 | 755 |
756 } // namespace headless | 756 } // namespace headless |
OLD | NEW |