1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 * For more information on this interface, please see
7 * https://html.spec.whatwg.org/#messageevent
10 [Exposed=(Window,Worker,AudioWorklet), ProbablyShortLivingWrapper]
11 interface MessageEvent : Event {
12 constructor(DOMString type, optional MessageEventInit eventInitDict = {});
15 * Custom data associated with this event.
18 readonly attribute any data;
21 * The origin of the site from which this event originated, which is the
22 * scheme, ":", and if the URI has a host, "//" followed by the
23 * host, and if the port is not the default for the given scheme,
24 * ":" followed by that port. This value does not have a trailing slash.
26 readonly attribute USVString origin;
29 * The last event ID string of the event source, for server-sent DOM events; this
30 * value is the empty string for cross-origin messaging.
32 readonly attribute DOMString lastEventId;
35 * The window or port which originated this event.
37 readonly attribute MessageEventSource? source;
39 [Pure, Cached, Frozen]
40 readonly attribute sequence<MessagePort> ports;
43 * Initializes this event with the given data, in a manner analogous to
44 * the similarly-named method on the Event interface, also setting the
45 * data, origin, source, and lastEventId attributes of this appropriately.
47 undefined initMessageEvent(DOMString type,
48 optional boolean bubbles = false,
49 optional boolean cancelable = false,
50 optional any data = null,
51 optional DOMString origin = "",
52 optional DOMString lastEventId = "",
53 optional MessageEventSource? source = null,
54 optional sequence<MessagePort> ports = []);
57 dictionary MessageEventInit : EventInit {
59 DOMString origin = "";
60 DOMString lastEventId = "";
61 MessageEventSource? source = null;
62 sequence<MessagePort> ports = [];
65 typedef (WindowProxy or MessagePort or ServiceWorker) MessageEventSource;