Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/NotificationEvent.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_workers_notificationevent_h__
8
#define mozilla_dom_workers_notificationevent_h__
9
10
#include "mozilla/dom/Event.h"
11
#include "mozilla/dom/NotificationEventBinding.h"
12
#include "mozilla/dom/ServiceWorkerEvents.h"
13
#include "mozilla/dom/WorkerCommon.h"
14
15
namespace mozilla {
16
namespace dom {
17
18
class ServiceWorker;
19
class ServiceWorkerClient;
20
21
class NotificationEvent final : public ExtendableEvent
22
{
23
protected:
24
  explicit NotificationEvent(EventTarget* aOwner);
25
  ~NotificationEvent()
26
  {}
27
28
public:
29
  NS_DECL_ISUPPORTS_INHERITED
30
  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(NotificationEvent, ExtendableEvent)
31
32
  virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
33
  {
34
    return NotificationEvent_Binding::Wrap(aCx, this, aGivenProto);
35
  }
36
37
  static already_AddRefed<NotificationEvent>
38
  Constructor(mozilla::dom::EventTarget* aOwner,
39
              const nsAString& aType,
40
              const NotificationEventInit& aOptions,
41
              ErrorResult& aRv)
42
0
  {
43
0
    RefPtr<NotificationEvent> e = new NotificationEvent(aOwner);
44
0
    bool trusted = e->Init(aOwner);
45
0
    e->InitEvent(aType, aOptions.mBubbles, aOptions.mCancelable);
46
0
    e->SetTrusted(trusted);
47
0
    e->SetComposed(aOptions.mComposed);
48
0
    e->mNotification = aOptions.mNotification;
49
0
    e->SetWantsPopupControlCheck(e->IsTrusted());
50
0
    return e.forget();
51
0
  }
52
53
  static already_AddRefed<NotificationEvent>
54
  Constructor(const GlobalObject& aGlobal,
55
              const nsAString& aType,
56
              const NotificationEventInit& aOptions,
57
              ErrorResult& aRv)
58
0
  {
59
0
    nsCOMPtr<EventTarget> owner = do_QueryInterface(aGlobal.GetAsSupports());
60
0
    return Constructor(owner, aType, aOptions, aRv);
61
0
  }
62
63
  already_AddRefed<Notification>
64
  Notification_()
65
0
  {
66
0
    RefPtr<Notification> n = mNotification;
67
0
    return n.forget();
68
0
  }
69
70
private:
71
  RefPtr<Notification> mNotification;
72
};
73
74
} // dom namspace
75
} // mozilla namespace
76
77
#endif /* mozilla_dom_workers_notificationevent_h__ */