From cc11dcc9a10c4ed6a439f68ed9f4421cc70cca0f Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Sat, 30 Nov 2024 18:35:45 +1300 Subject: [PATCH] LibWeb: Add stubbed implementation for ServiceWorkerGlobalScope --- Libraries/LibWeb/CMakeLists.txt | 1 + .../ServiceWorkerGlobalScope.cpp | 20 +++++++++++++++ .../ServiceWorker/ServiceWorkerGlobalScope.h | 25 +++++++++++++++++++ .../ServiceWorkerGlobalScope.idl | 18 +++++++++++++ Libraries/LibWeb/idl_files.cmake | 1 + 5 files changed, 65 insertions(+) create mode 100644 Libraries/LibWeb/ServiceWorker/ServiceWorkerGlobalScope.cpp create mode 100644 Libraries/LibWeb/ServiceWorker/ServiceWorkerGlobalScope.h create mode 100644 Libraries/LibWeb/ServiceWorker/ServiceWorkerGlobalScope.idl diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt index 601716b3a81..65ff7886876 100644 --- a/Libraries/LibWeb/CMakeLists.txt +++ b/Libraries/LibWeb/CMakeLists.txt @@ -669,6 +669,7 @@ set(SOURCES ServiceWorker/Registration.cpp ServiceWorker/ServiceWorker.cpp ServiceWorker/ServiceWorkerContainer.cpp + ServiceWorker/ServiceWorkerGlobalScope.cpp ServiceWorker/ServiceWorkerRecord.cpp ServiceWorker/ServiceWorkerRegistration.cpp SRI/SRI.cpp diff --git a/Libraries/LibWeb/ServiceWorker/ServiceWorkerGlobalScope.cpp b/Libraries/LibWeb/ServiceWorker/ServiceWorkerGlobalScope.cpp new file mode 100644 index 00000000000..e77aed7758a --- /dev/null +++ b/Libraries/LibWeb/ServiceWorker/ServiceWorkerGlobalScope.cpp @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2024, Shannon Booth + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include + +namespace Web::ServiceWorker { + +GC_DEFINE_ALLOCATOR(ServiceWorkerGlobalScope); + +ServiceWorkerGlobalScope::~ServiceWorkerGlobalScope() = default; + +ServiceWorkerGlobalScope::ServiceWorkerGlobalScope(JS::Realm& realm, GC::Ref page) + : HTML::WorkerGlobalScope(realm, page) +{ +} + +} diff --git a/Libraries/LibWeb/ServiceWorker/ServiceWorkerGlobalScope.h b/Libraries/LibWeb/ServiceWorker/ServiceWorkerGlobalScope.h new file mode 100644 index 00000000000..79a412e3d71 --- /dev/null +++ b/Libraries/LibWeb/ServiceWorker/ServiceWorkerGlobalScope.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024, Shannon Booth + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include + +namespace Web::ServiceWorker { + +// https://w3c.github.io/ServiceWorker/#serviceworkerglobalscope +class ServiceWorkerGlobalScope : public HTML::WorkerGlobalScope { + WEB_PLATFORM_OBJECT(ServiceWorkerGlobalScope, HTML::WorkerGlobalScope); + GC_DECLARE_ALLOCATOR(ServiceWorkerGlobalScope); + +public: + virtual ~ServiceWorkerGlobalScope() override; + +protected: + explicit ServiceWorkerGlobalScope(JS::Realm&, GC::Ref); +}; + +} diff --git a/Libraries/LibWeb/ServiceWorker/ServiceWorkerGlobalScope.idl b/Libraries/LibWeb/ServiceWorker/ServiceWorkerGlobalScope.idl new file mode 100644 index 00000000000..e80b1459bcf --- /dev/null +++ b/Libraries/LibWeb/ServiceWorker/ServiceWorkerGlobalScope.idl @@ -0,0 +1,18 @@ +#import + +// https://w3c.github.io/ServiceWorker/#serviceworkerglobalscope +[Global=(Worker,ServiceWorker), Exposed=ServiceWorker, SecureContext] +interface ServiceWorkerGlobalScope : WorkerGlobalScope { + [FIXME, SameObject] readonly attribute Clients clients; + [FIXME, SameObject] readonly attribute ServiceWorkerRegistration registration; + [FIXME, SameObject] readonly attribute ServiceWorker serviceWorker; + + [FIXME, NewObject] Promise skipWaiting(); + + [FIXME] attribute EventHandler oninstall; + [FIXME] attribute EventHandler onactivate; + [FIXME] attribute EventHandler onfetch; + + [FIXME] attribute EventHandler onmessage; + [FIXME] attribute EventHandler onmessageerror; +}; diff --git a/Libraries/LibWeb/idl_files.cmake b/Libraries/LibWeb/idl_files.cmake index fbcd14f5b6f..34727a224d9 100644 --- a/Libraries/LibWeb/idl_files.cmake +++ b/Libraries/LibWeb/idl_files.cmake @@ -277,6 +277,7 @@ libweb_js_bindings(ResizeObserver/ResizeObserverEntry) libweb_js_bindings(ResizeObserver/ResizeObserverSize) libweb_js_bindings(ServiceWorker/ServiceWorker) libweb_js_bindings(ServiceWorker/ServiceWorkerContainer) +libweb_js_bindings(ServiceWorker/ServiceWorkerGlobalScope GLOBAL) libweb_js_bindings(ServiceWorker/ServiceWorkerRegistration) libweb_js_bindings(Streams/ByteLengthQueuingStrategy) libweb_js_bindings(Streams/CountQueuingStrategy)