mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:17:45 +00:00
LibWeb: Make Window.postMessage closer to the spec
The main issues are using Structured{Serialize,Deserailize} instead of Structured{Serialize,Deserialize}WithTransfer and the temporary execution context usage for StructuredDeserialize. Allows Discord to load once again, as it uses a postMessage scheduler to render components, including the main App component. The callback checked the (previously) non-existent source attribute of the MessageEvent and returned if it was not the main window. Fixes the Twitch cookie consent banner saying "failed integrity check" for unknown reasons, but presumably related to the source and origin attributes.
This commit is contained in:
parent
464cc55b16
commit
fc42c75a0c
5 changed files with 361 additions and 13 deletions
|
@ -38,6 +38,11 @@ struct ScrollToOptions : public ScrollOptions {
|
|||
Optional<double> top;
|
||||
};
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#windowpostmessageoptions
|
||||
struct WindowPostMessageOptions : public StructuredSerializeOptions {
|
||||
String target_origin { "/"_string };
|
||||
};
|
||||
|
||||
class Window final
|
||||
: public DOM::EventTarget
|
||||
, public GlobalEventHandlers
|
||||
|
@ -146,7 +151,8 @@ public:
|
|||
bool confirm(Optional<String> const& message);
|
||||
Optional<String> prompt(Optional<String> const& message, Optional<String> const& default_);
|
||||
|
||||
void post_message(JS::Value message, String const&);
|
||||
WebIDL::ExceptionOr<void> post_message(JS::Value message, String const&, Vector<JS::Handle<JS::Object>> const&);
|
||||
WebIDL::ExceptionOr<void> post_message(JS::Value message, WindowPostMessageOptions const&);
|
||||
|
||||
Variant<JS::Handle<DOM::Event>, JS::Value> event() const;
|
||||
|
||||
|
@ -215,6 +221,8 @@ private:
|
|||
};
|
||||
NamedObjects named_objects(StringView name);
|
||||
|
||||
WebIDL::ExceptionOr<void> window_post_message_steps(JS::Value, WindowPostMessageOptions const&);
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/window-object.html#concept-document-window
|
||||
JS::GCPtr<DOM::Document> m_associated_document;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue