#include <memory>
#include <string>
#include <vector>
#include "base/functional/callback.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/test/allow_check_is_test_for_testing.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/browser/lifetime/browser_shutdown.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "components/network_session_configurator/common/network_switches.h"
#include "components/variations/net/variations_http_headers.h"
#include "content/public/browser/back_forward_cache.h"
#include "content/public/test/back_forward_cache_util.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/keep_alive_url_loader_utils.h"
#include "content/public/test/test_utils.h"
#include "net/dns/mock_host_resolver.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_status_code.h"
#include "net/test/embedded_test_server/controllable_http_response.h"
#include "net/test/embedded_test_server/default_handlers.h"
#include "third_party/blink/public/common/features.h"
namespace {
Contains;
Key;
Not;
constexpr char kPrimaryHost[] = …;
constexpr char kSecondaryHost[] = …;
constexpr char kGoogleHost[] = …;
constexpr char kKeepAliveEndpoint[] = …;
constexpr char16_t kPromiseResolvedPageTitle[] = …;
constexpr char k200TextResponse[] = …;
constexpr char k301ResponseTemplate[] = …;
}
class ChromeKeepAliveURLBrowserTestBase : public InProcessBrowserTest { … };
class ChromeKeepAliveURLBrowserTest
: public ChromeKeepAliveURLBrowserTestBase,
public ::testing::WithParamInterface<std::string> { … };
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(ChromeKeepAliveURLBrowserTest, OneRequest) { … }
IN_PROC_BROWSER_TEST_P(ChromeKeepAliveURLBrowserTest,
ReceiveResponseAfterPageUnload) { … }
#if !BUILDFLAG(IS_ANDROID)
#if BUILDFLAG(IS_MAC)
#define MAYBE_ReceiveResponseAfterBrowserShutdown …
#else
#define MAYBE_ReceiveResponseAfterBrowserShutdown …
#endif
IN_PROC_BROWSER_TEST_P(ChromeKeepAliveURLBrowserTest,
MAYBE_ReceiveResponseAfterBrowserShutdown) { … }
#endif
IN_PROC_BROWSER_TEST_P(ChromeKeepAliveURLBrowserTest,
ReceiveResponseInBackForwardCache) { … }
IN_PROC_BROWSER_TEST_P(ChromeKeepAliveURLBrowserTest,
ReceiveRedirectAfterPageUnload) { … }
IN_PROC_BROWSER_TEST_P(ChromeKeepAliveURLBrowserTest,
ReceiveUnSafeRedirectAfterPageUnload) { … }
IN_PROC_BROWSER_TEST_P(ChromeKeepAliveURLBrowserTest,
ReceiveMultipleRedirectsToGoogleAfterPageUnload) { … }
class ChromeKeepAliveURLVariationBrowserTest
: public ChromeKeepAliveURLBrowserTestBase,
public ::testing::WithParamInterface<std::string> { … };
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(ChromeKeepAliveURLVariationBrowserTest,
ReceiveRedirectToGoogleAfterPageUnloadAndStripHeaders) { … }