#include "content/browser/worker_host/mock_shared_worker.h"
#include "mojo/public/cpp/test_support/test_utils.h"
#include "services/network/public/mojom/content_security_policy.mojom-forward.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/loader/url_loader_factory_bundle.h"
#include "third_party/blink/public/mojom/worker/shared_worker_info.mojom.h"
#include "url/gurl.h"
namespace content {
namespace {
template <typename T>
bool CheckEquality(const T& expected, const T& actual) { … }
}
MockSharedWorker::MockSharedWorker(
mojo::PendingReceiver<blink::mojom::SharedWorker> receiver)
: … { … }
MockSharedWorker::~MockSharedWorker() = default;
bool MockSharedWorker::CheckReceivedConnect(int* connection_request_id,
blink::MessagePortChannel* port) { … }
bool MockSharedWorker::CheckNotReceivedConnect() { … }
bool MockSharedWorker::CheckReceivedTerminate() { … }
void MockSharedWorker::Disconnect() { … }
void MockSharedWorker::Connect(int connection_request_id,
blink::MessagePortDescriptor port) { … }
void MockSharedWorker::Terminate() { … }
MockSharedWorkerFactory::MockSharedWorkerFactory(
mojo::PendingReceiver<blink::mojom::SharedWorkerFactory> receiver)
: … { … }
MockSharedWorkerFactory::~MockSharedWorkerFactory() = default;
bool MockSharedWorkerFactory::CheckReceivedCreateSharedWorker(
const GURL& expected_url,
const std::string& expected_name,
const std::vector<network::mojom::ContentSecurityPolicyPtr>&
expected_content_security_policies,
mojo::Remote<blink::mojom::SharedWorkerHost>* host,
mojo::PendingReceiver<blink::mojom::SharedWorker>* receiver) { … }
void MockSharedWorkerFactory::Disconnect() { … }
void MockSharedWorkerFactory::CreateSharedWorker(
blink::mojom::SharedWorkerInfoPtr info,
const blink::SharedWorkerToken& token,
const blink::StorageKey& constructor_key,
const url::Origin& renderer_origin,
bool is_constructor_secure_context,
const std::string& user_agent,
const blink::UserAgentMetadata& ua_metadata,
bool pause_on_start,
const base::UnguessableToken& devtools_worker_token,
const blink::RendererPreferences& renderer_preferences,
mojo::PendingReceiver<blink::mojom::RendererPreferenceWatcher>
preference_watcher_receiver,
mojo::PendingRemote<blink::mojom::WorkerContentSettingsProxy>
content_settings,
blink::mojom::ServiceWorkerContainerInfoForClientPtr
service_worker_container_info,
blink::mojom::WorkerMainScriptLoadParamsPtr main_script_load_params,
std::unique_ptr<blink::PendingURLLoaderFactoryBundle>
subresource_loader_factories,
blink::mojom::ControllerServiceWorkerInfoPtr controller_info,
blink::mojom::PolicyContainerPtr policy_container,
mojo::PendingRemote<blink::mojom::SharedWorkerHost> host,
mojo::PendingReceiver<blink::mojom::SharedWorker> receiver,
mojo::PendingRemote<blink::mojom::BrowserInterfaceBroker>
browser_interface_broker,
ukm::SourceId ukm_source_id,
bool require_cross_site_request_for_cookies) { … }
MockSharedWorkerFactory::CreateParams::CreateParams() = default;
MockSharedWorkerFactory::CreateParams::~CreateParams() = default;
MockSharedWorkerClient::MockSharedWorkerClient() = default;
MockSharedWorkerClient::~MockSharedWorkerClient() = default;
void MockSharedWorkerClient::Bind(
mojo::PendingReceiver<blink::mojom::SharedWorkerClient> receiver) { … }
void MockSharedWorkerClient::Close() { … }
bool MockSharedWorkerClient::CheckReceivedOnCreated() { … }
bool MockSharedWorkerClient::CheckReceivedOnConnected(
std::set<blink::mojom::WebFeature> expected_used_features) { … }
bool MockSharedWorkerClient::CheckReceivedOnFeatureUsed(
blink::mojom::WebFeature expected_feature) { … }
bool MockSharedWorkerClient::CheckNotReceivedOnFeatureUsed() { … }
bool MockSharedWorkerClient::CheckReceivedOnScriptLoadFailed() { … }
void MockSharedWorkerClient::ResetReceiver() { … }
void MockSharedWorkerClient::OnCreated(
blink::mojom::SharedWorkerCreationContextType creation_context_type) { … }
void MockSharedWorkerClient::OnConnected(
const std::vector<blink::mojom::WebFeature>& features_used) { … }
void MockSharedWorkerClient::OnScriptLoadFailed(
const std::string& error_message) { … }
void MockSharedWorkerClient::OnFeatureUsed(blink::mojom::WebFeature feature) { … }
}