LibWeb: Stub the ServiceWorkerRegistration interface

This commit is contained in:
Tim Ledbetter 2024-08-22 22:59:01 +01:00 committed by Andreas Kling
parent 70fdf7affb
commit 0c0a4a6042
Notes: github-actions[bot] 2024-08-25 10:54:13 +00:00
8 changed files with 88 additions and 0 deletions

View file

@ -85,6 +85,7 @@ static bool is_platform_object(Type const& type)
"ReadableStream"sv,
"Request"sv,
"Selection"sv,
"ServiceWorkerRegistration"sv,
"SVGTransform"sv,
"ShadowRoot"sv,
"Table"sv,

View file

@ -317,6 +317,7 @@ SVGUseElement
Screen
ScreenOrientation
Selection
ServiceWorkerRegistration
Set
ShadowRealm
ShadowRoot

View file

@ -442,6 +442,7 @@ set(SOURCES
HTML/Scripting/SerializedEnvironmentSettingsObject.cpp
HTML/SelectedFile.cpp
HTML/SelectItem.cpp
HTML/ServiceWorkerRegistration.cpp
HTML/SessionHistoryEntry.cpp
HTML/SessionHistoryTraversalQueue.cpp
HTML/SharedResourceRequest.cpp

View file

@ -485,6 +485,7 @@ class Plugin;
class PluginArray;
class PromiseRejectionEvent;
class SelectedFile;
class ServiceWorkerRegistration;
class SharedResourceRequest;
class Storage;
class SubmitEvent;

View file

@ -0,0 +1,31 @@
/*
* Copyright (c) 2024, Tim Ledbetter <tim.ledbetter@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Runtime/Realm.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/ServiceWorkerRegistrationPrototype.h>
#include <LibWeb/HTML/ServiceWorkerRegistration.h>
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(ServiceWorkerRegistration);
ServiceWorkerRegistration::ServiceWorkerRegistration(JS::Realm& realm)
: DOM::EventTarget(realm)
{
}
void ServiceWorkerRegistration::initialize(JS::Realm& realm)
{
Base::initialize(realm);
WEB_SET_PROTOTYPE_FOR_INTERFACE(ServiceWorkerRegistration);
}
JS::NonnullGCPtr<ServiceWorkerRegistration> ServiceWorkerRegistration::create(JS::Realm& realm)
{
return realm.heap().allocate<ServiceWorkerRegistration>(realm, realm);
}
}

View file

@ -0,0 +1,26 @@
/*
* Copyright (c) 2024, Tim Ledbetter <tim.ledbetter@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/DOM/EventTarget.h>
namespace Web::HTML {
class ServiceWorkerRegistration : public DOM::EventTarget {
WEB_PLATFORM_OBJECT(ServiceWorkerRegistration, DOM::EventTarget);
JS_DECLARE_ALLOCATOR(ServiceWorkerRegistration);
public:
[[nodiscard]] static JS::NonnullGCPtr<ServiceWorkerRegistration> create(JS::Realm& realm);
explicit ServiceWorkerRegistration(JS::Realm&);
virtual ~ServiceWorkerRegistration() override = default;
virtual void initialize(JS::Realm&) override;
};
}

View file

@ -0,0 +1,26 @@
#import <DOM/EventTarget.idl>
#import <DOM/EventHandler.idl>
// https://w3c.github.io/ServiceWorker/#serviceworkerregistration-interface
[SecureContext, Exposed=(Window,Worker)]
interface ServiceWorkerRegistration : EventTarget {
[FIXME] readonly attribute ServiceWorker? installing;
[FIXME] readonly attribute ServiceWorker? waiting;
[FIXME] readonly attribute ServiceWorker? active;
[FIXME, SameObject] readonly attribute NavigationPreloadManager navigationPreload;
[FIXME] readonly attribute USVString scope;
[FIXME] readonly attribute ServiceWorkerUpdateViaCache updateViaCache;
[FIXME, NewObject] Promise<undefined> update();
[FIXME, NewObject] Promise<boolean> unregister();
// event
[FIXME] attribute EventHandler onupdatefound;
};
enum ServiceWorkerUpdateViaCache {
"imports",
"all",
"none"
};

View file

@ -213,6 +213,7 @@ libweb_js_bindings(HTML/Plugin)
libweb_js_bindings(HTML/PluginArray)
libweb_js_bindings(HTML/PopStateEvent)
libweb_js_bindings(HTML/PromiseRejectionEvent)
libweb_js_bindings(HTML/ServiceWorkerRegistration)
libweb_js_bindings(HTML/Storage)
libweb_js_bindings(HTML/SubmitEvent)
libweb_js_bindings(HTML/TextMetrics)