#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/run_loop.h"
#include "base/scoped_environment_variable_override.h"
#include "base/strings/strcat.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/lock.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_command_line.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_timeouts.h"
#include "base/thread_annotations.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "content/browser/network_service_instance_impl.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/browser/service_worker/embedded_worker_instance.h"
#include "content/browser/service_worker/service_worker_context_core_observer.h"
#include "content/browser/storage_partition_impl.h"
#include "content/browser/worker_host/test_shared_worker_service_impl.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/network_service_instance.h"
#include "content/public/browser/network_service_util.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/isolated_world_ids.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/commit_message_delayer.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/public/test/simple_url_loader_test_helper.h"
#include "content/public/test/test_utils.h"
#include "content/shell/browser/shell.h"
#include "content/shell/browser/shell_browser_context.h"
#include "content/test/io_thread_shared_url_loader_factory_owner.h"
#include "content/test/storage_partition_test_helpers.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/bindings/sync_call_restrictions.h"
#include "net/base/features.h"
#include "net/cookies/canonical_cookie_test_helpers.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/cert_verifier/public/mojom/cert_verifier_service_factory.mojom.h"
#include "services/network/public/cpp/network_switches.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "services/network/public/mojom/network_service.mojom.h"
#include "services/network/public/mojom/network_service_test.mojom.h"
#include "services/network/test/test_url_loader_client.h"
#include "testing/gmock/include/gmock/gmock-matchers.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/service_worker/embedded_worker_status.h"
namespace content {
namespace {
const char kHostA[] = …;
const char kCookieName[] = …;
mojo::PendingRemote<network::mojom::NetworkContext> CreateNetworkContext() { … }
int LoadBasicRequestOnUIThread(
network::mojom::URLLoaderFactory* url_loader_factory,
const GURL& url) { … }
class ServiceWorkerStatusObserver : public ServiceWorkerContextCoreObserver { … };
}
class NetworkServiceRestartBrowserTest : public ContentBrowserTest { … };
IN_PROC_BROWSER_TEST_F(NetworkServiceRestartBrowserTest,
NetworkServiceProcessRecovery) { … }
void IncrementIntExpectingCrash(int* i, bool crashed) { … }
IN_PROC_BROWSER_TEST_F(NetworkServiceRestartBrowserTest, CrashHandlers) { … }
IN_PROC_BROWSER_TEST_F(NetworkServiceRestartBrowserTest,
StoragePartitionImplGetNetworkContext) { … }
IN_PROC_BROWSER_TEST_F(NetworkServiceRestartBrowserTest,
GetURLLoaderFactoryForBrowserProcessIOThread) { … }
IN_PROC_BROWSER_TEST_F(NetworkServiceRestartBrowserTest,
BrowserIOSharedURLLoaderFactory) { … }
IN_PROC_BROWSER_TEST_F(NetworkServiceRestartBrowserTest,
BrowserIOSharedFactoryAfterStoragePartitionGone) { … }
IN_PROC_BROWSER_TEST_F(NetworkServiceRestartBrowserTest,
NavigationURLLoaderBasic) { … }
IN_PROC_BROWSER_TEST_F(NetworkServiceRestartBrowserTest, BasicXHR) { … }
IN_PROC_BROWSER_TEST_F(NetworkServiceRestartBrowserTest, BrowserUIFactory) { … }
IN_PROC_BROWSER_TEST_F(NetworkServiceRestartBrowserTest,
BrowserUIFactoryAfterStoragePartitionGone) { … }
#if BUILDFLAG(IS_WIN)
#define MAYBE_BrowserIOPendingFactory …
#else
#define MAYBE_BrowserIOPendingFactory …
#endif
IN_PROC_BROWSER_TEST_F(NetworkServiceRestartBrowserTest,
MAYBE_BrowserIOPendingFactory) { … }
IN_PROC_BROWSER_TEST_F(NetworkServiceRestartBrowserTest, BrowserIOFactory) { … }
IN_PROC_BROWSER_TEST_F(NetworkServiceRestartBrowserTest, WindowOpenXHR) { … }
class NetworkServiceRestartForWorkerBrowserTest
: public NetworkServiceRestartBrowserTest,
public ::testing::WithParamInterface<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(NetworkServiceRestartForWorkerBrowserTest, WorkerFetch) { … }
IN_PROC_BROWSER_TEST_P(NetworkServiceRestartForWorkerBrowserTest,
MultipleWorkerFetch) { … }
IN_PROC_BROWSER_TEST_F(NetworkServiceRestartBrowserTest,
FetchFromServiceWorkerControlledPage_NoFetchHandler) { … }
IN_PROC_BROWSER_TEST_F(NetworkServiceRestartBrowserTest,
FetchFromServiceWorkerControlledPage_PassThrough) { … }
IN_PROC_BROWSER_TEST_F(NetworkServiceRestartBrowserTest,
FetchFromServiceWorkerControlledPage_RespondWithFetch) { … }
IN_PROC_BROWSER_TEST_F(NetworkServiceRestartBrowserTest, ServiceWorkerFetch) { … }
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_SharedWorker …
#else
#define MAYBE_SharedWorker …
#endif
IN_PROC_BROWSER_TEST_F(NetworkServiceRestartBrowserTest, MAYBE_SharedWorker) { … }
IN_PROC_BROWSER_TEST_F(NetworkServiceRestartBrowserTest, SSLKeyLogFileMetrics) { … }
IN_PROC_BROWSER_TEST_F(NetworkServiceRestartBrowserTest, Cookies) { … }
#if BUILDFLAG(IS_ANDROID)
IN_PROC_BROWSER_TEST_F(NetworkServiceRestartBrowserTest,
DISABLED_SyncCallDuringRestart) {
if (IsInProcessNetworkService())
return;
base::RunLoop run_loop;
mojo::Remote<network::mojom::NetworkServiceTest> network_service_test;
content::GetNetworkService()->BindTestInterfaceForTesting(
network_service_test.BindNewPipeAndPassReceiver());
IgnoreNetworkServiceCrashes();
network_service_test.set_disconnect_handler(run_loop.QuitClosure());
network_service_test->SimulateCrash();
run_loop.Run();
network_service_test.reset();
content::GetNetworkService()->BindTestInterfaceForTesting(
network_service_test.BindNewPipeAndPassReceiver());
mojo::ScopedAllowSyncCallForTesting allow_sync_call;
network_service_test->AddRules({});
}
#endif
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_MAC)
#define MAYBE_BetweenCommitNavigationAndDidCommit …
#else
#define MAYBE_BetweenCommitNavigationAndDidCommit …
#endif
IN_PROC_BROWSER_TEST_F(NetworkServiceRestartBrowserTest,
MAYBE_BetweenCommitNavigationAndDidCommit) { … }
IN_PROC_BROWSER_TEST_F(NetworkServiceRestartBrowserTest,
RestoreNetworkRevocationNonces) { … }
class NetworkServiceRestartWithFirstPartySetBrowserTest
: public NetworkServiceRestartBrowserTest { … };
IN_PROC_BROWSER_TEST_F(NetworkServiceRestartWithFirstPartySetBrowserTest,
GetsUseFirstPartySetSwitch) { … }
}