Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(961)

Side by Side Diff: headless/lib/headless_browser_browsertest.cc

Issue 2837093003: Revert of Add --headless flag to Windows (Closed)
Patch Set: Fix compilation issue Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 393
394 // True if the request method is "safe" (per section 4.2.1 of RFC 7231). 394 // True if the request method is "safe" (per section 4.2.1 of RFC 7231).
395 bool IsMethodSafe(const std::string& method) { 395 bool IsMethodSafe(const std::string& method) {
396 return method == "GET" || method == "HEAD" || method == "OPTIONS" || 396 return method == "GET" || method == "HEAD" || method == "OPTIONS" ||
397 method == "TRACE"; 397 method == "TRACE";
398 } 398 }
399 399
400 class ProtocolHandlerWithCookies 400 class ProtocolHandlerWithCookies
401 : public net::URLRequestJobFactory::ProtocolHandler { 401 : public net::URLRequestJobFactory::ProtocolHandler {
402 public: 402 public:
403 explicit ProtocolHandlerWithCookies(net::CookieList* sent_cookies); 403 ProtocolHandlerWithCookies(net::CookieList* sent_cookies);
404 ~ProtocolHandlerWithCookies() override {} 404 ~ProtocolHandlerWithCookies() override {}
405 405
406 net::URLRequestJob* MaybeCreateJob( 406 net::URLRequestJob* MaybeCreateJob(
407 net::URLRequest* request, 407 net::URLRequest* request,
408 net::NetworkDelegate* network_delegate) const override; 408 net::NetworkDelegate* network_delegate) const override;
409 409
410 private: 410 private:
411 net::CookieList* sent_cookies_; // Not owned. 411 net::CookieList* sent_cookies_; // Not owned.
412 412
413 DISALLOW_COPY_AND_ASSIGN(ProtocolHandlerWithCookies); 413 DISALLOW_COPY_AND_ASSIGN(ProtocolHandlerWithCookies);
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 627
628 // We should have sent the matching cookies this time. 628 // We should have sent the matching cookies this time.
629 EXPECT_EQ(1u, sent_cookies.size()); 629 EXPECT_EQ(1u, sent_cookies.size());
630 EXPECT_EQ("shape", sent_cookies[0].Name()); 630 EXPECT_EQ("shape", sent_cookies[0].Name());
631 EXPECT_EQ("oblong", sent_cookies[0].Value()); 631 EXPECT_EQ("oblong", sent_cookies[0].Value());
632 } 632 }
633 633
634 // TODO(skyostil): This test currently relies on being able to run a shell 634 // TODO(skyostil): This test currently relies on being able to run a shell
635 // script. 635 // script.
636 #if defined(OS_POSIX) 636 #if defined(OS_POSIX)
637 IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, RendererCommandPrefixTest) { 637 #define MAYBE_RendererCommandPrefixTest RendererCommandPrefixTest
638 #else
639 #define MAYBE_RendererCommandPrefixTest DISABLED_RendererCommandPrefixTest
640 #endif // defined(OS_POSIX)
641 IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, MAYBE_RendererCommandPrefixTest) {
638 base::ThreadRestrictions::SetIOAllowed(true); 642 base::ThreadRestrictions::SetIOAllowed(true);
639 base::FilePath launcher_stamp; 643 base::FilePath launcher_stamp;
640 base::CreateTemporaryFile(&launcher_stamp); 644 base::CreateTemporaryFile(&launcher_stamp);
641 645
642 base::FilePath launcher_script; 646 base::FilePath launcher_script;
643 FILE* launcher_file = base::CreateAndOpenTemporaryFile(&launcher_script); 647 FILE* launcher_file = base::CreateAndOpenTemporaryFile(&launcher_script);
644 fprintf(launcher_file, "#!/bin/sh\n"); 648 fprintf(launcher_file, "#!/bin/sh\n");
645 fprintf(launcher_file, "echo $@ > %s\n", launcher_stamp.value().c_str()); 649 fprintf(launcher_file, "echo $@ > %s\n", launcher_stamp.value().c_str());
646 fprintf(launcher_file, "exec $@\n"); 650 fprintf(launcher_file, "exec $@\n");
647 fclose(launcher_file); 651 fclose(launcher_file);
(...skipping 17 matching lines...) Expand all
665 EXPECT_TRUE(WaitForLoad(web_contents)); 669 EXPECT_TRUE(WaitForLoad(web_contents));
666 670
667 // Make sure the launcher was invoked when starting the renderer. 671 // Make sure the launcher was invoked when starting the renderer.
668 std::string stamp; 672 std::string stamp;
669 EXPECT_TRUE(base::ReadFileToString(launcher_stamp, &stamp)); 673 EXPECT_TRUE(base::ReadFileToString(launcher_stamp, &stamp));
670 EXPECT_GE(stamp.find("--type=renderer"), 0u); 674 EXPECT_GE(stamp.find("--type=renderer"), 0u);
671 675
672 base::DeleteFile(launcher_script, false); 676 base::DeleteFile(launcher_script, false);
673 base::DeleteFile(launcher_stamp, false); 677 base::DeleteFile(launcher_stamp, false);
674 } 678 }
675 #endif // defined(OS_POSIX)
676 679
677 class CrashReporterTest : public HeadlessBrowserTest, 680 class CrashReporterTest : public HeadlessBrowserTest,
678 public HeadlessWebContents::Observer, 681 public HeadlessWebContents::Observer,
679 inspector::ExperimentalObserver { 682 inspector::ExperimentalObserver {
680 public: 683 public:
681 CrashReporterTest() : devtools_client_(HeadlessDevToolsClient::Create()) {} 684 CrashReporterTest() : devtools_client_(HeadlessDevToolsClient::Create()) {}
682 ~CrashReporterTest() override {} 685 ~CrashReporterTest() override {}
683 686
684 void SetUp() override { 687 void SetUp() override {
685 base::ThreadRestrictions::SetIOAllowed(true); 688 base::ThreadRestrictions::SetIOAllowed(true);
686 base::CreateNewTempDirectory(FILE_PATH_LITERAL("CrashReporterTest"), 689 base::CreateNewTempDirectory("CrashReporterTest", &crash_dumps_dir_);
687 &crash_dumps_dir_);
688 EXPECT_FALSE(options()->enable_crash_reporter); 690 EXPECT_FALSE(options()->enable_crash_reporter);
689 options()->enable_crash_reporter = true; 691 options()->enable_crash_reporter = true;
690 options()->crash_dumps_dir = crash_dumps_dir_; 692 options()->crash_dumps_dir = crash_dumps_dir_;
691 HeadlessBrowserTest::SetUp(); 693 HeadlessBrowserTest::SetUp();
692 } 694 }
693 695
694 void TearDown() override { 696 void TearDown() override {
695 base::ThreadRestrictions::SetIOAllowed(true); 697 base::ThreadRestrictions::SetIOAllowed(true);
696 base::DeleteFile(crash_dumps_dir_, /* recursive */ false); 698 base::DeleteFile(crash_dumps_dir_, /* recursive */ false);
697 } 699 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 { 747 {
746 #if defined(OS_MACOSX) 748 #if defined(OS_MACOSX)
747 // Mac outputs dumps in the 'completed' directory. 749 // Mac outputs dumps in the 'completed' directory.
748 crash_dumps_dir_ = crash_dumps_dir_.Append("completed"); 750 crash_dumps_dir_ = crash_dumps_dir_.Append("completed");
749 #endif 751 #endif
750 base::ThreadRestrictions::SetIOAllowed(true); 752 base::ThreadRestrictions::SetIOAllowed(true);
751 base::FileEnumerator it(crash_dumps_dir_, /* recursive */ false, 753 base::FileEnumerator it(crash_dumps_dir_, /* recursive */ false,
752 base::FileEnumerator::FILES); 754 base::FileEnumerator::FILES);
753 base::FilePath minidump = it.Next(); 755 base::FilePath minidump = it.Next();
754 EXPECT_FALSE(minidump.empty()); 756 EXPECT_FALSE(minidump.empty());
755 EXPECT_EQ(FILE_PATH_LITERAL(".dmp"), minidump.Extension()); 757 EXPECT_EQ(".dmp", minidump.Extension());
756 EXPECT_TRUE(it.Next().empty()); 758 EXPECT_TRUE(it.Next().empty());
757 } 759 }
758 760
759 web_contents_->RemoveObserver(this); 761 web_contents_->RemoveObserver(this);
760 web_contents_->Close(); 762 web_contents_->Close();
761 web_contents_ = nullptr; 763 web_contents_ = nullptr;
762 764
763 browser_context_->Close(); 765 browser_context_->Close();
764 browser_context_ = nullptr; 766 browser_context_ = nullptr;
765 } 767 }
(...skipping 15 matching lines...) Expand all
781 web_contents->browser_context()->GetPermissionManager(); 783 web_contents->browser_context()->GetPermissionManager();
782 EXPECT_NE(nullptr, permission_manager); 784 EXPECT_NE(nullptr, permission_manager);
783 785
784 // 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.
785 EXPECT_EQ(blink::mojom::PermissionStatus::ASK, 787 EXPECT_EQ(blink::mojom::PermissionStatus::ASK,
786 permission_manager->GetPermissionStatus( 788 permission_manager->GetPermissionStatus(
787 content::PermissionType::NOTIFICATIONS, url, url)); 789 content::PermissionType::NOTIFICATIONS, url, url));
788 } 790 }
789 791
790 } // namespace headless 792 } // namespace headless
OLDNEW
« no previous file with comments | « headless/lib/browser/headless_browser_impl.cc ('k') | headless/lib/headless_content_main_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698