Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/HTMLScriptElement.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_HTMLScriptElement_h
8
#define mozilla_dom_HTMLScriptElement_h
9
10
#include "nsGenericHTMLElement.h"
11
#include "mozilla/Attributes.h"
12
#include "mozilla/dom/ScriptElement.h"
13
14
namespace mozilla {
15
namespace dom {
16
17
class HTMLScriptElement final : public nsGenericHTMLElement,
18
                                public ScriptElement
19
{
20
public:
21
  using Element::GetText;
22
23
  HTMLScriptElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
24
                    FromParser aFromParser);
25
26
  // nsISupports
27
  NS_DECL_ISUPPORTS_INHERITED
28
29
  void GetInnerHTML(nsAString& aInnerHTML, OOMReporter& aError) override;
30
  virtual void SetInnerHTML(const nsAString& aInnerHTML,
31
                            nsIPrincipal* aSubjectPrincipal,
32
                            mozilla::ErrorResult& aError) override;
33
34
  // nsIScriptElement
35
  virtual bool GetScriptType(nsAString& type) override;
36
  virtual void GetScriptText(nsAString& text) override;
37
  virtual void GetScriptCharset(nsAString& charset) override;
38
  virtual void FreezeExecutionAttrs(nsIDocument* aOwnerDoc) override;
39
  virtual CORSMode GetCORSMode() const override;
40
41
  // nsIContent
42
  virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
43
                              nsIContent* aBindingParent) override;
44
  virtual bool ParseAttribute(int32_t aNamespaceID,
45
                              nsAtom* aAttribute,
46
                              const nsAString& aValue,
47
                              nsIPrincipal* aMaybeScriptedPrincipal,
48
                              nsAttrValue& aResult) override;
49
50
  virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
51
52
  // Element
53
  virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
54
                                const nsAttrValue* aValue,
55
                                const nsAttrValue* aOldValue,
56
                                nsIPrincipal* aMaybeScriptedPrincipal,
57
                                bool aNotify) override;
58
59
  // WebIDL
60
  void GetText(nsAString& aValue, ErrorResult& aRv);
61
62
  void SetText(const nsAString& aValue, ErrorResult& aRv);
63
64
  void GetCharset(nsAString& aCharset)
65
0
  {
66
0
    GetHTMLAttr(nsGkAtoms::charset, aCharset);
67
0
  }
68
  void SetCharset(const nsAString& aCharset, ErrorResult& aRv)
69
0
  {
70
0
    SetHTMLAttr(nsGkAtoms::charset, aCharset, aRv);
71
0
  }
72
73
  bool Defer()
74
0
  {
75
0
    return GetBoolAttr(nsGkAtoms::defer);
76
0
  }
77
  void SetDefer(bool aDefer, ErrorResult& aRv)
78
0
  {
79
0
    SetHTMLBoolAttr(nsGkAtoms::defer, aDefer, aRv);
80
0
  }
81
82
  void GetSrc(nsAString& aSrc)
83
0
  {
84
0
    GetURIAttr(nsGkAtoms::src, nullptr, aSrc);
85
0
  }
86
  void SetSrc(const nsAString& aSrc, nsIPrincipal* aTriggeringPrincipal, ErrorResult& aRv)
87
0
  {
88
0
    SetHTMLAttr(nsGkAtoms::src, aSrc, aTriggeringPrincipal, aRv);
89
0
  }
90
91
  void GetType(nsAString& aType)
92
0
  {
93
0
    GetHTMLAttr(nsGkAtoms::type, aType);
94
0
  }
95
  void SetType(const nsAString& aType, ErrorResult& aRv)
96
0
  {
97
0
    SetHTMLAttr(nsGkAtoms::type, aType, aRv);
98
0
  }
99
100
  void GetHtmlFor(nsAString& aHtmlFor)
101
0
  {
102
0
    GetHTMLAttr(nsGkAtoms::_for, aHtmlFor);
103
0
  }
104
  void SetHtmlFor(const nsAString& aHtmlFor, ErrorResult& aRv)
105
0
  {
106
0
    SetHTMLAttr(nsGkAtoms::_for, aHtmlFor, aRv);
107
0
  }
108
109
  void GetEvent(nsAString& aEvent)
110
0
  {
111
0
    GetHTMLAttr(nsGkAtoms::event, aEvent);
112
0
  }
113
  void SetEvent(const nsAString& aEvent, ErrorResult& aRv)
114
0
  {
115
0
    SetHTMLAttr(nsGkAtoms::event, aEvent, aRv);
116
0
  }
117
118
  bool Async()
119
0
  {
120
0
    return mForceAsync || GetBoolAttr(nsGkAtoms::async);
121
0
  }
122
123
  void SetAsync(bool aValue, ErrorResult& aRv)
124
0
  {
125
0
    mForceAsync = false;
126
0
    SetHTMLBoolAttr(nsGkAtoms::async, aValue, aRv);
127
0
  }
128
129
  bool NoModule()
130
0
  {
131
0
    return GetBoolAttr(nsGkAtoms::nomodule);
132
0
  }
133
134
  void SetNoModule(bool aValue, ErrorResult& aRv)
135
0
  {
136
0
    SetHTMLBoolAttr(nsGkAtoms::nomodule, aValue, aRv);
137
0
  }
138
139
  void GetCrossOrigin(nsAString& aResult)
140
0
  {
141
0
    // Null for both missing and invalid defaults is ok, since we
142
0
    // always parse to an enum value, so we don't need an invalid
143
0
    // default, and we _want_ the missing default to be null.
144
0
    GetEnumAttr(nsGkAtoms::crossorigin, nullptr, aResult);
145
0
  }
146
  void SetCrossOrigin(const nsAString& aCrossOrigin, ErrorResult& aError)
147
0
  {
148
0
    SetOrRemoveNullableStringAttr(nsGkAtoms::crossorigin, aCrossOrigin, aError);
149
0
  }
150
  void GetIntegrity(nsAString& aIntegrity)
151
0
  {
152
0
    GetHTMLAttr(nsGkAtoms::integrity, aIntegrity);
153
0
  }
154
  void SetIntegrity(const nsAString& aIntegrity, ErrorResult& aRv)
155
0
  {
156
0
    SetHTMLAttr(nsGkAtoms::integrity, aIntegrity, aRv);
157
0
  }
158
159
protected:
160
  virtual ~HTMLScriptElement();
161
162
  virtual bool GetAsyncState() override
163
0
  {
164
0
    return Async();
165
0
  }
166
167
  virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
168
169
  // ScriptElement
170
  virtual bool HasScriptContent() override;
171
};
172
173
} // namespace dom
174
} // namespace mozilla
175
176
#endif // mozilla_dom_HTMLScriptElement_h