mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:07:34 +00:00
LibWeb: Add simple ad-hoc version of window.postMessage()
This allows us to use the wpt.live copy of the ACID3 test, which is kept updated, unlike the acidtests.org version.
This commit is contained in:
parent
fc5e414596
commit
f855cbac92
4 changed files with 29 additions and 0 deletions
|
@ -19,6 +19,7 @@
|
|||
#include <LibWeb/DOM/Window.h>
|
||||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
#include <LibWeb/HTML/EventLoop/EventLoop.h>
|
||||
#include <LibWeb/HTML/MessageEvent.h>
|
||||
#include <LibWeb/HTML/PageTransitionEvent.h>
|
||||
#include <LibWeb/HTML/Scripting/ExceptionReporter.h>
|
||||
#include <LibWeb/HTML/Storage.h>
|
||||
|
@ -476,4 +477,18 @@ Window* Window::parent()
|
|||
return ¤t->active_document()->window();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/web-messaging.html#window-post-message-steps
|
||||
DOM::ExceptionOr<void> Window::post_message(JS::Value message, String const&)
|
||||
{
|
||||
// FIXME: This is an ad-hoc hack implementation instead, since we don't currently
|
||||
// have serialization and deserialization of messages.
|
||||
HTML::queue_global_task(HTML::Task::Source::PostedMessage, *wrapper(), [strong_this = NonnullRefPtr(*this), message]() mutable {
|
||||
HTML::MessageEventInit event_init {};
|
||||
event_init.data = message;
|
||||
event_init.origin = "<origin>";
|
||||
strong_this->dispatch_event(HTML::MessageEvent::create(HTML::EventNames::message, event_init));
|
||||
});
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue