#include <stdint.h>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/check_op.h"
#include "base/containers/span.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/notreached.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind.h"
#include "base/test/run_until.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_future.h"
#include "build/build_config.h"
#include "chrome/browser/content_settings/cookie_settings_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/login/login_handler.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/content_settings/core/browser/cookie_settings.h"
#include "components/content_settings/core/common/content_settings_metadata.h"
#include "components/content_settings/core/common/features.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/system/data_pipe.h"
#include "net/base/network_isolation_key.h"
#include "net/cookies/site_for_cookies.h"
#include "net/dns/mock_host_resolver.h"
#include "net/storage_access_api/status.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/spawned_test_server/spawned_test_server.h"
#include "net/test/test_data_directory.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "services/network/public/mojom/websocket.mojom.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace {
SSLOptions;
HasSubstr;
Not;
constexpr char kHostA[] = …;
constexpr char kHostB[] = …;
class WebSocketBrowserTest : public InProcessBrowserTest { … };
class WebSocketBrowserTestWithAllowFileAccessFromFiles
: public WebSocketBrowserTest { … };
class WebSocketBrowserConnectToTest : public WebSocketBrowserTest { … };
class WebSocketBrowserHTTPConnectToTest : public WebSocketBrowserConnectToTest { … };
class WebSocketBrowserHTTPSConnectToTest
: public WebSocketBrowserConnectToTest { … };
class WebSocketBrowserHTTPSConnectToTestPre3pcd
: public WebSocketBrowserHTTPSConnectToTest { … };
IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest, WebSocketSplitSegments) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_SecureWebSocketSplitRecords …
#else
#define MAYBE_SecureWebSocketSplitRecords …
#endif
IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest,
MAYBE_SecureWebSocketSplitRecords) { … }
IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest, SendCloseFrameWhenTabIsClosed) { … }
IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest, WebSocketBasicAuthInHTTPURL) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_WebSocketBasicAuthInHTTPSURL …
#else
#define MAYBE_WebSocketBasicAuthInHTTPSURL …
#endif
IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest,
MAYBE_WebSocketBasicAuthInHTTPSURL) { … }
IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest,
ReuseMainPageBasicAuthCredentialsForWebSocket) { … }
IN_PROC_BROWSER_TEST_F(WebSocketBrowserHTTPConnectToTest,
WebSocketBasicAuthInWSURL) { … }
IN_PROC_BROWSER_TEST_F(WebSocketBrowserHTTPConnectToTest,
WebSocketBasicAuthInWSURLBadCreds) { … }
IN_PROC_BROWSER_TEST_F(WebSocketBrowserHTTPConnectToTest,
WebSocketBasicAuthNoCreds) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_SSLConnectionLimit …
#else
#define MAYBE_SSLConnectionLimit …
#endif
IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest, MAYBE_SSLConnectionLimit) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_WebSocketAppliesHSTS …
#else
#define MAYBE_WebSocketAppliesHSTS …
#endif
IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest, MAYBE_WebSocketAppliesHSTS) { … }
class ExpectInvalidUtf8Client : public network::mojom::WebSocketClient { … };
class InvalidUtf8HandshakeClient
: public network::mojom::WebSocketHandshakeClient { … };
IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest, SendBadUtf8) { … }
class FailureMonitoringHandshakeClient
: public network::mojom::WebSocketHandshakeClient { … };
IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest, FailuresReported) { … }
IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest, CheckFileOrigin) { … }
IN_PROC_BROWSER_TEST_F(WebSocketBrowserTestWithAllowFileAccessFromFiles,
CheckFileOrigin) { … }
IN_PROC_BROWSER_TEST_F(WebSocketBrowserHTTPSConnectToTestPre3pcd,
CookieAccess_ThirdPartyAllowed) { … }
IN_PROC_BROWSER_TEST_F(WebSocketBrowserHTTPSConnectToTest,
CookieAccess_ThirdPartyBlocked) { … }
IN_PROC_BROWSER_TEST_F(WebSocketBrowserHTTPSConnectToTest,
CookieAccess_ThirdPartyAllowedBySetting) { … }
}