#include "content/browser/service_worker/fake_service_worker.h"
#include <utility>
#include "base/functional/bind.h"
#include "base/run_loop.h"
#include "content/browser/service_worker/embedded_worker_test_helper.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/network/public/mojom/fetch_api.mojom.h"
#include "third_party/blink/public/mojom/background_fetch/background_fetch.mojom.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_response.mojom.h"
#include "third_party/blink/public/mojom/payments/payment_app.mojom.h"
#include "third_party/blink/public/mojom/push_messaging/push_messaging.mojom.h"
#include "third_party/blink/public/mojom/service_worker/dispatch_fetch_event_params.mojom.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_fetch_response_callback.mojom.h"
namespace content {
FakeServiceWorker::FakeServiceWorker(EmbeddedWorkerTestHelper* helper)
: … { … }
FakeServiceWorker::~FakeServiceWorker() = default;
void FakeServiceWorker::Bind(
mojo::PendingReceiver<blink::mojom::ServiceWorker> receiver) { … }
void FakeServiceWorker::RunUntilInitializeGlobalScope() { … }
void FakeServiceWorker::FlushForTesting() { … }
base::WeakPtr<FakeServiceWorker> FakeServiceWorker::AsWeakPtr() { … }
void FakeServiceWorker::InitializeGlobalScope(
mojo::PendingAssociatedRemote<blink::mojom::ServiceWorkerHost>
service_worker_host,
mojo::PendingAssociatedRemote<blink::mojom::AssociatedInterfaceProvider>
associated_interfaces_from_browser,
mojo::PendingAssociatedReceiver<blink::mojom::AssociatedInterfaceProvider>
associated_interfaces_to_browser,
blink::mojom::ServiceWorkerRegistrationObjectInfoPtr registration_info,
blink::mojom::ServiceWorkerObjectInfoPtr service_worker_info,
blink::mojom::FetchHandlerExistence fetch_handler_existence,
mojo::PendingReceiver<blink::mojom::ReportingObserver>
reporting_observer_receiver,
blink::mojom::AncestorFrameType ancestor_frame_type,
const blink::StorageKey& storage_key) { … }
void FakeServiceWorker::DispatchInstallEvent(
DispatchInstallEventCallback callback) { … }
void FakeServiceWorker::DispatchActivateEvent(
DispatchActivateEventCallback callback) { … }
void FakeServiceWorker::DispatchBackgroundFetchAbortEvent(
blink::mojom::BackgroundFetchRegistrationPtr registration,
DispatchBackgroundFetchAbortEventCallback callback) { … }
void FakeServiceWorker::DispatchBackgroundFetchClickEvent(
blink::mojom::BackgroundFetchRegistrationPtr registration,
DispatchBackgroundFetchClickEventCallback callback) { … }
void FakeServiceWorker::DispatchBackgroundFetchFailEvent(
blink::mojom::BackgroundFetchRegistrationPtr registration,
DispatchBackgroundFetchFailEventCallback callback) { … }
void FakeServiceWorker::DispatchBackgroundFetchSuccessEvent(
blink::mojom::BackgroundFetchRegistrationPtr registration,
DispatchBackgroundFetchSuccessEventCallback callback) { … }
void FakeServiceWorker::DispatchCookieChangeEvent(
const net::CookieChangeInfo& change,
DispatchCookieChangeEventCallback callback) { … }
void FakeServiceWorker::DispatchFetchEventForMainResource(
blink::mojom::DispatchFetchEventParamsPtr params,
mojo::PendingRemote<blink::mojom::ServiceWorkerFetchResponseCallback>
pending_response_callback,
DispatchFetchEventForMainResourceCallback callback) { … }
void FakeServiceWorker::DispatchNotificationClickEvent(
const std::string& notification_id,
const blink::PlatformNotificationData& notification_data,
int action_index,
const std::optional<std::u16string>& reply,
DispatchNotificationClickEventCallback callback) { … }
void FakeServiceWorker::DispatchNotificationCloseEvent(
const std::string& notification_id,
const blink::PlatformNotificationData& notification_data,
DispatchNotificationCloseEventCallback callback) { … }
void FakeServiceWorker::DispatchPushEvent(
const std::optional<std::string>& payload,
DispatchPushEventCallback callback) { … }
void FakeServiceWorker::DispatchPushSubscriptionChangeEvent(
blink::mojom::PushSubscriptionPtr old_subscription,
blink::mojom::PushSubscriptionPtr new_subscription,
DispatchPushSubscriptionChangeEventCallback callback) { … }
void FakeServiceWorker::DispatchSyncEvent(const std::string& tag,
bool last_chance,
base::TimeDelta timeout,
DispatchSyncEventCallback callback) { … }
void FakeServiceWorker::DispatchPeriodicSyncEvent(
const std::string& tag,
base::TimeDelta timeout,
DispatchPeriodicSyncEventCallback callback) { … }
void FakeServiceWorker::DispatchAbortPaymentEvent(
mojo::PendingRemote<payments::mojom::PaymentHandlerResponseCallback>
pending_response_callback,
DispatchAbortPaymentEventCallback callback) { … }
void FakeServiceWorker::DispatchCanMakePaymentEvent(
payments::mojom::CanMakePaymentEventDataPtr event_data,
mojo::PendingRemote<payments::mojom::PaymentHandlerResponseCallback>
pending_response_callback,
DispatchCanMakePaymentEventCallback callback) { … }
void FakeServiceWorker::DispatchPaymentRequestEvent(
payments::mojom::PaymentRequestEventDataPtr event_data,
mojo::PendingRemote<payments::mojom::PaymentHandlerResponseCallback>
pending_response_callback,
DispatchPaymentRequestEventCallback callback) { … }
void FakeServiceWorker::DispatchExtendableMessageEvent(
blink::mojom::ExtendableMessageEventPtr event,
DispatchExtendableMessageEventCallback callback) { … }
void FakeServiceWorker::DispatchContentDeleteEvent(
const std::string& id,
DispatchContentDeleteEventCallback callback) { … }
void FakeServiceWorker::Ping(PingCallback callback) { … }
void FakeServiceWorker::SetIdleDelay(base::TimeDelta delay) { … }
void FakeServiceWorker::AddKeepAlive() { … }
void FakeServiceWorker::ClearKeepAlive() { … }
void FakeServiceWorker::AddMessageToConsole(
blink::mojom::ConsoleMessageLevel level,
const std::string& message) { … }
void FakeServiceWorker::ExecuteScriptForTest(
const std::u16string& script,
bool wants_result,
ExecuteScriptForTestCallback callback) { … }
void FakeServiceWorker::OnConnectionError() { … }
void FakeServiceWorker::CallOnConnectionError() { … }
}