LibWeb: Implement ServiceWorkerContainer.onmessage
This commit is contained in:
parent
820676857a
commit
4b1273cbde
Notes:
github-actions[bot]
2024-08-28 17:37:27 +00:00
Author: https://github.com/jamierocks Commit: https://github.com/LadybirdBrowser/ladybird/commit/4b1273cbde3 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1196 Reviewed-by: https://github.com/tcl3 ✅
3 changed files with 22 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Tim Ledbetter <tim.ledbetter@ladybird.org>
|
||||
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -7,6 +8,7 @@
|
|||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/ServiceWorkerContainerPrototype.h>
|
||||
#include <LibWeb/HTML/EventNames.h>
|
||||
#include <LibWeb/HTML/ServiceWorkerContainer.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -29,4 +31,16 @@ JS::NonnullGCPtr<ServiceWorkerContainer> ServiceWorkerContainer::create(JS::Real
|
|||
return realm.heap().allocate<ServiceWorkerContainer>(realm, realm);
|
||||
}
|
||||
|
||||
// https://w3c.github.io/ServiceWorker/#dom-serviceworkercontainer-onmessage
|
||||
WebIDL::CallbackType* ServiceWorkerContainer::onmessage()
|
||||
{
|
||||
return event_handler_attribute(HTML::EventNames::message);
|
||||
}
|
||||
|
||||
// https://w3c.github.io/ServiceWorker/#dom-serviceworkercontainer-onmessage
|
||||
void ServiceWorkerContainer::set_onmessage(WebIDL::CallbackType* event_handler)
|
||||
{
|
||||
set_event_handler_attribute(HTML::EventNames::message, event_handler);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Tim Ledbetter <tim.ledbetter@ladybird.org>
|
||||
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -16,10 +17,14 @@ class ServiceWorkerContainer : public DOM::EventTarget {
|
|||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<ServiceWorkerContainer> create(JS::Realm& realm);
|
||||
|
||||
explicit ServiceWorkerContainer(JS::Realm&);
|
||||
virtual ~ServiceWorkerContainer() override = default;
|
||||
|
||||
WebIDL::CallbackType* onmessage();
|
||||
void set_onmessage(WebIDL::CallbackType*);
|
||||
|
||||
private:
|
||||
explicit ServiceWorkerContainer(JS::Realm&);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
};
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ interface ServiceWorkerContainer : EventTarget {
|
|||
|
||||
// events
|
||||
[FIXME] attribute EventHandler oncontrollerchange;
|
||||
[FIXME] attribute EventHandler onmessage; // event.source of message events is ServiceWorker object
|
||||
attribute EventHandler onmessage; // event.source of message events is ServiceWorker object
|
||||
[FIXME] attribute EventHandler onmessageerror;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue