mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 04:39:06 +00:00
LibWeb: Implement nagivator.serviceWorker.getRegistration()
This commit is contained in:
parent
8e410f959c
commit
37e1d6ece1
Notes:
github-actions[bot]
2025-01-30 22:19:44 +00:00
Author: https://github.com/F3n67u
Commit: 37e1d6ece1
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3110
Reviewed-by: https://github.com/ADKaster ✅
12 changed files with 280 additions and 36 deletions
|
@ -10,17 +10,42 @@
|
|||
|
||||
namespace Web::ServiceWorker {
|
||||
|
||||
// https://w3c.github.io/ServiceWorker/#serviceworkerregistration-interface
|
||||
class ServiceWorkerRegistration : public DOM::EventTarget {
|
||||
WEB_PLATFORM_OBJECT(ServiceWorkerRegistration, DOM::EventTarget);
|
||||
GC_DECLARE_ALLOCATOR(ServiceWorkerRegistration);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static GC::Ref<ServiceWorkerRegistration> create(JS::Realm& realm);
|
||||
[[nodiscard]] static GC::Ref<ServiceWorkerRegistration> create(JS::Realm& realm, Registration const& registration);
|
||||
|
||||
explicit ServiceWorkerRegistration(JS::Realm&);
|
||||
Registration const& registration() { return m_registration; }
|
||||
|
||||
GC::Ptr<ServiceWorker> installing() const { return m_installing; }
|
||||
void set_installing(GC::Ptr<ServiceWorker> installing) { m_installing = installing; }
|
||||
|
||||
GC::Ptr<ServiceWorker> waiting() const { return m_waiting; }
|
||||
void set_waiting(GC::Ptr<ServiceWorker> waiting) { m_waiting = waiting; }
|
||||
|
||||
GC::Ptr<ServiceWorker> active() const { return m_active; }
|
||||
void set_active(GC::Ptr<ServiceWorker> active) { m_active = active; }
|
||||
|
||||
// https://w3c.github.io/ServiceWorker/#dom-serviceworkerregistration-scope
|
||||
String scope() const { return m_registration.scope_url().serialize(); }
|
||||
|
||||
// https://w3c.github.io/ServiceWorker/#dom-serviceworkerregistration-updateviacache
|
||||
Bindings::ServiceWorkerUpdateViaCache update_via_cache() const { return m_registration.update_via_cache(); }
|
||||
|
||||
explicit ServiceWorkerRegistration(JS::Realm&, Registration const&);
|
||||
virtual ~ServiceWorkerRegistration() override = default;
|
||||
|
||||
private:
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(JS::Cell::Visitor&) override;
|
||||
|
||||
Registration const& m_registration;
|
||||
GC::Ptr<ServiceWorker> m_installing;
|
||||
GC::Ptr<ServiceWorker> m_waiting;
|
||||
GC::Ptr<ServiceWorker> m_active;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue