/work/obj-fuzz/dist/include/mozilla/dom/MessageEvent.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef mozilla_dom_MessageEvent_h_ |
8 | | #define mozilla_dom_MessageEvent_h_ |
9 | | |
10 | | #include "mozilla/dom/Event.h" |
11 | | #include "mozilla/dom/BindingUtils.h" |
12 | | #include "nsCycleCollectionParticipant.h" |
13 | | |
14 | | namespace mozilla { |
15 | | namespace dom { |
16 | | |
17 | | struct MessageEventInit; |
18 | | class MessagePort; |
19 | | class OwningWindowProxyOrMessagePortOrServiceWorker; |
20 | | class ServiceWorker; |
21 | | class WindowProxyOrMessagePortOrServiceWorker; |
22 | | |
23 | | /** |
24 | | * Implements the MessageEvent event, used for cross-document messaging and |
25 | | * server-sent events. |
26 | | * |
27 | | * See http://www.whatwg.org/specs/web-apps/current-work/#messageevent for |
28 | | * further details. |
29 | | */ |
30 | | class MessageEvent final : public Event |
31 | | { |
32 | | public: |
33 | | MessageEvent(EventTarget* aOwner, |
34 | | nsPresContext* aPresContext, |
35 | | WidgetEvent* aEvent); |
36 | | |
37 | | NS_DECL_ISUPPORTS_INHERITED |
38 | | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(MessageEvent, Event) |
39 | | |
40 | | virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; |
41 | | |
42 | | void GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData, |
43 | | ErrorResult& aRv); |
44 | | void GetOrigin(nsAString&) const; |
45 | | void GetLastEventId(nsAString&) const; |
46 | | void GetSource(Nullable<OwningWindowProxyOrMessagePortOrServiceWorker>& aValue) const; |
47 | | |
48 | | void GetPorts(nsTArray<RefPtr<MessagePort>>& aPorts); |
49 | | |
50 | | static already_AddRefed<MessageEvent> |
51 | | Constructor(const GlobalObject& aGlobal, |
52 | | const nsAString& aType, |
53 | | const MessageEventInit& aEventInit, |
54 | | ErrorResult& aRv); |
55 | | |
56 | | static already_AddRefed<MessageEvent> |
57 | | Constructor(EventTarget* aEventTarget, |
58 | | const nsAString& aType, |
59 | | const MessageEventInit& aEventInit); |
60 | | |
61 | | void InitMessageEvent(JSContext* aCx, const nsAString& aType, |
62 | | bool aCanBubble, bool aCancelable, |
63 | | JS::Handle<JS::Value> aData, |
64 | | const nsAString& aOrigin, const nsAString& aLastEventId, |
65 | | const Nullable<WindowProxyOrMessagePortOrServiceWorker>& aSource, |
66 | | const Sequence<OwningNonNull<MessagePort>>& aPorts) |
67 | 0 | { |
68 | 0 | InitMessageEvent(aCx, aType, |
69 | 0 | aCanBubble ? CanBubble::eYes : CanBubble::eNo, |
70 | 0 | aCancelable ? Cancelable::eYes : Cancelable::eNo, |
71 | 0 | aData, |
72 | 0 | aOrigin, aLastEventId, |
73 | 0 | aSource, aPorts); |
74 | 0 | } |
75 | | |
76 | | void InitMessageEvent(JSContext* aCx, const nsAString& aType, |
77 | | mozilla::CanBubble, mozilla::Cancelable, |
78 | | JS::Handle<JS::Value> aData, |
79 | | const nsAString& aOrigin, const nsAString& aLastEventId, |
80 | | const Nullable<WindowProxyOrMessagePortOrServiceWorker>& aSource, |
81 | | const Sequence<OwningNonNull<MessagePort>>& aPorts); |
82 | | |
83 | | protected: |
84 | | ~MessageEvent(); |
85 | | |
86 | | private: |
87 | | JS::Heap<JS::Value> mData; |
88 | | nsString mOrigin; |
89 | | nsString mLastEventId; |
90 | | RefPtr<nsPIDOMWindowOuter> mWindowSource; |
91 | | RefPtr<MessagePort> mPortSource; |
92 | | RefPtr<ServiceWorker> mServiceWorkerSource; |
93 | | |
94 | | nsTArray<RefPtr<MessagePort>> mPorts; |
95 | | }; |
96 | | |
97 | | } // namespace dom |
98 | | } // namespace mozilla |
99 | | |
100 | | #endif // mozilla_dom_MessageEvent_h_ |