/work/obj-fuzz/dom/bindings/FuzzingFunctionsBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM FuzzingFunctions.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "FuzzingFunctionsBinding.h" |
4 | | #include "WrapperFactory.h" |
5 | | #include "mozilla/OwningNonNull.h" |
6 | | #include "mozilla/Preferences.h" |
7 | | #include "mozilla/dom/BindingUtils.h" |
8 | | #include "mozilla/dom/DOMJSClass.h" |
9 | | #include "mozilla/dom/FuzzingFunctions.h" |
10 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
11 | | #include "mozilla/dom/XrayExpandoClass.h" |
12 | | |
13 | | namespace mozilla { |
14 | | namespace dom { |
15 | | |
16 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
17 | | using namespace mozilla::dom::binding_detail; |
18 | | |
19 | | |
20 | | namespace FuzzingFunctions_Binding { |
21 | | |
22 | | static bool |
23 | | garbageCollect(JSContext* cx, unsigned argc, JS::Value* vp) |
24 | 0 | { |
25 | 0 | AUTO_PROFILER_LABEL_FAST("FuzzingFunctions.garbageCollect", DOM, cx); |
26 | 0 |
|
27 | 0 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
28 | 0 | JS::Rooted<JSObject*> obj(cx, &args.callee()); |
29 | 0 |
|
30 | 0 | GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj)); |
31 | 0 | if (global.Failed()) { |
32 | 0 | return false; |
33 | 0 | } |
34 | 0 | |
35 | 0 | mozilla::dom::FuzzingFunctions::GarbageCollect(global); |
36 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
37 | 0 | args.rval().setUndefined(); |
38 | 0 | return true; |
39 | 0 | } |
40 | | |
41 | | static bool |
42 | | cycleCollect(JSContext* cx, unsigned argc, JS::Value* vp) |
43 | 0 | { |
44 | 0 | AUTO_PROFILER_LABEL_FAST("FuzzingFunctions.cycleCollect", DOM, cx); |
45 | 0 |
|
46 | 0 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
47 | 0 | JS::Rooted<JSObject*> obj(cx, &args.callee()); |
48 | 0 |
|
49 | 0 | GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj)); |
50 | 0 | if (global.Failed()) { |
51 | 0 | return false; |
52 | 0 | } |
53 | 0 | |
54 | 0 | mozilla::dom::FuzzingFunctions::CycleCollect(global); |
55 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
56 | 0 | args.rval().setUndefined(); |
57 | 0 | return true; |
58 | 0 | } |
59 | | |
60 | | static bool |
61 | | enableAccessibility(JSContext* cx, unsigned argc, JS::Value* vp) |
62 | 0 | { |
63 | 0 | AUTO_PROFILER_LABEL_FAST("FuzzingFunctions.enableAccessibility", DOM, cx); |
64 | 0 |
|
65 | 0 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
66 | 0 | JS::Rooted<JSObject*> obj(cx, &args.callee()); |
67 | 0 |
|
68 | 0 | GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj)); |
69 | 0 | if (global.Failed()) { |
70 | 0 | return false; |
71 | 0 | } |
72 | 0 | |
73 | 0 | FastErrorResult rv; |
74 | 0 | mozilla::dom::FuzzingFunctions::EnableAccessibility(global, rv); |
75 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
76 | 0 | return false; |
77 | 0 | } |
78 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
79 | 0 | args.rval().setUndefined(); |
80 | 0 | return true; |
81 | 0 | } |
82 | | |
83 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
84 | | #if defined(__clang__) |
85 | | #pragma clang diagnostic push |
86 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
87 | | #endif |
88 | | static const JSFunctionSpec sStaticMethods_specs[] = { |
89 | | JS_FNSPEC("garbageCollect", garbageCollect, nullptr, 0, JSPROP_ENUMERATE, nullptr), |
90 | | JS_FNSPEC("cycleCollect", cycleCollect, nullptr, 0, JSPROP_ENUMERATE, nullptr), |
91 | | JS_FNSPEC("enableAccessibility", enableAccessibility, nullptr, 0, JSPROP_ENUMERATE, nullptr), |
92 | | JS_FS_END |
93 | | }; |
94 | | #if defined(__clang__) |
95 | | #pragma clang diagnostic pop |
96 | | #endif |
97 | | |
98 | | |
99 | | static const Prefable<const JSFunctionSpec> sStaticMethods[] = { |
100 | | { nullptr, &sStaticMethods_specs[0] }, |
101 | | { nullptr, nullptr } |
102 | | }; |
103 | | |
104 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
105 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
106 | | static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
107 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
108 | | |
109 | | |
110 | | static uint16_t sNativeProperties_sortedPropertyIndices[3]; |
111 | | static PropertyInfo sNativeProperties_propertyInfos[3]; |
112 | | |
113 | | static const NativePropertiesN<1> sNativeProperties = { |
114 | | true, 0 /* sStaticMethods */, |
115 | | false, 0, |
116 | | false, 0, |
117 | | false, 0, |
118 | | false, 0, |
119 | | false, 0, |
120 | | false, 0, |
121 | | -1, |
122 | | 3, |
123 | | sNativeProperties_sortedPropertyIndices, |
124 | | { |
125 | | { sStaticMethods, &sNativeProperties_propertyInfos[0] } |
126 | | } |
127 | | }; |
128 | | static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
129 | | "We have a property info count that is oversized"); |
130 | | |
131 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
132 | | { |
133 | | "Function", |
134 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
135 | | &sBoringInterfaceObjectClassClassOps, |
136 | | JS_NULL_CLASS_SPEC, |
137 | | JS_NULL_CLASS_EXT, |
138 | | &sInterfaceObjectClassObjectOps |
139 | | }, |
140 | | eInterface, |
141 | | false, |
142 | | prototypes::id::_ID_Count, |
143 | | 0, |
144 | | sNativePropertyHooks, |
145 | | "function FuzzingFunctions() {\n [native code]\n}", |
146 | | JS::GetRealmFunctionPrototype |
147 | | }; |
148 | | |
149 | | bool |
150 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
151 | 0 | { |
152 | 0 | static bool sPrefValue; |
153 | 0 | static bool sPrefCacheSetUp = false; |
154 | 0 | if (!sPrefCacheSetUp) { |
155 | 0 | sPrefCacheSetUp = true; |
156 | 0 | Preferences::AddBoolVarCache(&sPrefValue, "fuzzing.enabled"); |
157 | 0 | } |
158 | 0 |
|
159 | 0 | return sPrefValue; |
160 | 0 | } |
161 | | |
162 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
163 | | nullptr, |
164 | | nullptr, |
165 | | nullptr, |
166 | | { sNativeProperties.Upcast(), nullptr }, |
167 | | prototypes::id::_ID_Count, |
168 | | constructors::id::FuzzingFunctions, |
169 | | nullptr, |
170 | | &DefaultXrayExpandoObjectClass |
171 | | } }; |
172 | | |
173 | | void |
174 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
175 | 0 | { |
176 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
177 | 0 | if (!constructorProto) { |
178 | 0 | return; |
179 | 0 | } |
180 | 0 | |
181 | 0 | static bool sIdsInited = false; |
182 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
183 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
184 | 0 | return; |
185 | 0 | } |
186 | 0 | sIdsInited = true; |
187 | 0 | } |
188 | 0 |
|
189 | 0 | JS::Heap<JSObject*>* protoCache = nullptr; |
190 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::FuzzingFunctions); |
191 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, nullptr, |
192 | 0 | nullptr, protoCache, |
193 | 0 | nullptr, |
194 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
195 | 0 | interfaceCache, |
196 | 0 | sNativeProperties.Upcast(), |
197 | 0 | nullptr, |
198 | 0 | "FuzzingFunctions", aDefineOnGlobal, |
199 | 0 | nullptr, |
200 | 0 | false); |
201 | 0 | } |
202 | | |
203 | | JSObject* |
204 | | GetConstructorObject(JSContext* aCx) |
205 | 0 | { |
206 | 0 | return GetConstructorObjectHandle(aCx); |
207 | 0 | } |
208 | | |
209 | | } // namespace FuzzingFunctions_Binding |
210 | | |
211 | | |
212 | | |
213 | | } // namespace dom |
214 | | } // namespace mozilla |