@@ -133,9 +133,10 @@ already_AddRefed<Promise> GamepadServiceTest::AddGamepad(
133
133
return p.forget ();
134
134
}
135
135
136
- void GamepadServiceTest::RemoveGamepad (uint32_t aHandleSlot) {
136
+ already_AddRefed<Promise> GamepadServiceTest::RemoveGamepad (
137
+ uint32_t aHandleSlot, ErrorResult& aRv) {
137
138
if (mShuttingDown ) {
138
- return ;
139
+ return nullptr ;
139
140
}
140
141
141
142
GamepadHandle gamepadHandle = GetHandleInSlot (aHandleSlot);
@@ -145,13 +146,24 @@ void GamepadServiceTest::RemoveGamepad(uint32_t aHandleSlot) {
145
146
GamepadChangeEvent e (gamepadHandle, body);
146
147
147
148
uint32_t id = ++mEventNumber ;
149
+
150
+ RefPtr<Promise> p = Promise::Create (mWindow ->AsGlobal (), aRv);
151
+ if (aRv.Failed ()) {
152
+ return nullptr ;
153
+ }
154
+
155
+ MOZ_ASSERT (!mPromiseList .Contains (id));
156
+ mPromiseList .InsertOrUpdate (id, RefPtr{p});
157
+
148
158
mChild ->SendGamepadTestEvent (id, e);
159
+ return p.forget ();
149
160
}
150
161
151
- void GamepadServiceTest::NewButtonEvent (uint32_t aHandleSlot, uint32_t aButton,
152
- bool aPressed, bool aTouched) {
162
+ already_AddRefed<Promise> GamepadServiceTest::NewButtonEvent (
163
+ uint32_t aHandleSlot, uint32_t aButton, bool aPressed, bool aTouched,
164
+ ErrorResult& aRv) {
153
165
if (mShuttingDown ) {
154
- return ;
166
+ return nullptr ;
155
167
}
156
168
157
169
GamepadHandle gamepadHandle = GetHandleInSlot (aHandleSlot);
@@ -161,14 +173,22 @@ void GamepadServiceTest::NewButtonEvent(uint32_t aHandleSlot, uint32_t aButton,
161
173
GamepadChangeEvent e (gamepadHandle, body);
162
174
163
175
uint32_t id = ++mEventNumber ;
176
+ RefPtr<Promise> p = Promise::Create (mWindow ->AsGlobal (), aRv);
177
+ if (aRv.Failed ()) {
178
+ return nullptr ;
179
+ }
180
+
181
+ MOZ_ASSERT (!mPromiseList .Contains (id));
182
+ mPromiseList .InsertOrUpdate (id, RefPtr{p});
164
183
mChild ->SendGamepadTestEvent (id, e);
184
+ return p.forget ();
165
185
}
166
186
167
- void GamepadServiceTest::NewButtonValueEvent (uint32_t aHandleSlot,
168
- uint32_t aButton, bool aPressed,
169
- bool aTouched, double aValue ) {
187
+ already_AddRefed<Promise> GamepadServiceTest::NewButtonValueEvent (
188
+ uint32_t aHandleSlot, uint32_t aButton, bool aPressed, bool aTouched ,
189
+ double aValue, ErrorResult& aRv ) {
170
190
if (mShuttingDown ) {
171
- return ;
191
+ return nullptr ;
172
192
}
173
193
174
194
GamepadHandle gamepadHandle = GetHandleInSlot (aHandleSlot);
@@ -178,13 +198,21 @@ void GamepadServiceTest::NewButtonValueEvent(uint32_t aHandleSlot,
178
198
GamepadChangeEvent e (gamepadHandle, body);
179
199
180
200
uint32_t id = ++mEventNumber ;
201
+ RefPtr<Promise> p = Promise::Create (mWindow ->AsGlobal (), aRv);
202
+ if (aRv.Failed ()) {
203
+ return nullptr ;
204
+ }
205
+
206
+ MOZ_ASSERT (!mPromiseList .Contains (id));
207
+ mPromiseList .InsertOrUpdate (id, RefPtr{p});
181
208
mChild ->SendGamepadTestEvent (id, e);
209
+ return p.forget ();
182
210
}
183
211
184
- void GamepadServiceTest::NewAxisMoveEvent (uint32_t aHandleSlot, uint32_t aAxis,
185
- double aValue) {
212
+ already_AddRefed<Promise> GamepadServiceTest::NewAxisMoveEvent (
213
+ uint32_t aHandleSlot, uint32_t aAxis, double aValue, ErrorResult& aRv ) {
186
214
if (mShuttingDown ) {
187
- return ;
215
+ return nullptr ;
188
216
}
189
217
190
218
GamepadHandle gamepadHandle = GetHandleInSlot (aHandleSlot);
@@ -194,18 +222,26 @@ void GamepadServiceTest::NewAxisMoveEvent(uint32_t aHandleSlot, uint32_t aAxis,
194
222
GamepadChangeEvent e (gamepadHandle, body);
195
223
196
224
uint32_t id = ++mEventNumber ;
225
+ RefPtr<Promise> p = Promise::Create (mWindow ->AsGlobal (), aRv);
226
+ if (aRv.Failed ()) {
227
+ return nullptr ;
228
+ }
229
+
230
+ MOZ_ASSERT (!mPromiseList .Contains (id));
231
+ mPromiseList .InsertOrUpdate (id, RefPtr{p});
197
232
mChild ->SendGamepadTestEvent (id, e);
233
+ return p.forget ();
198
234
}
199
235
200
- void GamepadServiceTest::NewPoseMove (
236
+ already_AddRefed<Promise> GamepadServiceTest::NewPoseMove (
201
237
uint32_t aHandleSlot, const Nullable<Float32Array>& aOrient,
202
238
const Nullable<Float32Array>& aPos,
203
239
const Nullable<Float32Array>& aAngVelocity,
204
240
const Nullable<Float32Array>& aAngAcceleration,
205
241
const Nullable<Float32Array>& aLinVelocity,
206
- const Nullable<Float32Array>& aLinAcceleration) {
242
+ const Nullable<Float32Array>& aLinAcceleration, ErrorResult& aRv ) {
207
243
if (mShuttingDown ) {
208
- return ;
244
+ return nullptr ;
209
245
}
210
246
211
247
GamepadHandle gamepadHandle = GetHandleInSlot (aHandleSlot);
@@ -272,15 +308,23 @@ void GamepadServiceTest::NewPoseMove(
272
308
GamepadChangeEvent e (gamepadHandle, body);
273
309
274
310
uint32_t id = ++mEventNumber ;
311
+ RefPtr<Promise> p = Promise::Create (mWindow ->AsGlobal (), aRv);
312
+ if (aRv.Failed ()) {
313
+ return nullptr ;
314
+ }
315
+
316
+ MOZ_ASSERT (!mPromiseList .Contains (id));
317
+ mPromiseList .InsertOrUpdate (id, RefPtr{p});
275
318
mChild ->SendGamepadTestEvent (id, e);
319
+ return p.forget ();
276
320
}
277
321
278
- void GamepadServiceTest::NewTouch (uint32_t aHandleSlot,
279
- uint32_t aTouchArrayIndex, uint32_t aTouchId,
280
- uint8_t aSurfaceId, const Float32Array& aPos,
281
- const Nullable<Float32Array>& aSurfDim) {
322
+ already_AddRefed<Promise> GamepadServiceTest::NewTouch (
323
+ uint32_t aHandleSlot, uint32_t aTouchArrayIndex, uint32_t aTouchId,
324
+ uint8_t aSurfaceId, const Float32Array& aPos,
325
+ const Nullable<Float32Array>& aSurfDim, ErrorResult& aRv ) {
282
326
if (mShuttingDown ) {
283
- return ;
327
+ return nullptr ;
284
328
}
285
329
286
330
GamepadHandle gamepadHandle = GetHandleInSlot (aHandleSlot);
@@ -308,7 +352,15 @@ void GamepadServiceTest::NewTouch(uint32_t aHandleSlot,
308
352
GamepadChangeEvent e (gamepadHandle, body);
309
353
310
354
uint32_t id = ++mEventNumber ;
355
+ RefPtr<Promise> p = Promise::Create (mWindow ->AsGlobal (), aRv);
356
+ if (aRv.Failed ()) {
357
+ return nullptr ;
358
+ }
359
+
360
+ MOZ_ASSERT (!mPromiseList .Contains (id));
361
+ mPromiseList .InsertOrUpdate (id, RefPtr{p});
311
362
mChild ->SendGamepadTestEvent (id, e);
363
+ return p.forget ();
312
364
}
313
365
314
366
JSObject* GamepadServiceTest::WrapObject (JSContext* aCx,
0 commit comments