mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
LibWeb: Stub the ServiceWorkerContainer
interface
This commit is contained in:
parent
0c0a4a6042
commit
53ab6fa403
Notes:
github-actions[bot]
2024-08-25 10:54:07 +00:00
Author: https://github.com/tcl3
Commit: 53ab6fa403
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1173
8 changed files with 92 additions and 0 deletions
|
@ -85,6 +85,7 @@ static bool is_platform_object(Type const& type)
|
|||
"ReadableStream"sv,
|
||||
"Request"sv,
|
||||
"Selection"sv,
|
||||
"ServiceWorkerContainer"sv,
|
||||
"ServiceWorkerRegistration"sv,
|
||||
"SVGTransform"sv,
|
||||
"ShadowRoot"sv,
|
||||
|
|
|
@ -317,6 +317,7 @@ SVGUseElement
|
|||
Screen
|
||||
ScreenOrientation
|
||||
Selection
|
||||
ServiceWorkerContainer
|
||||
ServiceWorkerRegistration
|
||||
Set
|
||||
ShadowRealm
|
||||
|
|
|
@ -442,6 +442,7 @@ set(SOURCES
|
|||
HTML/Scripting/SerializedEnvironmentSettingsObject.cpp
|
||||
HTML/SelectedFile.cpp
|
||||
HTML/SelectItem.cpp
|
||||
HTML/ServiceWorkerContainer.cpp
|
||||
HTML/ServiceWorkerRegistration.cpp
|
||||
HTML/SessionHistoryEntry.cpp
|
||||
HTML/SessionHistoryTraversalQueue.cpp
|
||||
|
|
|
@ -485,6 +485,7 @@ class Plugin;
|
|||
class PluginArray;
|
||||
class PromiseRejectionEvent;
|
||||
class SelectedFile;
|
||||
class ServiceWorkerContainer;
|
||||
class ServiceWorkerRegistration;
|
||||
class SharedResourceRequest;
|
||||
class Storage;
|
||||
|
|
32
Userland/Libraries/LibWeb/HTML/ServiceWorkerContainer.cpp
Normal file
32
Userland/Libraries/LibWeb/HTML/ServiceWorkerContainer.cpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* 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/ServiceWorkerContainerPrototype.h>
|
||||
#include <LibWeb/HTML/ServiceWorkerContainer.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(ServiceWorkerContainer);
|
||||
|
||||
ServiceWorkerContainer::ServiceWorkerContainer(JS::Realm& realm)
|
||||
: DOM::EventTarget(realm)
|
||||
{
|
||||
}
|
||||
|
||||
void ServiceWorkerContainer::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(ServiceWorkerContainer);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<ServiceWorkerContainer> ServiceWorkerContainer::create(JS::Realm& realm)
|
||||
{
|
||||
return realm.heap().allocate<ServiceWorkerContainer>(realm, realm);
|
||||
}
|
||||
|
||||
}
|
26
Userland/Libraries/LibWeb/HTML/ServiceWorkerContainer.h
Normal file
26
Userland/Libraries/LibWeb/HTML/ServiceWorkerContainer.h
Normal 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 ServiceWorkerContainer : public DOM::EventTarget {
|
||||
WEB_PLATFORM_OBJECT(ServiceWorkerContainer, DOM::EventTarget);
|
||||
JS_DECLARE_ALLOCATOR(ServiceWorkerContainer);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<ServiceWorkerContainer> create(JS::Realm& realm);
|
||||
|
||||
explicit ServiceWorkerContainer(JS::Realm&);
|
||||
virtual ~ServiceWorkerContainer() override = default;
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
};
|
||||
|
||||
}
|
29
Userland/Libraries/LibWeb/HTML/ServiceWorkerContainer.idl
Normal file
29
Userland/Libraries/LibWeb/HTML/ServiceWorkerContainer.idl
Normal file
|
@ -0,0 +1,29 @@
|
|||
#import <DOM/EventTarget.idl>
|
||||
#import <DOM/EventHandler.idl>
|
||||
#import <HTML/ServiceWorkerRegistration.idl>
|
||||
#import <HTML/Worker.idl>
|
||||
|
||||
// https://w3c.github.io/ServiceWorker/#serviceworkercontainer-interface
|
||||
[SecureContext, Exposed=(Window,Worker)]
|
||||
interface ServiceWorkerContainer : EventTarget {
|
||||
[FIXME] readonly attribute ServiceWorker? controller;
|
||||
[FIXME] readonly attribute Promise<ServiceWorkerRegistration> ready;
|
||||
|
||||
[FIXME, NewObject] Promise<ServiceWorkerRegistration> register((TrustedScriptURL or USVString) scriptURL, optional RegistrationOptions options = {});
|
||||
|
||||
[FIXME, NewObject] Promise<(ServiceWorkerRegistration or undefined)> getRegistration(optional USVString clientURL = "");
|
||||
[FIXME, NewObject] Promise<FrozenArray<ServiceWorkerRegistration>> getRegistrations();
|
||||
|
||||
[FIXME] undefined startMessages();
|
||||
|
||||
// events
|
||||
[FIXME] attribute EventHandler oncontrollerchange;
|
||||
[FIXME] attribute EventHandler onmessage; // event.source of message events is ServiceWorker object
|
||||
[FIXME] attribute EventHandler onmessageerror;
|
||||
};
|
||||
|
||||
dictionary RegistrationOptions {
|
||||
USVString scope;
|
||||
WorkerType type = "classic";
|
||||
ServiceWorkerUpdateViaCache updateViaCache = "imports";
|
||||
};
|
|
@ -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/ServiceWorkerContainer)
|
||||
libweb_js_bindings(HTML/ServiceWorkerRegistration)
|
||||
libweb_js_bindings(HTML/Storage)
|
||||
libweb_js_bindings(HTML/SubmitEvent)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue