Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/PromiseBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM Promise.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "PromiseBinding.h"
4
#include "WrapperFactory.h"
5
#include "mozilla/OwningNonNull.h"
6
#include "mozilla/dom/BindingUtils.h"
7
#include "mozilla/dom/DOMJSClass.h"
8
#include "mozilla/dom/NonRefcountedDOMObject.h"
9
#include "mozilla/dom/PromiseNativeHandler.h"
10
#include "mozilla/dom/XrayExpandoClass.h"
11
12
namespace mozilla {
13
namespace dom {
14
15
namespace binding_detail {}; // Just to make sure it's known as a namespace
16
using namespace mozilla::dom::binding_detail;
17
18
19
void
20
PromiseJobCallback::Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv)
21
0
{
22
0
  JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
23
0
24
0
  JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
25
0
  if (!JS::Call(cx, aThisVal, callable,
26
0
                JS::HandleValueArray::empty(), &rval)) {
27
0
    aRv.NoteJSContextException(cx);
28
0
    return;
29
0
  }
30
0
}
31
32
33
34
void
35
AnyCallback::Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, JS::Handle<JS::Value> value, JS::MutableHandle<JS::Value> aRetVal, ErrorResult& aRv)
36
0
{
37
0
  JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
38
0
  JS::AutoValueVector argv(cx);
39
0
  if (!argv.resize(1)) {
40
0
    aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
41
0
    return;
42
0
  }
43
0
  unsigned argc = 1;
44
0
45
0
  do {
46
0
    JS::ExposeValueToActiveJS(value);
47
0
    argv[0].set(value);
48
0
    if (!MaybeWrapValue(cx, argv[0])) {
49
0
      aRv.Throw(NS_ERROR_UNEXPECTED);
50
0
      return;
51
0
    }
52
0
    break;
53
0
  } while (false);
54
0
55
0
  JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
56
0
  if (!JS::Call(cx, aThisVal, callable,
57
0
                JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
58
0
    aRv.NoteJSContextException(cx);
59
0
    return;
60
0
  }
61
0
  JS::Rooted<JS::Value> rvalDecl(cx);
62
0
#ifdef __clang__
63
0
#pragma clang diagnostic push
64
0
#pragma clang diagnostic ignored "-Wunreachable-code"
65
0
#pragma clang diagnostic ignored "-Wunreachable-code-return"
66
0
#endif // __clang__
67
0
  if ((false) && !CallerSubsumes(rval)) {
68
0
    ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "return value of AnyCallback");
69
0
    aRv.Throw(NS_ERROR_UNEXPECTED);
70
0
    return;
71
0
  }
72
0
#ifdef __clang__
73
0
#pragma clang diagnostic pop
74
0
#endif // __clang__
75
0
  rvalDecl = rval;
76
0
  aRetVal.set(rvalDecl);
77
0
}
78
79
80
81
namespace binding_detail {
82
} // namespace binding_detail
83
84
85
namespace binding_detail {
86
} // namespace binding_detail
87
88
89
namespace PromiseNativeHandler_Binding {
90
91
static void
92
_finalize(js::FreeOp* fop, JSObject* obj)
93
0
{
94
0
  mozilla::dom::PromiseNativeHandler* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PromiseNativeHandler>(obj);
95
0
  if (self) {
96
0
    AddForDeferredFinalization<mozilla::dom::PromiseNativeHandler>(self);
97
0
  }
98
0
}
99
100
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
101
  {
102
    "PromiseNativeHandlerPrototype",
103
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
104
    JS_NULL_CLASS_OPS,
105
    JS_NULL_CLASS_SPEC,
106
    JS_NULL_CLASS_EXT,
107
    JS_NULL_OBJECT_OPS
108
  },
109
  eInterfacePrototype,
110
  false,
111
  prototypes::id::PromiseNativeHandler,
112
  PrototypeTraits<prototypes::id::PromiseNativeHandler>::Depth,
113
  sNativePropertyHooks,
114
  "[object PromiseNativeHandlerPrototype]",
115
  JS::GetRealmObjectPrototype
116
};
117
118
static const js::ClassOps sClassOps = {
119
  nullptr, /* addProperty */
120
  nullptr,               /* delProperty */
121
  nullptr,               /* enumerate */
122
  nullptr, /* newEnumerate */
123
  nullptr, /* resolve */
124
  nullptr, /* mayResolve */
125
  _finalize, /* finalize */
126
  nullptr, /* call */
127
  nullptr,               /* hasInstance */
128
  nullptr,               /* construct */
129
  nullptr, /* trace */
130
};
131
132
static const js::ClassExtension sClassExtension = {
133
  nullptr, /* weakmapKeyDelegateOp */
134
  nullptr /* objectMovedOp */
135
};
136
137
static const DOMJSClass sClass = {
138
  { "PromiseNativeHandler",
139
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
140
    &sClassOps,
141
    JS_NULL_CLASS_SPEC,
142
    &sClassExtension,
143
    JS_NULL_OBJECT_OPS
144
  },
145
  { prototypes::id::PromiseNativeHandler, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
146
  IsBaseOf<nsISupports, mozilla::dom::PromiseNativeHandler >::value,
147
  sNativePropertyHooks,
148
  FindAssociatedGlobalForNative<mozilla::dom::PromiseNativeHandler>::Get,
149
  GetProtoObjectHandle,
150
  GetCCParticipant<mozilla::dom::PromiseNativeHandler>::Get()
151
};
152
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
153
              "Must have the right minimal number of reserved slots.");
154
static_assert(1 >= 1,
155
              "Must have enough reserved slots.");
156
157
const JSClass*
158
GetJSClass()
159
0
{
160
0
  return sClass.ToJSClass();
161
0
}
162
163
bool
164
Wrap(JSContext* aCx, mozilla::dom::PromiseNativeHandler* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
165
0
{
166
0
  MOZ_ASSERT(static_cast<mozilla::dom::PromiseNativeHandler*>(aObject) ==
167
0
             reinterpret_cast<mozilla::dom::PromiseNativeHandler*>(aObject),
168
0
             "Multiple inheritance for mozilla::dom::PromiseNativeHandler is broken.");
169
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
170
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
171
0
172
0
  JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
173
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
174
0
  if (!canonicalProto) {
175
0
    return false;
176
0
  }
177
0
  JS::Rooted<JSObject*> proto(aCx);
178
0
  if (aGivenProto) {
179
0
    proto = aGivenProto;
180
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
181
0
    // coming in, we changed compartments to that of "parent" so may need
182
0
    // to wrap the proto here.
183
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
184
0
      if (!JS_WrapObject(aCx, &proto)) {
185
0
        return false;
186
0
      }
187
0
    }
188
0
  } else {
189
0
    proto = canonicalProto;
190
0
  }
191
0
192
0
  BindingJSObjectCreator<mozilla::dom::PromiseNativeHandler> creator(aCx);
193
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
194
0
  if (!aReflector) {
195
0
    return false;
196
0
  }
197
0
198
0
199
0
200
0
  creator.InitializationSucceeded();
201
0
  return true;
202
0
}
203
204
const NativePropertyHooks sNativePropertyHooks[] = { {
205
  nullptr,
206
  nullptr,
207
  nullptr,
208
  { nullptr, nullptr },
209
  prototypes::id::PromiseNativeHandler,
210
  constructors::id::_ID_Count,
211
  nullptr,
212
  &DefaultXrayExpandoObjectClass
213
} };
214
215
void
216
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
217
0
{
218
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
219
0
  if (!parentProto) {
220
0
    return;
221
0
  }
222
0
223
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::PromiseNativeHandler);
224
0
  JS::Heap<JSObject*>* interfaceCache = nullptr;
225
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
226
0
                              &sPrototypeClass.mBase, protoCache,
227
0
                              nullptr,
228
0
                              nullptr, nullptr, 0, nullptr,
229
0
                              interfaceCache,
230
0
                              nullptr,
231
0
                              nullptr,
232
0
                              nullptr, aDefineOnGlobal,
233
0
                              nullptr,
234
0
                              false);
235
0
}
236
237
} // namespace PromiseNativeHandler_Binding
238
239
240
241
} // namespace dom
242
} // namespace mozilla