mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
LibWeb: Start implementing serviceWorker.register
This is mostly the fun boilerplate. Actually creating the Job queue to do the heavy lifting is next.
This commit is contained in:
parent
acd604c5e1
commit
c77d9a2732
Notes:
github-actions[bot]
2024-09-20 21:42:18 +00:00
Author: https://github.com/ADKaster
Commit: c77d9a2732
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1404
Reviewed-by: https://github.com/tcl3 ✅
7 changed files with 163 additions and 1 deletions
|
@ -7,7 +7,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Bindings/ServiceWorkerRegistrationPrototype.h>
|
||||
#include <LibWeb/Bindings/WorkerPrototype.h>
|
||||
#include <LibWeb/DOM/EventTarget.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
#include <LibWeb/WebIDL/Promise.h>
|
||||
|
||||
#define ENUMERATE_SERVICE_WORKER_CONTAINER_EVENT_HANDLERS(E) \
|
||||
E(oncontrollerchange, HTML::EventNames::controllerchange) \
|
||||
|
@ -16,6 +20,12 @@
|
|||
|
||||
namespace Web::HTML {
|
||||
|
||||
struct RegistrationOptions {
|
||||
Optional<String> scope;
|
||||
Bindings::WorkerType type = Bindings::WorkerType::Classic;
|
||||
Bindings::ServiceWorkerUpdateViaCache update_via_cache = Bindings::ServiceWorkerUpdateViaCache::Imports;
|
||||
};
|
||||
|
||||
class ServiceWorkerContainer : public DOM::EventTarget {
|
||||
WEB_PLATFORM_OBJECT(ServiceWorkerContainer, DOM::EventTarget);
|
||||
JS_DECLARE_ALLOCATOR(ServiceWorkerContainer);
|
||||
|
@ -24,6 +34,8 @@ public:
|
|||
[[nodiscard]] static JS::NonnullGCPtr<ServiceWorkerContainer> create(JS::Realm& realm);
|
||||
virtual ~ServiceWorkerContainer() override;
|
||||
|
||||
JS::NonnullGCPtr<JS::Promise> register_(String script_url, RegistrationOptions const& options);
|
||||
|
||||
#undef __ENUMERATE
|
||||
#define __ENUMERATE(attribute_name, event_name) \
|
||||
void set_##attribute_name(WebIDL::CallbackType*); \
|
||||
|
@ -37,6 +49,8 @@ private:
|
|||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
void start_register(Optional<URL::URL> scope_url, URL::URL script_url, JS::NonnullGCPtr<WebIDL::Promise>, EnvironmentSettingsObject&, URL::URL referrer, Bindings::WorkerType, Bindings::ServiceWorkerUpdateViaCache);
|
||||
|
||||
JS::NonnullGCPtr<EnvironmentSettingsObject> m_service_worker_client;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue