@webex/plugin-meetings 3.12.0-webex-services-ready.4 → 3.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.sdd/manifest.json +1312 -0
- package/.sdd/templates/.source.json +30 -0
- package/.sdd/templates/component-repo/module-docs/module-spec-quality.md +111 -0
- package/.sdd/templates/component-repo/module-docs/module-spec.template.md +321 -0
- package/.sdd/templates/component-repo/reference-docs/adr/_adr-example.md +59 -0
- package/.sdd/templates/component-repo/reference-docs/patterns/_pattern-example.md +49 -0
- package/.sdd/templates/component-repo/reference-docs/rules/_rule-example.md +42 -0
- package/.sdd/templates/component-repo/standing-docs/AGENTS.template.md +120 -0
- package/.sdd/templates/component-repo/standing-docs/ARCHITECTURE.template.md +206 -0
- package/.sdd/templates/component-repo/standing-docs/CONTRACTS.template.md +90 -0
- package/.sdd/templates/component-repo/standing-docs/DATA_MODEL.template.md +68 -0
- package/.sdd/templates/component-repo/standing-docs/GETTING_STARTED.template.md +111 -0
- package/.sdd/templates/component-repo/standing-docs/GLOSSARY.template.md +57 -0
- package/.sdd/templates/component-repo/standing-docs/REVIEW_CHECKLIST.template.md +69 -0
- package/.sdd/templates/component-repo/standing-docs/RULES.template.md +96 -0
- package/.sdd/templates/component-repo/standing-docs/SECURITY.template.md +84 -0
- package/.sdd/templates/component-repo/standing-docs/SERVICE_STATE.template.md +82 -0
- package/.sdd/templates/component-repo/standing-docs/SPEC_INDEX.template.md +94 -0
- package/.sdd/templates/component-repo/standing-docs/TEST_INDEX.template.md +64 -0
- package/.sdd/templates/component-repo/template-map.json +112 -0
- package/AGENTS.md +130 -4
- package/ai-docs/ARCHITECTURE.md +208 -0
- package/ai-docs/CONTRACTS.md +267 -0
- package/ai-docs/DATA_MODEL.md +64 -0
- package/ai-docs/GETTING_STARTED.md +73 -0
- package/ai-docs/GLOSSARY.md +56 -0
- package/ai-docs/REVIEW_CHECKLIST.md +45 -0
- package/ai-docs/RULES.md +79 -0
- package/ai-docs/SECURITY.md +74 -0
- package/ai-docs/SERVICE_STATE.md +59 -0
- package/ai-docs/SPEC_INDEX.md +85 -0
- package/ai-docs/TEST_INDEX.md +45 -0
- package/ai-docs/adr/0001-migrate-existing-docs-into-sdd.md +61 -0
- package/ai-docs/patterns/defensive-error-propagation.md +55 -0
- package/ai-docs/patterns/event-scope-emission.md +46 -0
- package/ai-docs/patterns/source-to-test-path-mirroring.md +45 -0
- package/ai-docs/patterns/stateless-plugin-request-classes.md +53 -0
- package/ai-docs/patterns/typed-constants-and-enum-values.md +47 -0
- package/assets/README.md +28 -0
- package/assets/e2ee-0.0.1.js +2 -0
- package/assets/e2ee-0.0.1.wasm +0 -0
- package/dist/aiEnableRequest/index.js +1 -1
- package/dist/annotation/index.js +55 -19
- package/dist/annotation/index.js.map +1 -1
- package/dist/assets/e2ee-0.0.1.js +2 -0
- package/dist/assets/e2ee-0.0.1.wasm +0 -0
- package/dist/breakouts/breakout.js +1 -1
- package/dist/breakouts/index.js +39 -5
- package/dist/breakouts/index.js.map +1 -1
- package/dist/common/errors/webex-errors.js +7 -2
- package/dist/common/errors/webex-errors.js.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/constants.js +6 -5
- package/dist/constants.js.map +1 -1
- package/dist/hashTree/hashTreeParser.js +101 -48
- package/dist/hashTree/hashTreeParser.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interceptors/dataChannelAuthToken.js +41 -59
- package/dist/interceptors/dataChannelAuthToken.js.map +1 -1
- package/dist/interceptors/locusRetry.js +1 -1
- package/dist/interceptors/locusRetry.js.map +1 -1
- package/dist/interpretation/index.js +46 -12
- package/dist/interpretation/index.js.map +1 -1
- package/dist/interpretation/siLanguage.js +1 -1
- package/dist/locus-info/index.js +236 -80
- package/dist/locus-info/index.js.map +1 -1
- package/dist/locus-info/types.js +2 -1
- package/dist/locus-info/types.js.map +1 -1
- package/dist/media/MediaConnectionAwaiter.js +225 -175
- package/dist/media/MediaConnectionAwaiter.js.map +1 -1
- package/dist/meeting/index.js +355 -299
- package/dist/meeting/index.js.map +1 -1
- package/dist/meeting/util.js +8 -2
- package/dist/meeting/util.js.map +1 -1
- package/dist/meeting/voicea-meeting.js +2 -1
- package/dist/meeting/voicea-meeting.js.map +1 -1
- package/dist/meeting-info/meeting-info-v2.js +10 -3
- package/dist/meeting-info/meeting-info-v2.js.map +1 -1
- package/dist/meetings/index.js +72 -31
- package/dist/meetings/index.js.map +1 -1
- package/dist/multistream/remoteMediaManager.js +32 -4
- package/dist/multistream/remoteMediaManager.js.map +1 -1
- package/dist/multistream/sendSlotManager.js +11 -1
- package/dist/multistream/sendSlotManager.js.map +1 -1
- package/dist/types/annotation/index.d.ts +19 -0
- package/dist/types/common/errors/webex-errors.d.ts +6 -2
- package/dist/types/config.d.ts +1 -0
- package/dist/types/constants.d.ts +2 -1
- package/dist/types/hashTree/hashTreeParser.d.ts +12 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/locus-info/index.d.ts +45 -1
- package/dist/types/locus-info/types.d.ts +1 -0
- package/dist/types/media/MediaConnectionAwaiter.d.ts +61 -53
- package/dist/types/meeting/index.d.ts +49 -12
- package/dist/types/meeting/util.d.ts +3 -1
- package/dist/types/meeting-info/meeting-info-v2.d.ts +1 -0
- package/dist/types/meetings/index.d.ts +2 -1
- package/dist/types/multistream/remoteMediaManager.d.ts +18 -0
- package/dist/types/multistream/sendSlotManager.d.ts +5 -1
- package/dist/webinar/index.js +298 -255
- package/dist/webinar/index.js.map +1 -1
- package/package.json +25 -23
- package/src/aiEnableRequest/ai-docs/ai-enable-request-spec.md +223 -0
- package/src/annotation/ai-docs/annotation-spec.md +236 -0
- package/src/annotation/index.ts +61 -29
- package/src/breakouts/ai-docs/breakouts-spec.md +324 -0
- package/src/breakouts/index.ts +35 -2
- package/src/common/errors/webex-errors.ts +8 -2
- package/src/config.ts +5 -1
- package/src/constants.ts +2 -1
- package/src/controls-options-manager/ai-docs/controls-options-manager-spec.md +243 -0
- package/src/hashTree/ai-docs/hash-tree-spec.md +267 -0
- package/src/hashTree/hashTreeParser.ts +67 -3
- package/src/index.ts +1 -0
- package/src/interceptors/ai-docs/interceptors-spec.md +247 -0
- package/src/interceptors/dataChannelAuthToken.ts +48 -77
- package/src/interceptors/locusRetry.ts +1 -1
- package/src/interpretation/ai-docs/interpretation-spec.md +256 -0
- package/src/interpretation/index.ts +38 -1
- package/src/locus-info/ai-docs/locus-info-spec.md +293 -0
- package/src/locus-info/index.ts +156 -35
- package/src/locus-info/types.ts +1 -0
- package/src/media/MediaConnectionAwaiter.ts +223 -207
- package/src/media/ai-docs/media-spec.md +267 -0
- package/src/meeting/ai-docs/meeting-spec.md +404 -0
- package/src/meeting/index.ts +332 -296
- package/src/meeting/util.ts +7 -4
- package/src/meeting/voicea-meeting.ts +1 -1
- package/src/meeting-info/ai-docs/meeting-info-spec.md +261 -0
- package/src/meeting-info/meeting-info-v2.ts +7 -2
- package/src/meetings/ai-docs/meetings-spec.md +296 -0
- package/src/meetings/index.ts +59 -23
- package/src/member/ai-docs/member-spec.md +196 -0
- package/src/members/ai-docs/members-spec.md +256 -0
- package/src/metrics/ai-docs/metrics-spec.md +185 -0
- package/src/multistream/ai-docs/multistream-spec.md +295 -0
- package/src/multistream/remoteMediaManager.ts +23 -1
- package/src/multistream/sendSlotManager.ts +15 -1
- package/src/personal-meeting-room/ai-docs/personal-meeting-room-spec.md +234 -0
- package/src/reachability/ai-docs/reachability-spec.md +261 -0
- package/src/reactions/ai-docs/reactions-spec.md +198 -0
- package/src/reconnection-manager/ai-docs/reconnection-manager-spec.md +272 -0
- package/src/recording-controller/ai-docs/recording-controller-spec.md +223 -0
- package/src/roap/ai-docs/roap-spec.md +241 -0
- package/src/webinar/ai-docs/webinar-spec.md +243 -0
- package/src/webinar/index.ts +168 -188
- package/test/unit/spec/annotation/index.ts +214 -182
- package/test/unit/spec/breakouts/index.ts +145 -13
- package/test/unit/spec/hashTree/hashTreeParser.ts +212 -1
- package/test/unit/spec/interceptors/dataChannelAuthToken.ts +81 -99
- package/test/unit/spec/interceptors/locusRetry.ts +29 -1
- package/test/unit/spec/interpretation/index.ts +93 -0
- package/test/unit/spec/locus-info/index.js +397 -0
- package/test/unit/spec/media/MediaConnectionAwaiter.ts +426 -19
- package/test/unit/spec/media/properties.ts +3 -3
- package/test/unit/spec/meeting/index.js +1219 -723
- package/test/unit/spec/meeting/utils.js +52 -18
- package/test/unit/spec/meeting/voicea-meeting.ts +85 -1
- package/test/unit/spec/meeting-info/meetinginfov2.js +69 -1
- package/test/unit/spec/meetings/index.js +145 -43
- package/test/unit/spec/multistream/remoteMediaManager.ts +46 -0
- package/test/unit/spec/multistream/sendSlotManager.ts +30 -2
- package/test/unit/spec/webinar/index.ts +886 -718
|
@@ -3,7 +3,10 @@ import {assert} from '@webex/test-helper-chai';
|
|
|
3
3
|
import sinon from 'sinon';
|
|
4
4
|
import {ConnectionState, MediaConnectionEventNames} from '@webex/internal-media-core';
|
|
5
5
|
import testUtils from '../../../utils/testUtils';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
DTLS_CONNECTION_TIMEOUT,
|
|
8
|
+
ICE_CONNECTION_TIMEOUT,
|
|
9
|
+
} from '@webex/plugin-meetings/src/constants';
|
|
7
10
|
import MediaConnectionAwaiter from '../../../../src/media/MediaConnectionAwaiter';
|
|
8
11
|
import Metrics from '../../../../src/metrics';
|
|
9
12
|
import BEHAVIORAL_METRICS from '../../../../src/metrics/constants';
|
|
@@ -56,9 +59,12 @@ describe('MediaConnectionAwaiter', () => {
|
|
|
56
59
|
it('resolves immediately if connection state is connected', async () => {
|
|
57
60
|
mockMC.getConnectionState.returns(ConnectionState.Connected);
|
|
58
61
|
|
|
62
|
+
await mediaConnectionAwaiter.waitForMediaConnectionConnected();
|
|
59
63
|
await mediaConnectionAwaiter.waitForMediaConnectionConnected();
|
|
60
64
|
|
|
61
|
-
assert.
|
|
65
|
+
assert.calledThrice(mockMC.on);
|
|
66
|
+
assert.calledThrice(mockMC.off);
|
|
67
|
+
assert.equal(clock.countTimers(), 0);
|
|
62
68
|
});
|
|
63
69
|
|
|
64
70
|
it('rejects after timeout if ice state is not connected', async () => {
|
|
@@ -70,7 +76,7 @@ describe('MediaConnectionAwaiter', () => {
|
|
|
70
76
|
let promiseResolved = false;
|
|
71
77
|
let promiseRejected = false;
|
|
72
78
|
|
|
73
|
-
mediaConnectionAwaiter
|
|
79
|
+
const connectionPromise = mediaConnectionAwaiter
|
|
74
80
|
.waitForMediaConnectionConnected()
|
|
75
81
|
.then(() => {
|
|
76
82
|
promiseResolved = true;
|
|
@@ -96,9 +102,10 @@ describe('MediaConnectionAwaiter', () => {
|
|
|
96
102
|
mockMC.getIceGatheringState.returns('complete');
|
|
97
103
|
iceGatheringListener();
|
|
98
104
|
|
|
99
|
-
await clock.tickAsync(
|
|
105
|
+
await clock.tickAsync(ICE_CONNECTION_TIMEOUT);
|
|
100
106
|
await testUtils.flushPromises();
|
|
101
107
|
|
|
108
|
+
await connectionPromise;
|
|
102
109
|
assert.equal(promiseResolved, false);
|
|
103
110
|
assert.equal(promiseRejected, true);
|
|
104
111
|
|
|
@@ -106,6 +113,8 @@ describe('MediaConnectionAwaiter', () => {
|
|
|
106
113
|
|
|
107
114
|
assert.calledOnceWithExactly(sendMetricSpy, BEHAVIORAL_METRICS.MEDIA_STILL_NOT_CONNECTED, {
|
|
108
115
|
correlation_id: 'test-correlation-id',
|
|
116
|
+
iceConnected: false,
|
|
117
|
+
iceConnectedAtLeastOnce: false,
|
|
109
118
|
numTransports: 1,
|
|
110
119
|
dtlsState: 'connecting',
|
|
111
120
|
iceState: 'checking',
|
|
@@ -124,7 +133,7 @@ describe('MediaConnectionAwaiter', () => {
|
|
|
124
133
|
let promiseResolved = false;
|
|
125
134
|
let promiseRejected = false;
|
|
126
135
|
|
|
127
|
-
mediaConnectionAwaiter
|
|
136
|
+
const connectionPromise = mediaConnectionAwaiter
|
|
128
137
|
.waitForMediaConnectionConnected()
|
|
129
138
|
.then(() => {
|
|
130
139
|
promiseResolved = true;
|
|
@@ -152,6 +161,7 @@ describe('MediaConnectionAwaiter', () => {
|
|
|
152
161
|
|
|
153
162
|
await testUtils.flushPromises();
|
|
154
163
|
|
|
164
|
+
await connectionPromise;
|
|
155
165
|
assert.equal(promiseResolved, false);
|
|
156
166
|
assert.equal(promiseRejected, true);
|
|
157
167
|
|
|
@@ -165,7 +175,7 @@ describe('MediaConnectionAwaiter', () => {
|
|
|
165
175
|
let promiseResolved = false;
|
|
166
176
|
let promiseRejected = false;
|
|
167
177
|
|
|
168
|
-
mediaConnectionAwaiter
|
|
178
|
+
const connectionPromise = mediaConnectionAwaiter
|
|
169
179
|
.waitForMediaConnectionConnected()
|
|
170
180
|
.then(() => {
|
|
171
181
|
promiseResolved = true;
|
|
@@ -174,7 +184,7 @@ describe('MediaConnectionAwaiter', () => {
|
|
|
174
184
|
promiseRejected = true;
|
|
175
185
|
|
|
176
186
|
const {iceConnected} = error;
|
|
177
|
-
assert.equal(iceConnected,
|
|
187
|
+
assert.equal(iceConnected, true);
|
|
178
188
|
});
|
|
179
189
|
|
|
180
190
|
await testUtils.flushPromises();
|
|
@@ -186,18 +196,19 @@ describe('MediaConnectionAwaiter', () => {
|
|
|
186
196
|
assert.equal(mockMC.on.getCall(0).args[0], MediaConnectionEventNames.PEER_CONNECTION_STATE_CHANGED);
|
|
187
197
|
assert.equal(mockMC.on.getCall(1).args[0], MediaConnectionEventNames.ICE_CONNECTION_STATE_CHANGED);
|
|
188
198
|
assert.equal(mockMC.on.getCall(2).args[0], MediaConnectionEventNames.ICE_GATHERING_STATE_CHANGED);
|
|
189
|
-
const
|
|
199
|
+
const gatheringStateListener = mockMC.on.getCall(2).args[1];
|
|
190
200
|
const iceConnectionListener = mockMC.on.getCall(1).args[1];
|
|
191
201
|
|
|
192
202
|
mockMC.getIceGatheringState.returns('complete');
|
|
193
|
-
|
|
203
|
+
gatheringStateListener();
|
|
194
204
|
|
|
195
205
|
mockMC.getIceConnectionState.returns('connected');
|
|
196
206
|
iceConnectionListener();
|
|
197
207
|
|
|
198
|
-
await clock.tickAsync(
|
|
208
|
+
await clock.tickAsync(DTLS_CONNECTION_TIMEOUT);
|
|
199
209
|
await testUtils.flushPromises();
|
|
200
210
|
|
|
211
|
+
await connectionPromise;
|
|
201
212
|
assert.equal(promiseResolved, false);
|
|
202
213
|
assert.equal(promiseRejected, true);
|
|
203
214
|
|
|
@@ -226,13 +237,121 @@ describe('MediaConnectionAwaiter', () => {
|
|
|
226
237
|
mockMC.getIceConnectionState.returns('completed');
|
|
227
238
|
iceConnectionListener();
|
|
228
239
|
|
|
229
|
-
await clock.tickAsync(
|
|
240
|
+
await clock.tickAsync(DTLS_CONNECTION_TIMEOUT);
|
|
230
241
|
await testUtils.flushPromises();
|
|
231
242
|
|
|
232
243
|
assert.equal(promiseRejected, true);
|
|
233
244
|
assert.equal(rejectedIceConnected, true);
|
|
234
245
|
});
|
|
235
246
|
|
|
247
|
+
it('switches to the shorter DTLS timeout once ICE connects', async () => {
|
|
248
|
+
mockMC.getConnectionState.returns(ConnectionState.Connecting);
|
|
249
|
+
mockMC.getIceGatheringState.returns('complete');
|
|
250
|
+
|
|
251
|
+
const setTimeoutSpy = sinon.spy(clock, 'setTimeout');
|
|
252
|
+
const clearTimeoutSpy = sinon.spy(clock, 'clearTimeout');
|
|
253
|
+
|
|
254
|
+
let promiseResolved = false;
|
|
255
|
+
let promiseRejected = false;
|
|
256
|
+
|
|
257
|
+
mediaConnectionAwaiter
|
|
258
|
+
.waitForMediaConnectionConnected()
|
|
259
|
+
.then(() => {
|
|
260
|
+
promiseResolved = true;
|
|
261
|
+
})
|
|
262
|
+
.catch(() => {
|
|
263
|
+
promiseRejected = true;
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
await testUtils.flushPromises();
|
|
267
|
+
|
|
268
|
+
// the initial timer uses the longer ICE timeout
|
|
269
|
+
assert.calledOnceWithExactly(setTimeoutSpy, sinon.match.func, ICE_CONNECTION_TIMEOUT);
|
|
270
|
+
|
|
271
|
+
const iceConnectionListener = mockMC.on.getCall(1).args[1];
|
|
272
|
+
|
|
273
|
+
// ICE connects - the ICE timer should be replaced with the shorter DTLS timer
|
|
274
|
+
mockMC.getIceConnectionState.returns('connected');
|
|
275
|
+
iceConnectionListener();
|
|
276
|
+
|
|
277
|
+
assert.calledOnce(clearTimeoutSpy);
|
|
278
|
+
assert.calledTwice(setTimeoutSpy);
|
|
279
|
+
assert.calledWithExactly(setTimeoutSpy.secondCall, sinon.match.func, DTLS_CONNECTION_TIMEOUT);
|
|
280
|
+
|
|
281
|
+
// just before the DTLS timeout elapses nothing happens
|
|
282
|
+
await clock.tickAsync(DTLS_CONNECTION_TIMEOUT - 1);
|
|
283
|
+
await testUtils.flushPromises();
|
|
284
|
+
|
|
285
|
+
assert.equal(promiseResolved, false);
|
|
286
|
+
assert.equal(promiseRejected, false);
|
|
287
|
+
|
|
288
|
+
// once the DTLS timeout elapses the promise rejects
|
|
289
|
+
await clock.tickAsync(1);
|
|
290
|
+
await testUtils.flushPromises();
|
|
291
|
+
|
|
292
|
+
assert.equal(promiseResolved, false);
|
|
293
|
+
assert.equal(promiseRejected, true);
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it('rejects at the DTLS deadline even if ICE gathering has not completed', async () => {
|
|
297
|
+
mockMC.getConnectionState.returns(ConnectionState.Connecting);
|
|
298
|
+
mockMC.getIceGatheringState.returns('gathering');
|
|
299
|
+
|
|
300
|
+
const setTimeoutSpy = sinon.spy(clock, 'setTimeout');
|
|
301
|
+
const failure = mediaConnectionAwaiter.waitForMediaConnectionConnected().then(
|
|
302
|
+
() => assert.fail('Expected DTLS timeout rejection'),
|
|
303
|
+
(error) => error
|
|
304
|
+
);
|
|
305
|
+
const iceConnectionListener = mockMC.on.getCall(1).args[1];
|
|
306
|
+
|
|
307
|
+
mockMC.getIceConnectionState.returns('connected');
|
|
308
|
+
iceConnectionListener();
|
|
309
|
+
await clock.tickAsync(DTLS_CONNECTION_TIMEOUT);
|
|
310
|
+
|
|
311
|
+
assert.deepEqual(await failure, {iceConnected: true, iceConnectedAtLeastOnce: true});
|
|
312
|
+
assert.calledTwice(setTimeoutSpy);
|
|
313
|
+
assert.calledWithExactly(setTimeoutSpy.lastCall, sinon.match.func, DTLS_CONNECTION_TIMEOUT);
|
|
314
|
+
assert.equal(clock.countTimers(), 0);
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
it('resolves when DTLS completes within the shorter DTLS timeout after ICE connects', async () => {
|
|
318
|
+
mockMC.getConnectionState.returns(ConnectionState.Connecting);
|
|
319
|
+
mockMC.getIceGatheringState.returns('gathering');
|
|
320
|
+
|
|
321
|
+
let promiseResolved = false;
|
|
322
|
+
let promiseRejected = false;
|
|
323
|
+
|
|
324
|
+
mediaConnectionAwaiter
|
|
325
|
+
.waitForMediaConnectionConnected()
|
|
326
|
+
.then(() => {
|
|
327
|
+
promiseResolved = true;
|
|
328
|
+
})
|
|
329
|
+
.catch(() => {
|
|
330
|
+
promiseRejected = true;
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
await testUtils.flushPromises();
|
|
334
|
+
|
|
335
|
+
const connectionStateListener = mockMC.on.getCall(0).args[1];
|
|
336
|
+
const iceConnectionListener = mockMC.on.getCall(1).args[1];
|
|
337
|
+
|
|
338
|
+
// ICE connects - switches to the DTLS timeout
|
|
339
|
+
mockMC.getIceConnectionState.returns('connected');
|
|
340
|
+
iceConnectionListener();
|
|
341
|
+
|
|
342
|
+
// DTLS completes within the DTLS timeout
|
|
343
|
+
await clock.tickAsync(DTLS_CONNECTION_TIMEOUT - 1);
|
|
344
|
+
mockMC.getConnectionState.returns(ConnectionState.Connected);
|
|
345
|
+
connectionStateListener();
|
|
346
|
+
|
|
347
|
+
await testUtils.flushPromises();
|
|
348
|
+
|
|
349
|
+
assert.equal(promiseResolved, true);
|
|
350
|
+
assert.equal(promiseRejected, false);
|
|
351
|
+
|
|
352
|
+
assert.calledThrice(mockMC.off);
|
|
353
|
+
});
|
|
354
|
+
|
|
236
355
|
['connected', 'completed'].forEach((iceState) => {
|
|
237
356
|
it(`initializes iceConnected=true from current ICE state "${iceState}" when starting the await`, async () => {
|
|
238
357
|
mockMC.getConnectionState.returns(ConnectionState.Connecting);
|
|
@@ -251,7 +370,7 @@ describe('MediaConnectionAwaiter', () => {
|
|
|
251
370
|
});
|
|
252
371
|
|
|
253
372
|
// no ICE connection state events fired - the flag should be set from the initial state
|
|
254
|
-
await clock.tickAsync(
|
|
373
|
+
await clock.tickAsync(DTLS_CONNECTION_TIMEOUT);
|
|
255
374
|
await testUtils.flushPromises();
|
|
256
375
|
|
|
257
376
|
assert.equal(promiseRejected, true);
|
|
@@ -287,7 +406,7 @@ describe('MediaConnectionAwaiter', () => {
|
|
|
287
406
|
|
|
288
407
|
mockMC.getConnectionState.returns(ConnectionState.Connected);
|
|
289
408
|
|
|
290
|
-
await clock.tickAsync(
|
|
409
|
+
await clock.tickAsync(ICE_CONNECTION_TIMEOUT);
|
|
291
410
|
await testUtils.flushPromises();
|
|
292
411
|
|
|
293
412
|
assert.equal(promiseResolved, true);
|
|
@@ -366,15 +485,16 @@ describe('MediaConnectionAwaiter', () => {
|
|
|
366
485
|
assert.equal(mockMC.on.getCall(0).args[0], MediaConnectionEventNames.PEER_CONNECTION_STATE_CHANGED);
|
|
367
486
|
assert.equal(mockMC.on.getCall(1).args[0], MediaConnectionEventNames.ICE_CONNECTION_STATE_CHANGED);
|
|
368
487
|
assert.equal(mockMC.on.getCall(2).args[0], MediaConnectionEventNames.ICE_GATHERING_STATE_CHANGED);
|
|
369
|
-
const listener = mockMC.on.getCall(
|
|
488
|
+
const listener = mockMC.on.getCall(2).args[1];
|
|
370
489
|
|
|
371
490
|
// call the listener and pretend we are now connected
|
|
372
491
|
mockMC.getIceGatheringState.returns('gathering');
|
|
373
492
|
listener();
|
|
493
|
+
assert.notCalled(clearTimeoutSpy);
|
|
374
494
|
|
|
375
495
|
mockMC.getConnectionState.returns(ConnectionState.Connected);
|
|
376
496
|
|
|
377
|
-
await clock.tickAsync(
|
|
497
|
+
await clock.tickAsync(ICE_CONNECTION_TIMEOUT);
|
|
378
498
|
await testUtils.flushPromises();
|
|
379
499
|
|
|
380
500
|
assert.equal(promiseResolved, true);
|
|
@@ -383,7 +503,8 @@ describe('MediaConnectionAwaiter', () => {
|
|
|
383
503
|
// check that listener was removed
|
|
384
504
|
assert.calledThrice(mockMC.off);
|
|
385
505
|
|
|
386
|
-
assert.
|
|
506
|
+
assert.calledOnce(clearTimeoutSpy);
|
|
507
|
+
assert.equal(clock.countTimers(), 0);
|
|
387
508
|
});
|
|
388
509
|
|
|
389
510
|
it(`ice gathering update to 'complete' state restarts the timer`, async () => {
|
|
@@ -427,7 +548,7 @@ describe('MediaConnectionAwaiter', () => {
|
|
|
427
548
|
|
|
428
549
|
mockMC.getConnectionState.returns(ConnectionState.Connected);
|
|
429
550
|
|
|
430
|
-
await clock.tickAsync(
|
|
551
|
+
await clock.tickAsync(ICE_CONNECTION_TIMEOUT);
|
|
431
552
|
await testUtils.flushPromises();
|
|
432
553
|
|
|
433
554
|
assert.equal(promiseResolved, true);
|
|
@@ -468,7 +589,7 @@ describe('MediaConnectionAwaiter', () => {
|
|
|
468
589
|
assert.equal(mockMC.on.getCall(1).args[0], MediaConnectionEventNames.ICE_CONNECTION_STATE_CHANGED);
|
|
469
590
|
assert.equal(mockMC.on.getCall(2).args[0], MediaConnectionEventNames.ICE_GATHERING_STATE_CHANGED);
|
|
470
591
|
|
|
471
|
-
await clock.tickAsync(
|
|
592
|
+
await clock.tickAsync(ICE_CONNECTION_TIMEOUT * 2);
|
|
472
593
|
await testUtils.flushPromises();
|
|
473
594
|
|
|
474
595
|
assert.equal(promiseResolved, false);
|
|
@@ -477,7 +598,8 @@ describe('MediaConnectionAwaiter', () => {
|
|
|
477
598
|
// check that listener was removed
|
|
478
599
|
assert.calledThrice(mockMC.off);
|
|
479
600
|
|
|
480
|
-
assert.
|
|
601
|
+
assert.calledTwice(clearTimeoutSpy);
|
|
602
|
+
assert.equal(clock.countTimers(), 0);
|
|
481
603
|
assert.calledTwice(setTimeoutSpy);
|
|
482
604
|
|
|
483
605
|
// verify sendMetric was called twice (once for each timeout)
|
|
@@ -536,4 +658,289 @@ describe('MediaConnectionAwaiter', () => {
|
|
|
536
658
|
assert.calledTwice(setTimeoutSpy);
|
|
537
659
|
});
|
|
538
660
|
});
|
|
661
|
+
describe('connection phases', () => {
|
|
662
|
+
const DTLS_TIME_BEFORE_STATE_CHANGE = Math.floor(DTLS_CONNECTION_TIMEOUT / 2);
|
|
663
|
+
const DTLS_TIME_AFTER_STATE_CHANGE = DTLS_CONNECTION_TIMEOUT - DTLS_TIME_BEFORE_STATE_CHANGE;
|
|
664
|
+
const ICE_RECOVERY_DELAY = Math.floor(ICE_CONNECTION_TIMEOUT / 2);
|
|
665
|
+
|
|
666
|
+
const startWait = (iceState = 'checking', gatheringState = 'complete') => {
|
|
667
|
+
mockMC.getConnectionState.returns(ConnectionState.Connecting);
|
|
668
|
+
mockMC.getIceConnectionState.returns(iceState);
|
|
669
|
+
mockMC.getIceGatheringState.returns(gatheringState);
|
|
670
|
+
|
|
671
|
+
const result = {status: 'pending', error: undefined};
|
|
672
|
+
const promise = mediaConnectionAwaiter.waitForMediaConnectionConnected().then(
|
|
673
|
+
() => {
|
|
674
|
+
result.status = 'resolved';
|
|
675
|
+
},
|
|
676
|
+
(error) => {
|
|
677
|
+
result.status = 'rejected';
|
|
678
|
+
result.error = error;
|
|
679
|
+
}
|
|
680
|
+
);
|
|
681
|
+
|
|
682
|
+
return {result, promise};
|
|
683
|
+
};
|
|
684
|
+
|
|
685
|
+
const changeIceState = (iceState) => {
|
|
686
|
+
mockMC.getIceConnectionState.returns(iceState);
|
|
687
|
+
mediaConnectionAwaiter.iceConnectionStateHandler();
|
|
688
|
+
};
|
|
689
|
+
|
|
690
|
+
const assertCleanedUp = () => {
|
|
691
|
+
assert.equal(clock.countTimers(), 0);
|
|
692
|
+
assert.calledThrice(mockMC.off);
|
|
693
|
+
mockMC.on.getCalls().forEach(({args}) => {
|
|
694
|
+
assert.calledWithExactly(mockMC.off, ...args);
|
|
695
|
+
});
|
|
696
|
+
};
|
|
697
|
+
|
|
698
|
+
['connected', 'completed'].forEach((iceState) => {
|
|
699
|
+
['disconnected', 'checking', 'new'].forEach((lostState) => {
|
|
700
|
+
it(`gives DTLS a fresh deadline after ${iceState} -> ${lostState} -> connected`, async () => {
|
|
701
|
+
const {result, promise} = startWait(iceState);
|
|
702
|
+
await clock.tickAsync(DTLS_TIME_BEFORE_STATE_CHANGE);
|
|
703
|
+
changeIceState(lostState);
|
|
704
|
+
await clock.tickAsync(ICE_RECOVERY_DELAY);
|
|
705
|
+
assert.equal(result.status, 'pending');
|
|
706
|
+
changeIceState('connected');
|
|
707
|
+
await clock.tickAsync(DTLS_CONNECTION_TIMEOUT - 1);
|
|
708
|
+
assert.equal(result.status, 'pending');
|
|
709
|
+
|
|
710
|
+
mockMC.getConnectionState.returns(ConnectionState.Connected);
|
|
711
|
+
mediaConnectionAwaiter.peerConnectionStateHandler();
|
|
712
|
+
await promise;
|
|
713
|
+
assert.equal(result.status, 'resolved');
|
|
714
|
+
assertCleanedUp();
|
|
715
|
+
});
|
|
716
|
+
});
|
|
717
|
+
});
|
|
718
|
+
|
|
719
|
+
['disconnected', 'checking', 'new'].forEach((lostState) => {
|
|
720
|
+
it(`uses the ICE deadline and preserves history after connectivity becomes ${lostState}`, async () => {
|
|
721
|
+
const metric = sinon.stub(Metrics, 'sendBehavioralMetric');
|
|
722
|
+
const {result, promise} = startWait('connected');
|
|
723
|
+
await clock.tickAsync(DTLS_TIME_BEFORE_STATE_CHANGE);
|
|
724
|
+
changeIceState(lostState);
|
|
725
|
+
await clock.tickAsync(ICE_CONNECTION_TIMEOUT - 1);
|
|
726
|
+
assert.equal(result.status, 'pending');
|
|
727
|
+
assert.notCalled(metric);
|
|
728
|
+
await clock.tickAsync(1);
|
|
729
|
+
await promise;
|
|
730
|
+
assert.deepEqual(result.error, {iceConnected: false, iceConnectedAtLeastOnce: true});
|
|
731
|
+
assert.calledOnceWithExactly(
|
|
732
|
+
metric,
|
|
733
|
+
BEHAVIORAL_METRICS.MEDIA_STILL_NOT_CONNECTED,
|
|
734
|
+
sinon.match({iceConnected: false, iceConnectedAtLeastOnce: true})
|
|
735
|
+
);
|
|
736
|
+
assertCleanedUp();
|
|
737
|
+
});
|
|
738
|
+
});
|
|
739
|
+
|
|
740
|
+
it('does not extend DTLS for repeated connected or completed events', async () => {
|
|
741
|
+
const {result, promise} = startWait('connected');
|
|
742
|
+
await clock.tickAsync(DTLS_TIME_BEFORE_STATE_CHANGE);
|
|
743
|
+
changeIceState('completed');
|
|
744
|
+
changeIceState('completed');
|
|
745
|
+
changeIceState('connected');
|
|
746
|
+
await clock.tickAsync(DTLS_TIME_AFTER_STATE_CHANGE);
|
|
747
|
+
assert.equal(result.status, 'rejected');
|
|
748
|
+
await promise;
|
|
749
|
+
assert.deepEqual(result.error, {iceConnected: true, iceConnectedAtLeastOnce: true});
|
|
750
|
+
assertCleanedUp();
|
|
751
|
+
});
|
|
752
|
+
|
|
753
|
+
it('gives late ICE connectivity the full DTLS deadline', async () => {
|
|
754
|
+
const {result, promise} = startWait();
|
|
755
|
+
await clock.tickAsync(ICE_CONNECTION_TIMEOUT - 1);
|
|
756
|
+
changeIceState('connected');
|
|
757
|
+
await clock.tickAsync(DTLS_CONNECTION_TIMEOUT - 1);
|
|
758
|
+
assert.equal(result.status, 'pending');
|
|
759
|
+
await clock.tickAsync(1);
|
|
760
|
+
await promise;
|
|
761
|
+
assert.deepEqual(result.error, {iceConnected: true, iceConnectedAtLeastOnce: true});
|
|
762
|
+
assertCleanedUp();
|
|
763
|
+
});
|
|
764
|
+
|
|
765
|
+
it('does not extend DTLS when gathering completes', async () => {
|
|
766
|
+
const {result, promise} = startWait('connected', 'gathering');
|
|
767
|
+
await clock.tickAsync(DTLS_TIME_BEFORE_STATE_CHANGE);
|
|
768
|
+
mockMC.getIceGatheringState.returns('complete');
|
|
769
|
+
mediaConnectionAwaiter.iceGatheringStateHandler();
|
|
770
|
+
await clock.tickAsync(DTLS_TIME_AFTER_STATE_CHANGE);
|
|
771
|
+
assert.equal(result.status, 'rejected');
|
|
772
|
+
await promise;
|
|
773
|
+
assertCleanedUp();
|
|
774
|
+
});
|
|
775
|
+
|
|
776
|
+
['peerConnectionStateHandler', 'iceGatheringStateHandler', 'onTimeout'].forEach((handler) => {
|
|
777
|
+
it(`detects an unreported ICE connection through ${handler}`, async () => {
|
|
778
|
+
const metric = sinon.stub(Metrics, 'sendBehavioralMetric');
|
|
779
|
+
const {result, promise} = startWait();
|
|
780
|
+
await clock.tickAsync(ICE_CONNECTION_TIMEOUT - 1);
|
|
781
|
+
mockMC.getIceConnectionState.returns('connected');
|
|
782
|
+
if (handler === 'onTimeout') {
|
|
783
|
+
await clock.tickAsync(1);
|
|
784
|
+
} else {
|
|
785
|
+
mediaConnectionAwaiter[handler]();
|
|
786
|
+
}
|
|
787
|
+
assert.notCalled(metric);
|
|
788
|
+
await clock.tickAsync(DTLS_CONNECTION_TIMEOUT - 1);
|
|
789
|
+
assert.equal(result.status, 'pending');
|
|
790
|
+
await clock.tickAsync(1);
|
|
791
|
+
await promise;
|
|
792
|
+
assert.equal(result.status, 'rejected');
|
|
793
|
+
assertCleanedUp();
|
|
794
|
+
});
|
|
795
|
+
});
|
|
796
|
+
|
|
797
|
+
it('detects unreported ICE loss when the DTLS timer expires', async () => {
|
|
798
|
+
const metric = sinon.stub(Metrics, 'sendBehavioralMetric');
|
|
799
|
+
const {result, promise} = startWait('connected');
|
|
800
|
+
mockMC.getIceConnectionState.returns('disconnected');
|
|
801
|
+
await clock.tickAsync(DTLS_CONNECTION_TIMEOUT);
|
|
802
|
+
assert.equal(result.status, 'pending');
|
|
803
|
+
assert.notCalled(metric);
|
|
804
|
+
await clock.tickAsync(ICE_CONNECTION_TIMEOUT);
|
|
805
|
+
await promise;
|
|
806
|
+
assert.deepEqual(result.error, {iceConnected: false, iceConnectedAtLeastOnce: true});
|
|
807
|
+
assertCleanedUp();
|
|
808
|
+
});
|
|
809
|
+
|
|
810
|
+
['checking', 'connected'].forEach((iceState) => {
|
|
811
|
+
[false, true].forEach((retryConsumed) => {
|
|
812
|
+
it(`retries incomplete gathering only during ICE with ${iceState}, consumed=${retryConsumed}`, async () => {
|
|
813
|
+
const {result, promise} = startWait('checking', 'gathering');
|
|
814
|
+
if (retryConsumed) {
|
|
815
|
+
await clock.tickAsync(ICE_CONNECTION_TIMEOUT);
|
|
816
|
+
}
|
|
817
|
+
changeIceState(iceState);
|
|
818
|
+
const timeout =
|
|
819
|
+
iceState === 'connected' ? DTLS_CONNECTION_TIMEOUT : ICE_CONNECTION_TIMEOUT;
|
|
820
|
+
await clock.tickAsync(timeout);
|
|
821
|
+
const shouldRetry = iceState === 'checking' && !retryConsumed;
|
|
822
|
+
assert.equal(result.status, shouldRetry ? 'pending' : 'rejected');
|
|
823
|
+
if (shouldRetry) {
|
|
824
|
+
await clock.tickAsync(timeout);
|
|
825
|
+
}
|
|
826
|
+
await promise;
|
|
827
|
+
assert.equal(result.status, 'rejected');
|
|
828
|
+
assertCleanedUp();
|
|
829
|
+
});
|
|
830
|
+
});
|
|
831
|
+
});
|
|
832
|
+
|
|
833
|
+
[ConnectionState.Failed, ConnectionState.Closed].forEach((state) => {
|
|
834
|
+
['checking', 'connected'].forEach((iceState) => {
|
|
835
|
+
it(`rejects initial ${state} immediately with ICE ${iceState}`, async () => {
|
|
836
|
+
mockMC.getConnectionState.returns(state);
|
|
837
|
+
mockMC.getIceConnectionState.returns(iceState);
|
|
838
|
+
const error = await mediaConnectionAwaiter.waitForMediaConnectionConnected().then(
|
|
839
|
+
() => assert.fail('Expected rejection'),
|
|
840
|
+
(failure) => failure
|
|
841
|
+
);
|
|
842
|
+
assert.deepEqual(error, {
|
|
843
|
+
iceConnected: iceState === 'connected',
|
|
844
|
+
iceConnectedAtLeastOnce: iceState === 'connected',
|
|
845
|
+
});
|
|
846
|
+
assert.calledThrice(mockMC.on);
|
|
847
|
+
assertCleanedUp();
|
|
848
|
+
});
|
|
849
|
+
|
|
850
|
+
it(`cleans up on ${state} with ICE ${iceState} and ignores late callbacks`, async () => {
|
|
851
|
+
const metric = sinon.stub(Metrics, 'sendBehavioralMetric');
|
|
852
|
+
const {result, promise} = startWait('connected');
|
|
853
|
+
mockMC.getIceConnectionState.returns(iceState);
|
|
854
|
+
mockMC.getConnectionState.returns(state);
|
|
855
|
+
mediaConnectionAwaiter.peerConnectionStateHandler();
|
|
856
|
+
await promise;
|
|
857
|
+
assert.deepEqual(result.error, {
|
|
858
|
+
iceConnected: iceState === 'connected',
|
|
859
|
+
iceConnectedAtLeastOnce: true,
|
|
860
|
+
});
|
|
861
|
+
mediaConnectionAwaiter.iceGatheringStateHandler();
|
|
862
|
+
mediaConnectionAwaiter.iceConnectionStateHandler();
|
|
863
|
+
mediaConnectionAwaiter.onTimeout();
|
|
864
|
+
await clock.tickAsync(ICE_CONNECTION_TIMEOUT * 2);
|
|
865
|
+
assert.notCalled(metric);
|
|
866
|
+
assertCleanedUp();
|
|
867
|
+
});
|
|
868
|
+
});
|
|
869
|
+
});
|
|
870
|
+
|
|
871
|
+
it('restarts the ICE deadline when gathering completes after connectivity loss', async () => {
|
|
872
|
+
const {result, promise} = startWait('connected', 'gathering');
|
|
873
|
+
changeIceState('disconnected');
|
|
874
|
+
await clock.tickAsync(ICE_CONNECTION_TIMEOUT - 1);
|
|
875
|
+
mockMC.getIceGatheringState.returns('complete');
|
|
876
|
+
mediaConnectionAwaiter.iceGatheringStateHandler();
|
|
877
|
+
await clock.tickAsync(ICE_CONNECTION_TIMEOUT - 1);
|
|
878
|
+
assert.equal(result.status, 'pending');
|
|
879
|
+
await clock.tickAsync(1);
|
|
880
|
+
await promise;
|
|
881
|
+
assert.deepEqual(result.error, {iceConnected: false, iceConnectedAtLeastOnce: true});
|
|
882
|
+
assertCleanedUp();
|
|
883
|
+
});
|
|
884
|
+
|
|
885
|
+
['connected', 'completed'].forEach((iceState) => {
|
|
886
|
+
it(`resets the ICE gathering retry after recovery through ${iceState}`, async () => {
|
|
887
|
+
const {result, promise} = startWait('checking', 'gathering');
|
|
888
|
+
await clock.tickAsync(ICE_CONNECTION_TIMEOUT);
|
|
889
|
+
assert.equal(result.status, 'pending');
|
|
890
|
+
changeIceState(iceState);
|
|
891
|
+
changeIceState('disconnected');
|
|
892
|
+
await clock.tickAsync(ICE_CONNECTION_TIMEOUT);
|
|
893
|
+
assert.equal(result.status, 'pending');
|
|
894
|
+
await clock.tickAsync(ICE_CONNECTION_TIMEOUT);
|
|
895
|
+
assert.equal(result.status, 'rejected');
|
|
896
|
+
await promise;
|
|
897
|
+
assert.deepEqual(result.error, {iceConnected: false, iceConnectedAtLeastOnce: true});
|
|
898
|
+
assertCleanedUp();
|
|
899
|
+
});
|
|
900
|
+
});
|
|
901
|
+
|
|
902
|
+
it('captures connectivity before asynchronous stats complete', async () => {
|
|
903
|
+
const metric = sinon.stub(Metrics, 'sendBehavioralMetric');
|
|
904
|
+
let resolveStats;
|
|
905
|
+
mockMC.getStats.returns(
|
|
906
|
+
new Promise((resolve) => {
|
|
907
|
+
resolveStats = resolve;
|
|
908
|
+
})
|
|
909
|
+
);
|
|
910
|
+
const {promise} = startWait('connected');
|
|
911
|
+
await clock.tickAsync(DTLS_CONNECTION_TIMEOUT);
|
|
912
|
+
await promise;
|
|
913
|
+
mockMC.getIceConnectionState.returns('disconnected');
|
|
914
|
+
resolveStats({values: () => []});
|
|
915
|
+
await testUtils.flushPromises();
|
|
916
|
+
assert.calledOnceWithExactly(
|
|
917
|
+
metric,
|
|
918
|
+
BEHAVIORAL_METRICS.MEDIA_STILL_NOT_CONNECTED,
|
|
919
|
+
sinon.match({iceConnected: true, iceConnectedAtLeastOnce: true})
|
|
920
|
+
);
|
|
921
|
+
});
|
|
922
|
+
|
|
923
|
+
it('rejects on deadline even if gathering stats fails', async () => {
|
|
924
|
+
const metric = sinon.stub(Metrics, 'sendBehavioralMetric');
|
|
925
|
+
mockMC.getStats.rejects(new Error('Stats unavailable'));
|
|
926
|
+
const {result, promise} = startWait('connected');
|
|
927
|
+
await clock.tickAsync(DTLS_CONNECTION_TIMEOUT);
|
|
928
|
+
await promise;
|
|
929
|
+
assert.equal(result.status, 'rejected');
|
|
930
|
+
assert.notCalled(metric);
|
|
931
|
+
assertCleanedUp();
|
|
932
|
+
});
|
|
933
|
+
|
|
934
|
+
it('registers listeners and starts the deadline only once for repeated waits', async () => {
|
|
935
|
+
const first = mediaConnectionAwaiter.waitForMediaConnectionConnected();
|
|
936
|
+
const second = mediaConnectionAwaiter.waitForMediaConnectionConnected();
|
|
937
|
+
assert.strictEqual(first, second);
|
|
938
|
+
assert.calledThrice(mockMC.on);
|
|
939
|
+
assert.equal(clock.countTimers(), 1);
|
|
940
|
+
mockMC.getConnectionState.returns(ConnectionState.Connected);
|
|
941
|
+
mediaConnectionAwaiter.peerConnectionStateHandler();
|
|
942
|
+
await first;
|
|
943
|
+
assertCleanedUp();
|
|
944
|
+
});
|
|
945
|
+
});
|
|
539
946
|
});
|
|
@@ -55,9 +55,9 @@ describe('MediaProperties', () => {
|
|
|
55
55
|
|
|
56
56
|
await mediaProperties.waitForMediaConnectionConnected(correlationId);
|
|
57
57
|
|
|
58
|
-
assert.
|
|
59
|
-
assert.equal(capturedInstance.correlationId, correlationId);
|
|
60
|
-
assert.equal(capturedInstance.webrtcMediaConnection, mockMC);
|
|
58
|
+
assert.calledOnceWithExactly(stub);
|
|
59
|
+
assert.equal(capturedInstance.props.correlationId, correlationId);
|
|
60
|
+
assert.equal(capturedInstance.props.webrtcMediaConnection, mockMC);
|
|
61
61
|
});
|
|
62
62
|
it('rejects if media connection is not connected', async () => {
|
|
63
63
|
const waitForMediaConnectionConnectedResult = new Defer();
|