mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +00: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
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";
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue