webext-schema 7.0.0 → 7.1.1

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.
@@ -5,50 +5,73 @@ import path from 'node:path';
5
5
  import process from 'node:process';
6
6
  import sinon from 'sinon';
7
7
  import { afterEach, beforeEach, describe, it } from 'mocha';
8
- import { MockAgent, getGlobalDispatcher, setGlobalDispatcher } from 'undici';
8
+ import {
9
+ fetch as undiciFetch,
10
+ getGlobalDispatcher,
11
+ MockAgent,
12
+ setGlobalDispatcher
13
+ } from 'undici';
9
14
 
10
15
  /* test */
11
16
  import {
12
- createUnifiedSchema, fetchText, getAllSchemaData, getChannelUrl, getFileList,
13
- getListedSchemaData, getMailExtSchemaData, getSchemaData, saveSchemaFile,
17
+ createUnifiedSchema,
18
+ fetchText,
19
+ getAllSchemaData,
20
+ getChannelUrl,
21
+ getFileList,
22
+ getListedSchemaData,
23
+ getMailExtSchemaData,
24
+ getSchemaData,
25
+ saveSchemaFile,
14
26
  updateSchemas
15
27
  } from '../modules/update.js';
16
28
 
17
29
  describe('fetch text', () => {
30
+ const originalFetch = globalThis.fetch;
18
31
  const globalDispatcher = getGlobalDispatcher();
19
32
  const mockAgent = new MockAgent();
20
33
  beforeEach(() => {
21
34
  setGlobalDispatcher(mockAgent);
22
35
  mockAgent.disableNetConnect();
36
+ globalThis.fetch = undiciFetch;
23
37
  });
24
38
  afterEach(() => {
25
39
  mockAgent.enableNetConnect();
26
40
  setGlobalDispatcher(globalDispatcher);
41
+ globalThis.fetch = originalFetch;
27
42
  });
28
43
 
29
44
  it('should throw', async () => {
30
45
  await fetchText().catch(e => {
31
- assert.deepStrictEqual(e,
32
- new TypeError('Expected String but got Undefined.'));
46
+ assert.deepStrictEqual(
47
+ e,
48
+ new TypeError('Expected String but got Undefined.')
49
+ );
33
50
  });
34
51
  });
35
52
 
36
53
  it('should throw', async () => {
37
54
  const url = new URL('https://example.com');
38
- mockAgent.get(url.origin).intercept({ path: url.pathname, method: 'GET' })
55
+ mockAgent
56
+ .get(url.origin)
57
+ .intercept({ path: url.pathname, method: 'GET' })
39
58
  .reply(404, {
40
59
  ok: false,
41
60
  status: 404
42
61
  });
43
62
  await fetchText('https://example.com').catch(e => {
44
- assert.deepStrictEqual(e,
45
- new Error('Network response was not ok. status: 404'));
63
+ assert.deepStrictEqual(
64
+ e,
65
+ new Error('Network response was not ok. status: 404')
66
+ );
46
67
  });
47
68
  });
48
69
 
49
70
  it('should get result', async () => {
50
71
  const url = new URL('https://example.com');
51
- mockAgent.get(url.origin).intercept({ path: url.pathname, method: 'GET' })
72
+ mockAgent
73
+ .get(url.origin)
74
+ .intercept({ path: url.pathname, method: 'GET' })
52
75
  .reply(200, 'foo');
53
76
  const res = await fetchText('https://example.com');
54
77
  assert.strictEqual(res, 'foo', 'result');
@@ -59,7 +82,8 @@ describe('get channel url', () => {
59
82
  it('should get result', () => {
60
83
  const res = getChannelUrl();
61
84
  assert.strictEqual(
62
- res, 'https://hg.mozilla.org/releases/mozilla-beta/raw-file/tip/',
85
+ res,
86
+ 'https://hg-edge.mozilla.org/releases/mozilla-beta/raw-file/tip/',
63
87
  'result'
64
88
  );
65
89
  });
@@ -67,7 +91,8 @@ describe('get channel url', () => {
67
91
  it('should get result', () => {
68
92
  const res = getChannelUrl('beta');
69
93
  assert.strictEqual(
70
- res, 'https://hg.mozilla.org/releases/mozilla-beta/raw-file/tip/',
94
+ res,
95
+ 'https://hg-edge.mozilla.org/releases/mozilla-beta/raw-file/tip/',
71
96
  'result'
72
97
  );
73
98
  });
@@ -75,7 +100,8 @@ describe('get channel url', () => {
75
100
  it('should get result', () => {
76
101
  const res = getChannelUrl('central');
77
102
  assert.strictEqual(
78
- res, 'https://hg.mozilla.org/mozilla-central/raw-file/tip/',
103
+ res,
104
+ 'https://hg-edge.mozilla.org/mozilla-central/raw-file/tip/',
79
105
  'result'
80
106
  );
81
107
  });
@@ -83,101 +109,134 @@ describe('get channel url', () => {
83
109
  it('should get result', () => {
84
110
  const res = getChannelUrl('mail');
85
111
  assert.strictEqual(
86
- res, 'https://hg.mozilla.org/comm-central/raw-file/tip/',
112
+ res,
113
+ 'https://hg-edge.mozilla.org/comm-central/raw-file/tip/',
87
114
  'result'
88
115
  );
89
116
  });
90
117
  });
91
118
 
92
119
  describe('get schema data', () => {
120
+ const originalFetch = globalThis.fetch;
93
121
  const globalDispatcher = getGlobalDispatcher();
94
122
  const mockAgent = new MockAgent();
95
123
  beforeEach(() => {
96
124
  setGlobalDispatcher(mockAgent);
97
125
  mockAgent.disableNetConnect();
126
+ globalThis.fetch = undiciFetch;
98
127
  });
99
128
  afterEach(() => {
100
129
  mockAgent.enableNetConnect();
101
130
  setGlobalDispatcher(globalDispatcher);
131
+ globalThis.fetch = originalFetch;
102
132
  });
103
133
 
104
134
  it('should throw', async () => {
105
135
  await getSchemaData().catch(e => {
106
- assert.deepStrictEqual(e,
107
- new TypeError('Expected String but got Undefined.'));
136
+ assert.deepStrictEqual(
137
+ e,
138
+ new TypeError('Expected String but got Undefined.')
139
+ );
108
140
  });
109
141
  });
110
142
 
111
143
  it('should throw', async () => {
112
144
  await getSchemaData('foo').catch(e => {
113
- assert.deepStrictEqual(e,
114
- new TypeError('Expected String but got Undefined.'));
145
+ assert.deepStrictEqual(
146
+ e,
147
+ new TypeError('Expected String but got Undefined.')
148
+ );
115
149
  });
116
150
  });
117
151
 
118
152
  it('should get object', async () => {
119
153
  const url = new URL('https://example.com/foo.json');
120
- mockAgent.get(url.origin).intercept({ path: url.pathname, method: 'GET' })
154
+ mockAgent
155
+ .get(url.origin)
156
+ .intercept({ path: url.pathname, method: 'GET' })
121
157
  .reply(200, '{ "foo": [ "bar" ] }');
122
158
  const res = await getSchemaData('foo.json', 'https://example.com');
123
- assert.deepEqual(res, {
124
- file: 'foo.json',
125
- schema: {
126
- foo: ['bar']
127
- }
128
- }, 'result');
159
+ assert.deepEqual(
160
+ res,
161
+ {
162
+ file: 'foo.json',
163
+ schema: {
164
+ foo: ['bar']
165
+ }
166
+ },
167
+ 'result'
168
+ );
129
169
  });
130
170
  });
131
171
 
132
172
  describe('get schema file list from jar manifest', () => {
173
+ const originalFetch = globalThis.fetch;
133
174
  const globalDispatcher = getGlobalDispatcher();
134
175
  const mockAgent = new MockAgent();
135
176
  beforeEach(() => {
136
177
  setGlobalDispatcher(mockAgent);
137
178
  mockAgent.disableNetConnect();
179
+ globalThis.fetch = undiciFetch;
138
180
  });
139
181
  afterEach(() => {
140
182
  mockAgent.enableNetConnect();
141
183
  setGlobalDispatcher(globalDispatcher);
184
+ globalThis.fetch = originalFetch;
142
185
  });
143
186
 
144
187
  it('should throw', async () => {
145
188
  await getFileList().catch(e => {
146
- assert.deepStrictEqual(e,
147
- new TypeError('Expected String but got Undefined.'));
189
+ assert.deepStrictEqual(
190
+ e,
191
+ new TypeError('Expected String but got Undefined.')
192
+ );
148
193
  });
149
194
  });
150
195
 
151
196
  it('should get array', async () => {
152
197
  const url = new URL('https://example.com/jar.mn');
153
- mockAgent.get(url.origin).intercept({ path: url.pathname, method: 'GET' })
154
- .reply(200, '# comment\n\ntoolkit.jar:\n% content extensions %content/extensions/\n content/extensions/schemas/alarms.json\n content/extensions/schemas/browser_settings.json\n#ifndef ANDROID\n content/extensions/schemas/geckoProfiler.json\n#endif\n content/extensions/schemas/i18n.json\n');
198
+ mockAgent
199
+ .get(url.origin)
200
+ .intercept({ path: url.pathname, method: 'GET' })
201
+ .reply(
202
+ 200,
203
+ '# comment\n\ntoolkit.jar:\n% content extensions %content/extensions/\n content/extensions/schemas/alarms.json\n content/extensions/schemas/browser_settings.json\n#ifndef ANDROID\n content/extensions/schemas/geckoProfiler.json\n#endif\n content/extensions/schemas/i18n.json\n'
204
+ );
155
205
  const res = await getFileList('https://example.com');
156
- assert.deepEqual(res, [
157
- 'alarms.json',
158
- 'browser_settings.json',
159
- 'geckoProfiler.json',
160
- 'i18n.json'
161
- ], 'result');
206
+ assert.deepEqual(
207
+ res,
208
+ [
209
+ 'alarms.json',
210
+ 'browser_settings.json',
211
+ 'geckoProfiler.json',
212
+ 'i18n.json'
213
+ ],
214
+ 'result'
215
+ );
162
216
  });
163
217
  });
164
218
 
165
219
  describe('get all schema data', () => {
220
+ const originalFetch = globalThis.fetch;
166
221
  const globalDispatcher = getGlobalDispatcher();
167
222
  const mockAgent = new MockAgent();
168
223
  beforeEach(() => {
169
224
  setGlobalDispatcher(mockAgent);
170
225
  mockAgent.disableNetConnect();
226
+ globalThis.fetch = undiciFetch;
171
227
  });
172
228
  afterEach(() => {
173
229
  mockAgent.enableNetConnect();
174
230
  setGlobalDispatcher(globalDispatcher);
231
+ globalThis.fetch = originalFetch;
175
232
  });
176
233
 
177
234
  it('should throw', async () => {
178
235
  await getAllSchemaData().catch(e => {
179
- assert.deepStrictEqual(e,
180
- new TypeError('Expected String but got Undefined.'));
236
+ assert.deepStrictEqual(
237
+ e,
238
+ new TypeError('Expected String but got Undefined.')
239
+ );
181
240
  });
182
241
  });
183
242
 
@@ -185,84 +244,111 @@ describe('get all schema data', () => {
185
244
  const stubInfo = sinon.stub(console, 'info');
186
245
  const url = new URL('https://example.com');
187
246
  const mockPool = mockAgent.get(url.origin);
188
- mockPool.intercept({ path: '/jar.mn', method: 'GET' })
189
- .reply(200, 'content/extensions/schemas/foo.json\ncontent/extensions/schemas/bar.json\n');
190
- mockPool.intercept({ path: '/foo.json', method: 'GET' })
247
+ mockPool
248
+ .intercept({ path: '/jar.mn', method: 'GET' })
249
+ .reply(
250
+ 200,
251
+ 'content/extensions/schemas/foo.json\ncontent/extensions/schemas/bar.json\n'
252
+ );
253
+ mockPool
254
+ .intercept({ path: '/foo.json', method: 'GET' })
191
255
  .reply(200, '{ "foo": "foobar" }');
192
- mockPool.intercept({ path: '/bar.json', method: 'GET' })
256
+ mockPool
257
+ .intercept({ path: '/bar.json', method: 'GET' })
193
258
  .reply(200, '{ "baz": "qux" }');
194
259
  const res = await getAllSchemaData('https://example.com/');
195
260
  assert.strictEqual(stubInfo.called, false, 'info');
196
261
  stubInfo.restore();
197
- assert.deepEqual(res, [
198
- {
199
- file: 'foo.json',
200
- schema: {
201
- foo: 'foobar'
202
- }
203
- },
204
- {
205
- file: 'bar.json',
206
- schema: {
207
- baz: 'qux'
262
+ assert.deepEqual(
263
+ res,
264
+ [
265
+ {
266
+ file: 'foo.json',
267
+ schema: {
268
+ foo: 'foobar'
269
+ }
270
+ },
271
+ {
272
+ file: 'bar.json',
273
+ schema: {
274
+ baz: 'qux'
275
+ }
208
276
  }
209
- }
210
- ], 'result');
277
+ ],
278
+ 'result'
279
+ );
211
280
  });
212
281
 
213
282
  it('should get array', async () => {
214
283
  const stubInfo = sinon.stub(console, 'info');
215
284
  const url = new URL('https://example.com');
216
285
  const mockPool = mockAgent.get(url.origin);
217
- mockPool.intercept({ path: '/jar.mn', method: 'GET' })
218
- .reply(200, 'content/extensions/schemas/foo.json\ncontent/extensions/schemas/bar.json\n');
219
- mockPool.intercept({ path: '/foo.json', method: 'GET' })
286
+ mockPool
287
+ .intercept({ path: '/jar.mn', method: 'GET' })
288
+ .reply(
289
+ 200,
290
+ 'content/extensions/schemas/foo.json\ncontent/extensions/schemas/bar.json\n'
291
+ );
292
+ mockPool
293
+ .intercept({ path: '/foo.json', method: 'GET' })
220
294
  .reply(200, '{ "foo": "foobar" }');
221
- mockPool.intercept({ path: '/bar.json', method: 'GET' })
295
+ mockPool
296
+ .intercept({ path: '/bar.json', method: 'GET' })
222
297
  .reply(200, '{ "baz": "qux" }');
223
298
  const res = await getAllSchemaData('https://example.com/', true);
224
299
  assert.strictEqual(stubInfo.called, true, 'info');
225
300
  stubInfo.restore();
226
- assert.deepEqual(res, [
227
- {
228
- file: 'foo.json',
229
- schema: {
230
- foo: 'foobar'
231
- }
232
- },
233
- {
234
- file: 'bar.json',
235
- schema: {
236
- baz: 'qux'
301
+ assert.deepEqual(
302
+ res,
303
+ [
304
+ {
305
+ file: 'foo.json',
306
+ schema: {
307
+ foo: 'foobar'
308
+ }
309
+ },
310
+ {
311
+ file: 'bar.json',
312
+ schema: {
313
+ baz: 'qux'
314
+ }
237
315
  }
238
- }
239
- ], 'result');
316
+ ],
317
+ 'result'
318
+ );
240
319
  });
241
320
  });
242
321
 
243
322
  describe('get listed schema data', () => {
323
+ const originalFetch = globalThis.fetch;
244
324
  const globalDispatcher = getGlobalDispatcher();
245
325
  const mockAgent = new MockAgent();
246
326
  beforeEach(() => {
247
327
  setGlobalDispatcher(mockAgent);
248
328
  mockAgent.disableNetConnect();
329
+ globalThis.fetch = undiciFetch;
249
330
  });
250
331
  afterEach(() => {
251
332
  mockAgent.enableNetConnect();
252
333
  setGlobalDispatcher(globalDispatcher);
334
+ globalThis.fetch = originalFetch;
253
335
  });
254
336
 
255
337
  it('should throw', async () => {
256
338
  await getListedSchemaData().catch(e => {
257
- assert.deepStrictEqual(e,
258
- new TypeError('Expected String but got Undefined.'));
339
+ assert.deepStrictEqual(
340
+ e,
341
+ new TypeError('Expected String but got Undefined.')
342
+ );
259
343
  });
260
344
  });
261
345
 
262
346
  it('should throw', async () => {
263
347
  await getListedSchemaData('foo').catch(e => {
264
- assert.deepStrictEqual(e,
265
- new TypeError('Expected Array but got Undefined.'));
348
+ assert.deepStrictEqual(
349
+ e,
350
+ new TypeError('Expected Array but got Undefined.')
351
+ );
266
352
  });
267
353
  });
268
354
 
@@ -270,75 +356,97 @@ describe('get listed schema data', () => {
270
356
  const stubInfo = sinon.stub(console, 'info');
271
357
  const url = new URL('https://example.com');
272
358
  const mockPool = mockAgent.get(url.origin);
273
- mockPool.intercept({ path: '/foo.json', method: 'GET' })
359
+ mockPool
360
+ .intercept({ path: '/foo.json', method: 'GET' })
274
361
  .reply(200, '{ "foo": "foobar" }');
275
- mockPool.intercept({ path: '/bar.json', method: 'GET' })
362
+ mockPool
363
+ .intercept({ path: '/bar.json', method: 'GET' })
276
364
  .reply(200, '{ "baz": "qux" }');
277
- const res = await getListedSchemaData('https://example.com/',
278
- ['foo.json', 'bar.json']);
365
+ const res = await getListedSchemaData('https://example.com/', [
366
+ 'foo.json',
367
+ 'bar.json'
368
+ ]);
279
369
  assert.strictEqual(stubInfo.called, false, 'info');
280
370
  stubInfo.restore();
281
- assert.deepEqual(res, [
282
- {
283
- file: 'foo.json',
284
- schema: {
285
- foo: 'foobar'
286
- }
287
- },
288
- {
289
- file: 'bar.json',
290
- schema: {
291
- baz: 'qux'
371
+ assert.deepEqual(
372
+ res,
373
+ [
374
+ {
375
+ file: 'foo.json',
376
+ schema: {
377
+ foo: 'foobar'
378
+ }
379
+ },
380
+ {
381
+ file: 'bar.json',
382
+ schema: {
383
+ baz: 'qux'
384
+ }
292
385
  }
293
- }
294
- ], 'result');
386
+ ],
387
+ 'result'
388
+ );
295
389
  });
296
390
 
297
391
  it('should get array', async () => {
298
392
  const stubInfo = sinon.stub(console, 'info');
299
393
  const url = new URL('https://example.com');
300
394
  const mockPool = mockAgent.get(url.origin);
301
- mockPool.intercept({ path: '/foo.json', method: 'GET' })
395
+ mockPool
396
+ .intercept({ path: '/foo.json', method: 'GET' })
302
397
  .reply(200, '{ "foo": "foobar" }');
303
- mockPool.intercept({ path: '/bar.json', method: 'GET' })
398
+ mockPool
399
+ .intercept({ path: '/bar.json', method: 'GET' })
304
400
  .reply(200, '{ "baz": "qux" }');
305
- const res = await getListedSchemaData('https://example.com/',
306
- ['foo.json', 'bar.json'], true);
401
+ const res = await getListedSchemaData(
402
+ 'https://example.com/',
403
+ ['foo.json', 'bar.json'],
404
+ true
405
+ );
307
406
  assert.strictEqual(stubInfo.called, true, 'info');
308
407
  stubInfo.restore();
309
- assert.deepEqual(res, [
310
- {
311
- file: 'foo.json',
312
- schema: {
313
- foo: 'foobar'
314
- }
315
- },
316
- {
317
- file: 'bar.json',
318
- schema: {
319
- baz: 'qux'
408
+ assert.deepEqual(
409
+ res,
410
+ [
411
+ {
412
+ file: 'foo.json',
413
+ schema: {
414
+ foo: 'foobar'
415
+ }
416
+ },
417
+ {
418
+ file: 'bar.json',
419
+ schema: {
420
+ baz: 'qux'
421
+ }
320
422
  }
321
- }
322
- ], 'result');
423
+ ],
424
+ 'result'
425
+ );
323
426
  });
324
427
  });
325
428
 
326
429
  describe('get MailExtensions schema data', () => {
430
+ const originalFetch = globalThis.fetch;
327
431
  const globalDispatcher = getGlobalDispatcher();
328
432
  const mockAgent = new MockAgent();
329
433
  beforeEach(() => {
330
434
  setGlobalDispatcher(mockAgent);
331
435
  mockAgent.disableNetConnect();
436
+ globalThis.fetch = undiciFetch;
332
437
  });
333
438
  afterEach(() => {
334
439
  mockAgent.enableNetConnect();
335
440
  setGlobalDispatcher(globalDispatcher);
441
+ globalThis.fetch = originalFetch;
336
442
  });
337
443
 
338
444
  it('should throw', async () => {
339
445
  await getMailExtSchemaData().catch(e => {
340
- assert.deepStrictEqual(e,
341
- new TypeError('Expected String but got Undefined.'));
446
+ assert.deepStrictEqual(
447
+ e,
448
+ new TypeError('Expected String but got Undefined.')
449
+ );
342
450
  });
343
451
  });
344
452
 
@@ -346,294 +454,388 @@ describe('get MailExtensions schema data', () => {
346
454
  const stubInfo = sinon.stub(console, 'info');
347
455
  const url = new URL('https://example.com');
348
456
  const mockPool = mockAgent.get(url.origin);
349
- mockPool.intercept({ path: '/jar.mn', method: 'GET' })
350
- .reply(200, '# comment\n\nmessenger.jar:\n% content/messenger/ext-mail.json\n content/messenger/schemas/accounts.json\n content/messenger/schemas/browserAction.json\n content/messenger/schemas/commands.json\n content/messenger/schemas/pkcs11.json\n');
351
- mockPool.intercept({ path: '/schemas/accounts.json', method: 'GET' })
457
+ mockPool
458
+ .intercept({ path: '/jar.mn', method: 'GET' })
459
+ .reply(
460
+ 200,
461
+ '# comment\n\nmessenger.jar:\n% content/messenger/ext-mail.json\n content/messenger/schemas/accounts.json\n content/messenger/schemas/browserAction.json\n content/messenger/schemas/commands.json\n content/messenger/schemas/pkcs11.json\n'
462
+ );
463
+ mockPool
464
+ .intercept({ path: '/schemas/accounts.json', method: 'GET' })
352
465
  .reply(200, '{ "foo": "foobar" }');
353
- mockPool.intercept({ path: '/schemas/browserAction.json', method: 'GET' })
466
+ mockPool
467
+ .intercept({ path: '/schemas/browserAction.json', method: 'GET' })
354
468
  .reply(200, '{ "bar": "baz" }');
355
469
  const res = await getMailExtSchemaData('https://example.com/');
356
470
  assert.strictEqual(stubInfo.called, false, 'info');
357
471
  stubInfo.restore();
358
- assert.deepEqual(res, [
359
- {
360
- file: 'accounts.json',
361
- schema: {
362
- foo: 'foobar'
472
+ assert.deepEqual(
473
+ res,
474
+ [
475
+ {
476
+ file: 'accounts.json',
477
+ schema: {
478
+ foo: 'foobar'
479
+ }
480
+ },
481
+ {
482
+ file: 'browserAction.json',
483
+ schema: {
484
+ bar: 'baz'
485
+ }
363
486
  }
364
- },
365
- {
366
- file: 'browserAction.json',
367
- schema: {
368
- bar: 'baz'
369
- }
370
- }
371
- ], 'result');
487
+ ],
488
+ 'result'
489
+ );
372
490
  });
373
491
 
374
492
  it('should get array', async () => {
375
493
  const stubInfo = sinon.stub(console, 'info');
376
494
  const url = new URL('https://example.com');
377
495
  const mockPool = mockAgent.get(url.origin);
378
- mockPool.intercept({ path: '/jar.mn', method: 'GET' })
379
- .reply(200, '# comment\n\nmessenger.jar:\n% content/messenger/ext-mail.json\n content/messenger/schemas/accounts.json\n content/messenger/schemas/browserAction.json\n content/messenger/schemas/commands.json\n content/messenger/schemas/pkcs11.json\n');
380
- mockPool.intercept({ path: '/schemas/accounts.json', method: 'GET' })
496
+ mockPool
497
+ .intercept({ path: '/jar.mn', method: 'GET' })
498
+ .reply(
499
+ 200,
500
+ '# comment\n\nmessenger.jar:\n% content/messenger/ext-mail.json\n content/messenger/schemas/accounts.json\n content/messenger/schemas/browserAction.json\n content/messenger/schemas/commands.json\n content/messenger/schemas/pkcs11.json\n'
501
+ );
502
+ mockPool
503
+ .intercept({ path: '/schemas/accounts.json', method: 'GET' })
381
504
  .reply(200, '{ "foo": "foobar" }');
382
- mockPool.intercept({ path: '/schemas/browserAction.json', method: 'GET' })
505
+ mockPool
506
+ .intercept({ path: '/schemas/browserAction.json', method: 'GET' })
383
507
  .reply(200, '{ "bar": "baz" }');
384
508
  const res = await getMailExtSchemaData('https://example.com/', true);
385
509
  assert.strictEqual(stubInfo.called, true, 'info');
386
510
  stubInfo.restore();
387
- assert.deepEqual(res, [
388
- {
389
- file: 'accounts.json',
390
- schema: {
391
- foo: 'foobar'
511
+ assert.deepEqual(
512
+ res,
513
+ [
514
+ {
515
+ file: 'accounts.json',
516
+ schema: {
517
+ foo: 'foobar'
518
+ }
519
+ },
520
+ {
521
+ file: 'browserAction.json',
522
+ schema: {
523
+ bar: 'baz'
524
+ }
392
525
  }
393
- },
394
- {
395
- file: 'browserAction.json',
396
- schema: {
397
- bar: 'baz'
398
- }
399
- }
400
- ], 'result');
526
+ ],
527
+ 'result'
528
+ );
401
529
  });
402
530
  });
403
531
 
404
532
  describe('create unified schema', () => {
533
+ const originalFetch = globalThis.fetch;
405
534
  const globalDispatcher = getGlobalDispatcher();
406
535
  const mockAgent = new MockAgent();
407
536
  beforeEach(() => {
408
537
  setGlobalDispatcher(mockAgent);
409
538
  mockAgent.disableNetConnect();
539
+ globalThis.fetch = undiciFetch;
410
540
  });
411
541
  afterEach(() => {
412
542
  mockAgent.enableNetConnect();
413
543
  setGlobalDispatcher(globalDispatcher);
544
+ globalThis.fetch = originalFetch;
414
545
  });
415
546
 
416
547
  it('should get object', async () => {
417
548
  const stubInfo = sinon.stub(console, 'info');
418
- const url = new URL('https://hg.mozilla.org');
549
+ const url = new URL('https://hg-edge.mozilla.org');
419
550
  const mockPool = mockAgent.get(url.origin);
420
551
  const basePath = '/releases/mozilla-beta/raw-file/tip/';
421
- const browserUrl =
422
- `${url.origin}${basePath}browser/components/extensions/schemas/`;
423
- const toolkitUrl =
424
- `${url.origin}${basePath}toolkit/components/extensions/schemas/`;
425
- mockPool.intercept({ path: `${browserUrl}jar.mn`, method: 'GET' })
426
- .reply(200, 'content/extensions/schemas/foo.json\ncontent/extensions/schemas/bar.json\n');
427
- mockPool.intercept({ path: `${browserUrl}foo.json`, method: 'GET' })
552
+ const browserUrl = `${url.origin}${basePath}browser/components/extensions/schemas/`;
553
+ const toolkitUrl = `${url.origin}${basePath}toolkit/components/extensions/schemas/`;
554
+ mockPool
555
+ .intercept({ path: `${browserUrl}jar.mn`, method: 'GET' })
556
+ .reply(
557
+ 200,
558
+ 'content/extensions/schemas/foo.json\ncontent/extensions/schemas/bar.json\n'
559
+ );
560
+ mockPool
561
+ .intercept({ path: `${browserUrl}foo.json`, method: 'GET' })
428
562
  .reply(200, '{ "foo": "Foo" }');
429
- mockPool.intercept({ path: `${browserUrl}bar.json`, method: 'GET' })
563
+ mockPool
564
+ .intercept({ path: `${browserUrl}bar.json`, method: 'GET' })
430
565
  .reply(200, '{ "bar": "Bar" }');
431
- mockPool.intercept({ path: `${toolkitUrl}jar.mn`, method: 'GET' })
432
- .reply(200, 'content/extensions/schemas/baz.json\ncontent/extensions/schemas/qux.json\n');
433
- mockPool.intercept({ path: `${toolkitUrl}baz.json`, method: 'GET' })
566
+ mockPool
567
+ .intercept({ path: `${toolkitUrl}jar.mn`, method: 'GET' })
568
+ .reply(
569
+ 200,
570
+ 'content/extensions/schemas/baz.json\ncontent/extensions/schemas/qux.json\n'
571
+ );
572
+ mockPool
573
+ .intercept({ path: `${toolkitUrl}baz.json`, method: 'GET' })
434
574
  .reply(200, '{ "baz": "Baz" }');
435
- mockPool.intercept({ path: `${toolkitUrl}qux.json`, method: 'GET' })
575
+ mockPool
576
+ .intercept({ path: `${toolkitUrl}qux.json`, method: 'GET' })
436
577
  .reply(200, '{ "qux": "Qux" }');
437
578
  const res = await createUnifiedSchema();
438
579
  assert.strictEqual(stubInfo.called, false, 'info');
439
580
  stubInfo.restore();
440
- assert.deepEqual(res, {
441
- 'foo.json': {
442
- foo: 'Foo'
443
- },
444
- 'bar.json': {
445
- bar: 'Bar'
446
- },
447
- 'baz.json': {
448
- baz: 'Baz'
581
+ assert.deepEqual(
582
+ res,
583
+ {
584
+ 'foo.json': {
585
+ foo: 'Foo'
586
+ },
587
+ 'bar.json': {
588
+ bar: 'Bar'
589
+ },
590
+ 'baz.json': {
591
+ baz: 'Baz'
592
+ },
593
+ 'qux.json': {
594
+ qux: 'Qux'
595
+ }
449
596
  },
450
- 'qux.json': {
451
- qux: 'Qux'
452
- }
453
- }, 'result');
597
+ 'result'
598
+ );
454
599
  });
455
600
 
456
601
  it('should get object', async () => {
457
602
  const stubInfo = sinon.stub(console, 'info');
458
- const url = new URL('https://hg.mozilla.org');
603
+ const url = new URL('https://hg-edge.mozilla.org');
459
604
  const mockPool = mockAgent.get(url.origin);
460
605
  const basePath = '/mozilla-central/raw-file/tip/';
461
- const browserUrl =
462
- `${url.origin}${basePath}browser/components/extensions/schemas/`;
463
- const toolkitUrl =
464
- `${url.origin}${basePath}toolkit/components/extensions/schemas/`;
465
- mockPool.intercept({ path: `${browserUrl}jar.mn`, method: 'GET' })
466
- .reply(200, 'content/extensions/schemas/foo.json\ncontent/extensions/schemas/bar.json\n');
467
- mockPool.intercept({ path: `${browserUrl}foo.json`, method: 'GET' })
606
+ const browserUrl = `${url.origin}${basePath}browser/components/extensions/schemas/`;
607
+ const toolkitUrl = `${url.origin}${basePath}toolkit/components/extensions/schemas/`;
608
+ mockPool
609
+ .intercept({ path: `${browserUrl}jar.mn`, method: 'GET' })
610
+ .reply(
611
+ 200,
612
+ 'content/extensions/schemas/foo.json\ncontent/extensions/schemas/bar.json\n'
613
+ );
614
+ mockPool
615
+ .intercept({ path: `${browserUrl}foo.json`, method: 'GET' })
468
616
  .reply(200, '{ "foo": "Foo" }');
469
- mockPool.intercept({ path: `${browserUrl}bar.json`, method: 'GET' })
617
+ mockPool
618
+ .intercept({ path: `${browserUrl}bar.json`, method: 'GET' })
470
619
  .reply(200, '{ "bar": "Bar" }');
471
- mockPool.intercept({ path: `${toolkitUrl}jar.mn`, method: 'GET' })
472
- .reply(200, 'content/extensions/schemas/baz.json\ncontent/extensions/schemas/qux.json\n');
473
- mockPool.intercept({ path: `${toolkitUrl}baz.json`, method: 'GET' })
620
+ mockPool
621
+ .intercept({ path: `${toolkitUrl}jar.mn`, method: 'GET' })
622
+ .reply(
623
+ 200,
624
+ 'content/extensions/schemas/baz.json\ncontent/extensions/schemas/qux.json\n'
625
+ );
626
+ mockPool
627
+ .intercept({ path: `${toolkitUrl}baz.json`, method: 'GET' })
474
628
  .reply(200, '{ "baz": "Baz" }');
475
- mockPool.intercept({ path: `${toolkitUrl}qux.json`, method: 'GET' })
629
+ mockPool
630
+ .intercept({ path: `${toolkitUrl}qux.json`, method: 'GET' })
476
631
  .reply(200, '{ "qux": "Qux" }');
477
632
  const res = await createUnifiedSchema('central', true);
478
633
  assert.strictEqual(stubInfo.called, true, 'info');
479
634
  stubInfo.restore();
480
- assert.deepEqual(res, {
481
- 'foo.json': {
482
- foo: 'Foo'
483
- },
484
- 'bar.json': {
485
- bar: 'Bar'
486
- },
487
- 'baz.json': {
488
- baz: 'Baz'
635
+ assert.deepEqual(
636
+ res,
637
+ {
638
+ 'foo.json': {
639
+ foo: 'Foo'
640
+ },
641
+ 'bar.json': {
642
+ bar: 'Bar'
643
+ },
644
+ 'baz.json': {
645
+ baz: 'Baz'
646
+ },
647
+ 'qux.json': {
648
+ qux: 'Qux'
649
+ }
489
650
  },
490
- 'qux.json': {
491
- qux: 'Qux'
492
- }
493
- }, 'result');
651
+ 'result'
652
+ );
494
653
  });
495
654
 
496
655
  it('should get object', async () => {
497
656
  const stubInfo = sinon.stub(console, 'info');
498
- const url = new URL('https://hg.mozilla.org');
657
+ const url = new URL('https://hg-edge.mozilla.org');
499
658
  const mockPool = mockAgent.get(url.origin);
500
659
  const basePath = '/mozilla-central/raw-file/tip/';
501
660
  const mailBasePath = '/comm-central/raw-file/tip/';
502
- const browserUrl =
503
- `${url.origin}${basePath}browser/components/extensions/schemas/`;
504
- const toolkitUrl =
505
- `${url.origin}${basePath}toolkit/components/extensions/schemas/`;
506
- const mailBaseUrl =
507
- `${url.origin}${mailBasePath}mail/components/extensions/`;
661
+ const browserUrl = `${url.origin}${basePath}browser/components/extensions/schemas/`;
662
+ const toolkitUrl = `${url.origin}${basePath}toolkit/components/extensions/schemas/`;
663
+ const mailBaseUrl = `${url.origin}${mailBasePath}mail/components/extensions/`;
508
664
  const mailUrl = `${mailBaseUrl}schemas/`;
509
- mockPool.intercept({ path: `${browserUrl}commands.json`, method: 'GET' })
665
+ mockPool
666
+ .intercept({ path: `${browserUrl}commands.json`, method: 'GET' })
510
667
  .reply(200, '{ "commands": "Commands" }');
511
- mockPool.intercept({ path: `${browserUrl}pkcs11.json`, method: 'GET' })
668
+ mockPool
669
+ .intercept({ path: `${browserUrl}pkcs11.json`, method: 'GET' })
512
670
  .reply(200, '{ "pkcs11": "Pkcs11" }');
513
- mockPool.intercept({
514
- path: `${toolkitUrl}content_scripts.json`,
515
- method: 'GET'
516
- }).reply(200, '{ "content_scripts": "ContentScripts" }');
517
- mockPool.intercept({ path: `${toolkitUrl}experiments.json`, method: 'GET' })
671
+ mockPool
672
+ .intercept({
673
+ path: `${toolkitUrl}content_scripts.json`,
674
+ method: 'GET'
675
+ })
676
+ .reply(200, '{ "content_scripts": "ContentScripts" }');
677
+ mockPool
678
+ .intercept({ path: `${toolkitUrl}experiments.json`, method: 'GET' })
518
679
  .reply(200, '{ "experiments": "Experiments" }');
519
- mockPool.intercept({ path: `${toolkitUrl}extension.json`, method: 'GET' })
680
+ mockPool
681
+ .intercept({ path: `${toolkitUrl}extension.json`, method: 'GET' })
520
682
  .reply(200, '{ "extension": "Extension" }');
521
- mockPool.intercept({ path: `${toolkitUrl}i18n.json`, method: 'GET' })
683
+ mockPool
684
+ .intercept({ path: `${toolkitUrl}i18n.json`, method: 'GET' })
522
685
  .reply(200, '{ "i18n": "I18n" }');
523
- mockPool.intercept({ path: `${toolkitUrl}management.json`, method: 'GET' })
686
+ mockPool
687
+ .intercept({ path: `${toolkitUrl}management.json`, method: 'GET' })
524
688
  .reply(200, '{ "management": "Management" }');
525
- mockPool.intercept({ path: `${toolkitUrl}permissions.json`, method: 'GET' })
689
+ mockPool
690
+ .intercept({ path: `${toolkitUrl}permissions.json`, method: 'GET' })
526
691
  .reply(200, '{ "permissions": "Permissions" }');
527
- mockPool.intercept({ path: `${toolkitUrl}runtime.json`, method: 'GET' })
692
+ mockPool
693
+ .intercept({ path: `${toolkitUrl}runtime.json`, method: 'GET' })
528
694
  .reply(200, '{ "runtime": "Runtime" }');
529
- mockPool.intercept({ path: `${toolkitUrl}theme.json`, method: 'GET' })
695
+ mockPool
696
+ .intercept({ path: `${toolkitUrl}theme.json`, method: 'GET' })
530
697
  .reply(200, '{ "theme": "Theme" }');
531
- mockPool.intercept({ path: `${mailBaseUrl}jar.mn`, method: 'GET' })
532
- .reply(200, 'content/extensions/schemas/foo.json\ncontent/extensions/schemas/bar.json\n');
533
- mockPool.intercept({ path: `${mailUrl}foo.json`, method: 'GET' })
698
+ mockPool
699
+ .intercept({ path: `${mailBaseUrl}jar.mn`, method: 'GET' })
700
+ .reply(
701
+ 200,
702
+ 'content/extensions/schemas/foo.json\ncontent/extensions/schemas/bar.json\n'
703
+ );
704
+ mockPool
705
+ .intercept({ path: `${mailUrl}foo.json`, method: 'GET' })
534
706
  .reply(200, '{ "foo": "Foo" }');
535
- mockPool.intercept({ path: `${mailUrl}bar.json`, method: 'GET' })
707
+ mockPool
708
+ .intercept({ path: `${mailUrl}bar.json`, method: 'GET' })
536
709
  .reply(200, '{ "bar": "Bar" }');
537
710
  const res = await createUnifiedSchema('mail', true);
538
711
  assert.strictEqual(stubInfo.called, true, 'info');
539
712
  stubInfo.restore();
540
- assert.deepEqual(res, {
541
- 'commands.json': {
542
- commands: 'Commands'
543
- },
544
- 'pkcs11.json': {
545
- pkcs11: 'Pkcs11'
546
- },
547
- 'content_scripts.json': {
548
- content_scripts: 'ContentScripts'
549
- },
550
- 'experiments.json': {
551
- experiments: 'Experiments'
552
- },
553
- 'extension.json': {
554
- extension: 'Extension'
555
- },
556
- 'i18n.json': {
557
- i18n: 'I18n'
558
- },
559
- 'management.json': {
560
- management: 'Management'
561
- },
562
- 'permissions.json': {
563
- permissions: 'Permissions'
564
- },
565
- 'runtime.json': {
566
- runtime: 'Runtime'
567
- },
568
- 'theme.json': {
569
- theme: 'Theme'
570
- },
571
- 'foo.json': {
572
- foo: 'Foo'
713
+ assert.deepEqual(
714
+ res,
715
+ {
716
+ 'commands.json': {
717
+ commands: 'Commands'
718
+ },
719
+ 'pkcs11.json': {
720
+ pkcs11: 'Pkcs11'
721
+ },
722
+ 'content_scripts.json': {
723
+ content_scripts: 'ContentScripts'
724
+ },
725
+ 'experiments.json': {
726
+ experiments: 'Experiments'
727
+ },
728
+ 'extension.json': {
729
+ extension: 'Extension'
730
+ },
731
+ 'i18n.json': {
732
+ i18n: 'I18n'
733
+ },
734
+ 'management.json': {
735
+ management: 'Management'
736
+ },
737
+ 'permissions.json': {
738
+ permissions: 'Permissions'
739
+ },
740
+ 'runtime.json': {
741
+ runtime: 'Runtime'
742
+ },
743
+ 'theme.json': {
744
+ theme: 'Theme'
745
+ },
746
+ 'foo.json': {
747
+ foo: 'Foo'
748
+ },
749
+ 'bar.json': {
750
+ bar: 'Bar'
751
+ }
573
752
  },
574
- 'bar.json': {
575
- bar: 'Bar'
576
- }
577
- }, 'result');
753
+ 'result'
754
+ );
578
755
  });
579
756
  });
580
757
 
581
758
  describe('save schema file', () => {
759
+ const originalFetch = globalThis.fetch;
582
760
  const globalDispatcher = getGlobalDispatcher();
583
761
  const mockAgent = new MockAgent();
584
762
  beforeEach(() => {
585
763
  setGlobalDispatcher(mockAgent);
586
764
  mockAgent.disableNetConnect();
765
+ globalThis.fetch = undiciFetch;
587
766
  });
588
767
  afterEach(() => {
589
768
  mockAgent.enableNetConnect();
590
769
  setGlobalDispatcher(globalDispatcher);
770
+ globalThis.fetch = originalFetch;
591
771
  });
592
772
 
593
773
  it('should throw', async () => {
594
774
  await saveSchemaFile().catch(e => {
595
- assert.deepStrictEqual(e,
596
- new TypeError('Expected String but got Undefined.'));
775
+ assert.deepStrictEqual(
776
+ e,
777
+ new TypeError('Expected String but got Undefined.')
778
+ );
597
779
  });
598
780
  });
599
781
 
600
782
  it('should create file', async () => {
601
- const url = new URL('https://hg.mozilla.org/mozilla-central/raw-file/tip/');
783
+ const url = new URL(
784
+ 'https://hg-edge.mozilla.org/mozilla-central/raw-file/tip/'
785
+ );
602
786
  const mockPool = mockAgent.get(url.origin);
603
- const browserItems = [
604
- 'commands.json',
605
- 'pkcs11.json'
606
- ];
787
+ const browserItems = ['commands.json', 'pkcs11.json'];
607
788
  for (const item of browserItems) {
608
- mockPool.intercept({
609
- path: `${url.pathname}browser/components/extensions/schemas/${item}`,
610
- method: 'GET'
611
- }).reply(200, `{ "browser": "${item}" }`);
789
+ mockPool
790
+ .intercept({
791
+ path: `${url.pathname}browser/components/extensions/schemas/${item}`,
792
+ method: 'GET'
793
+ })
794
+ .reply(200, `{ "browser": "${item}" }`);
612
795
  }
613
796
  const toolkitItems = [
614
- 'content_scripts.json', 'experiments.json', 'extension.json', 'i18n.json',
615
- 'management.json', 'permissions.json', 'runtime.json', 'theme.json'
797
+ 'content_scripts.json',
798
+ 'experiments.json',
799
+ 'extension.json',
800
+ 'i18n.json',
801
+ 'management.json',
802
+ 'permissions.json',
803
+ 'runtime.json',
804
+ 'theme.json'
616
805
  ];
617
806
  for (const item of toolkitItems) {
618
- mockPool.intercept({
619
- path: `${url.pathname}toolkit/components/extensions/schemas/${item}`,
620
- method: 'GET'
621
- }).reply(200, `{ "toolkit": "${item}" }`);
807
+ mockPool
808
+ .intercept({
809
+ path: `${url.pathname}toolkit/components/extensions/schemas/${item}`,
810
+ method: 'GET'
811
+ })
812
+ .reply(200, `{ "toolkit": "${item}" }`);
622
813
  }
623
- mockPool.intercept({
624
- path: '/comm-central/raw-file/tip/mail/components/extensions/jar.mn',
625
- method: 'GET'
626
- }).reply(200, '# comment\n\nmessenger.jar:\n% content/messenger/ext-mail.json\n content/messenger/schemas/accounts.json\n');
627
- mockPool.intercept({
628
- path: '/comm-central/raw-file/tip/mail/components/extensions/schemas/accounts.json',
629
- method: 'GET'
630
- }).reply(200, '{ "mail": "accounts.json" }');
814
+ mockPool
815
+ .intercept({
816
+ path: '/comm-central/raw-file/tip/mail/components/extensions/jar.mn',
817
+ method: 'GET'
818
+ })
819
+ .reply(
820
+ 200,
821
+ '# comment\n\nmessenger.jar:\n% content/messenger/ext-mail.json\n content/messenger/schemas/accounts.json\n'
822
+ );
823
+ mockPool
824
+ .intercept({
825
+ path: '/comm-central/raw-file/tip/mail/components/extensions/schemas/accounts.json',
826
+ method: 'GET'
827
+ })
828
+ .reply(200, '{ "mail": "accounts.json" }');
631
829
  const stubWrite = sinon.stub(fs.promises, 'writeFile');
632
830
  const stubInfo = sinon.stub(console, 'info');
633
831
  const i = stubWrite.callCount;
634
832
  const j = stubInfo.callCount;
635
- const filePath =
636
- path.join(process.cwd(), 'schemas', 'mail', 'mailext.json');
833
+ const filePath = path.join(
834
+ process.cwd(),
835
+ 'schemas',
836
+ 'mail',
837
+ 'mailext.json'
838
+ );
637
839
  const res = await saveSchemaFile('mail');
638
840
  const { callCount: writeCallCount } = stubWrite;
639
841
  const { callCount: infoCallCount } = stubInfo;
@@ -645,42 +847,62 @@ describe('save schema file', () => {
645
847
  });
646
848
 
647
849
  it('should create file', async () => {
648
- const url = new URL('https://hg.mozilla.org/mozilla-central/raw-file/tip/');
850
+ const url = new URL(
851
+ 'https://hg-edge.mozilla.org/mozilla-central/raw-file/tip/'
852
+ );
649
853
  const mockPool = mockAgent.get(url.origin);
650
- const browserItems = [
651
- 'commands.json',
652
- 'pkcs11.json'
653
- ];
854
+ const browserItems = ['commands.json', 'pkcs11.json'];
654
855
  for (const item of browserItems) {
655
- mockPool.intercept({
656
- path: `${url.pathname}browser/components/extensions/schemas/${item}`,
657
- method: 'GET'
658
- }).reply(200, `{ "browser": "${item}" }`);
856
+ mockPool
857
+ .intercept({
858
+ path: `${url.pathname}browser/components/extensions/schemas/${item}`,
859
+ method: 'GET'
860
+ })
861
+ .reply(200, `{ "browser": "${item}" }`);
659
862
  }
660
863
  const toolkitItems = [
661
- 'content_scripts.json', 'experiments.json', 'extension.json', 'i18n.json',
662
- 'management.json', 'permissions.json', 'runtime.json', 'theme.json'
864
+ 'content_scripts.json',
865
+ 'experiments.json',
866
+ 'extension.json',
867
+ 'i18n.json',
868
+ 'management.json',
869
+ 'permissions.json',
870
+ 'runtime.json',
871
+ 'theme.json'
663
872
  ];
664
873
  for (const item of toolkitItems) {
665
- mockPool.intercept({
666
- path: `${url.pathname}toolkit/components/extensions/schemas/${item}`,
667
- method: 'GET'
668
- }).reply(200, `{ "toolkit": "${item}" }`);
874
+ mockPool
875
+ .intercept({
876
+ path: `${url.pathname}toolkit/components/extensions/schemas/${item}`,
877
+ method: 'GET'
878
+ })
879
+ .reply(200, `{ "toolkit": "${item}" }`);
669
880
  }
670
- mockPool.intercept({
671
- path: '/comm-central/raw-file/tip/mail/components/extensions/jar.mn',
672
- method: 'GET'
673
- }).reply(200, '# comment\n\nmessenger.jar:\n% content/messenger/ext-mail.json\n content/messenger/schemas/accounts.json\n');
674
- mockPool.intercept({
675
- path: '/comm-central/raw-file/tip/mail/components/extensions/schemas/accounts.json',
676
- method: 'GET'
677
- }).reply(200, '{ "mail": "accounts.json" }');
881
+ mockPool
882
+ .intercept({
883
+ path: '/comm-central/raw-file/tip/mail/components/extensions/jar.mn',
884
+ method: 'GET'
885
+ })
886
+ .reply(
887
+ 200,
888
+ '# comment\n\nmessenger.jar:\n% content/messenger/ext-mail.json\n content/messenger/schemas/accounts.json\n'
889
+ );
890
+ mockPool
891
+ .intercept({
892
+ path: '/comm-central/raw-file/tip/mail/components/extensions/schemas/accounts.json',
893
+ method: 'GET'
894
+ })
895
+ .reply(200, '{ "mail": "accounts.json" }');
678
896
  const stubWrite = sinon.stub(fs.promises, 'writeFile');
679
897
  const stubInfo = sinon.stub(console, 'info');
680
898
  const i = stubWrite.callCount;
681
899
  const j = stubInfo.callCount;
682
- const filePath =
683
- path.join(process.cwd(), 'schemas', 'mail', 'mailext.json');
900
+ const filePath = path.join(
901
+ process.cwd(),
902
+ 'schemas',
903
+ 'mail',
904
+ 'mailext.json'
905
+ );
684
906
  const res = await saveSchemaFile('mail', true);
685
907
  const { callCount: writeCallCount } = stubWrite;
686
908
  const { callCount: infoCallCount } = stubInfo;
@@ -692,39 +914,57 @@ describe('save schema file', () => {
692
914
  });
693
915
 
694
916
  it('should create file', async () => {
695
- const url =
696
- new URL('https://hg.mozilla.org/releases/mozilla-beta/raw-file/tip/');
917
+ const url = new URL(
918
+ 'https://hg-edge.mozilla.org/releases/mozilla-beta/raw-file/tip/'
919
+ );
697
920
  const mockPool = mockAgent.get(url.origin);
698
- mockPool.intercept({
699
- path: `${url.pathname}browser/components/extensions/schemas/jar.mn`,
700
- method: 'GET'
701
- }).reply(200, 'content/extensions/schemas/foo.json\ncontent/extensions/schemas/bar.json\n');
702
- mockPool.intercept({
703
- path: `${url.pathname}browser/components/extensions/schemas/foo.json`,
704
- method: 'GET'
705
- }).reply(200, '{ "browser": "foo.json" }');
706
- mockPool.intercept({
707
- path: `${url.pathname}browser/components/extensions/schemas/bar.json`,
708
- method: 'GET'
709
- }).reply(200, '{ "browser": "bar.json" }');
710
- mockPool.intercept({
711
- path: `${url.pathname}toolkit/components/extensions/schemas/jar.mn`,
712
- method: 'GET'
713
- }).reply(200, 'content/extensions/schemas/baz.json\ncontent/extensions/schemas/qux.json\n');
714
- mockPool.intercept({
715
- path: `${url.pathname}toolkit/components/extensions/schemas/baz.json`,
716
- method: 'GET'
717
- }).reply(200, '{ "toolkit": "baz.json" }');
718
- mockPool.intercept({
719
- path: `${url.pathname}toolkit/components/extensions/schemas/qux.json`,
720
- method: 'GET'
721
- }).reply(200, '{ "toolkit": "qux.json" }');
921
+ mockPool
922
+ .intercept({
923
+ path: `${url.pathname}browser/components/extensions/schemas/jar.mn`,
924
+ method: 'GET'
925
+ })
926
+ .reply(
927
+ 200,
928
+ 'content/extensions/schemas/foo.json\ncontent/extensions/schemas/bar.json\n'
929
+ );
930
+ mockPool
931
+ .intercept({
932
+ path: `${url.pathname}browser/components/extensions/schemas/foo.json`,
933
+ method: 'GET'
934
+ })
935
+ .reply(200, '{ "browser": "foo.json" }');
936
+ mockPool
937
+ .intercept({
938
+ path: `${url.pathname}browser/components/extensions/schemas/bar.json`,
939
+ method: 'GET'
940
+ })
941
+ .reply(200, '{ "browser": "bar.json" }');
942
+ mockPool
943
+ .intercept({
944
+ path: `${url.pathname}toolkit/components/extensions/schemas/jar.mn`,
945
+ method: 'GET'
946
+ })
947
+ .reply(
948
+ 200,
949
+ 'content/extensions/schemas/baz.json\ncontent/extensions/schemas/qux.json\n'
950
+ );
951
+ mockPool
952
+ .intercept({
953
+ path: `${url.pathname}toolkit/components/extensions/schemas/baz.json`,
954
+ method: 'GET'
955
+ })
956
+ .reply(200, '{ "toolkit": "baz.json" }');
957
+ mockPool
958
+ .intercept({
959
+ path: `${url.pathname}toolkit/components/extensions/schemas/qux.json`,
960
+ method: 'GET'
961
+ })
962
+ .reply(200, '{ "toolkit": "qux.json" }');
722
963
  const stubWrite = sinon.stub(fs.promises, 'writeFile');
723
964
  const stubInfo = sinon.stub(console, 'info');
724
965
  const i = stubWrite.callCount;
725
966
  const j = stubInfo.callCount;
726
- const filePath =
727
- path.join(process.cwd(), 'schemas', 'beta', 'webext.json');
967
+ const filePath = path.join(process.cwd(), 'schemas', 'beta', 'webext.json');
728
968
  const res = await saveSchemaFile('beta');
729
969
  const { callCount: writeCallCount } = stubWrite;
730
970
  const { callCount: infoCallCount } = stubInfo;
@@ -736,39 +976,57 @@ describe('save schema file', () => {
736
976
  });
737
977
 
738
978
  it('should create file', async () => {
739
- const url =
740
- new URL('https://hg.mozilla.org/releases/mozilla-beta/raw-file/tip/');
979
+ const url = new URL(
980
+ 'https://hg-edge.mozilla.org/releases/mozilla-beta/raw-file/tip/'
981
+ );
741
982
  const mockPool = mockAgent.get(url.origin);
742
- mockPool.intercept({
743
- path: `${url.pathname}browser/components/extensions/schemas/jar.mn`,
744
- method: 'GET'
745
- }).reply(200, 'content/extensions/schemas/foo.json\ncontent/extensions/schemas/bar.json\n');
746
- mockPool.intercept({
747
- path: `${url.pathname}browser/components/extensions/schemas/foo.json`,
748
- method: 'GET'
749
- }).reply(200, '{ "browser": "foo.json" }');
750
- mockPool.intercept({
751
- path: `${url.pathname}browser/components/extensions/schemas/bar.json`,
752
- method: 'GET'
753
- }).reply(200, '{ "browser": "bar.json" }');
754
- mockPool.intercept({
755
- path: `${url.pathname}toolkit/components/extensions/schemas/jar.mn`,
756
- method: 'GET'
757
- }).reply(200, 'content/extensions/schemas/baz.json\ncontent/extensions/schemas/qux.json\n');
758
- mockPool.intercept({
759
- path: `${url.pathname}toolkit/components/extensions/schemas/baz.json`,
760
- method: 'GET'
761
- }).reply(200, '{ "toolkit": "baz.json" }');
762
- mockPool.intercept({
763
- path: `${url.pathname}toolkit/components/extensions/schemas/qux.json`,
764
- method: 'GET'
765
- }).reply(200, '{ "toolkit": "qux.json" }');
983
+ mockPool
984
+ .intercept({
985
+ path: `${url.pathname}browser/components/extensions/schemas/jar.mn`,
986
+ method: 'GET'
987
+ })
988
+ .reply(
989
+ 200,
990
+ 'content/extensions/schemas/foo.json\ncontent/extensions/schemas/bar.json\n'
991
+ );
992
+ mockPool
993
+ .intercept({
994
+ path: `${url.pathname}browser/components/extensions/schemas/foo.json`,
995
+ method: 'GET'
996
+ })
997
+ .reply(200, '{ "browser": "foo.json" }');
998
+ mockPool
999
+ .intercept({
1000
+ path: `${url.pathname}browser/components/extensions/schemas/bar.json`,
1001
+ method: 'GET'
1002
+ })
1003
+ .reply(200, '{ "browser": "bar.json" }');
1004
+ mockPool
1005
+ .intercept({
1006
+ path: `${url.pathname}toolkit/components/extensions/schemas/jar.mn`,
1007
+ method: 'GET'
1008
+ })
1009
+ .reply(
1010
+ 200,
1011
+ 'content/extensions/schemas/baz.json\ncontent/extensions/schemas/qux.json\n'
1012
+ );
1013
+ mockPool
1014
+ .intercept({
1015
+ path: `${url.pathname}toolkit/components/extensions/schemas/baz.json`,
1016
+ method: 'GET'
1017
+ })
1018
+ .reply(200, '{ "toolkit": "baz.json" }');
1019
+ mockPool
1020
+ .intercept({
1021
+ path: `${url.pathname}toolkit/components/extensions/schemas/qux.json`,
1022
+ method: 'GET'
1023
+ })
1024
+ .reply(200, '{ "toolkit": "qux.json" }');
766
1025
  const stubWrite = sinon.stub(fs.promises, 'writeFile');
767
1026
  const stubInfo = sinon.stub(console, 'info');
768
1027
  const i = stubWrite.callCount;
769
1028
  const j = stubInfo.callCount;
770
- const filePath =
771
- path.join(process.cwd(), 'schemas', 'beta', 'webext.json');
1029
+ const filePath = path.join(process.cwd(), 'schemas', 'beta', 'webext.json');
772
1030
  const res = await saveSchemaFile('beta', true);
773
1031
  const { callCount: writeCallCount } = stubWrite;
774
1032
  const { callCount: infoCallCount } = stubInfo;
@@ -781,77 +1039,111 @@ describe('save schema file', () => {
781
1039
  });
782
1040
 
783
1041
  describe('update schemas files', () => {
1042
+ const originalFetch = globalThis.fetch;
784
1043
  const globalDispatcher = getGlobalDispatcher();
785
1044
  const mockAgent = new MockAgent();
786
1045
  beforeEach(() => {
787
1046
  setGlobalDispatcher(mockAgent);
788
1047
  mockAgent.disableNetConnect();
1048
+ globalThis.fetch = undiciFetch;
789
1049
  });
790
1050
  afterEach(() => {
791
1051
  mockAgent.enableNetConnect();
792
1052
  setGlobalDispatcher(globalDispatcher);
1053
+ globalThis.fetch = originalFetch;
793
1054
  });
794
1055
 
795
1056
  it('should not call function', async () => {
796
- const url = new URL('https://hg.mozilla.org/mozilla-central/raw-file/tip/');
1057
+ const url = new URL(
1058
+ 'https://hg-edge.mozilla.org/mozilla-central/raw-file/tip/'
1059
+ );
797
1060
  const centralPath = url.pathname;
798
1061
  const betaPath = '/releases/mozilla-beta/raw-file/tip/';
799
1062
  const mailPath = '/comm-central/raw-file/tip/';
800
1063
  const mockPool = mockAgent.get(url.origin);
801
1064
  for (const item of [centralPath, betaPath]) {
802
- mockPool.intercept({
803
- path: `${item}browser/components/extensions/schemas/jar.mn`,
804
- method: 'GET'
805
- }).reply(200, 'content/extensions/schemas/foo.json\ncontent/extensions/schemas/bar.json\n');
806
- mockPool.intercept({
807
- path: `${item}browser/components/extensions/schemas/foo.json`,
808
- method: 'GET'
809
- }).reply(200, '{ "browser": "foo.json" }');
810
- mockPool.intercept({
811
- path: `${item}browser/components/extensions/schemas/bar.json`,
812
- method: 'GET'
813
- }).reply(200, '{ "browser": "bar.json" }');
814
- mockPool.intercept({
815
- path: `${item}toolkit/components/extensions/schemas/jar.mn`,
816
- method: 'GET'
817
- }).reply(200, 'content/extensions/schemas/baz.json\ncontent/extensions/schemas/qux.json\n');
818
- mockPool.intercept({
819
- path: `${item}toolkit/components/extensions/schemas/baz.json`,
820
- method: 'GET'
821
- }).reply(200, '{ "toolkit": "baz.json" }');
822
- mockPool.intercept({
823
- path: `${item}toolkit/components/extensions/schemas/qux.json`,
824
- method: 'GET'
825
- }).reply(200, '{ "toolkit": "qux.json" }');
1065
+ mockPool
1066
+ .intercept({
1067
+ path: `${item}browser/components/extensions/schemas/jar.mn`,
1068
+ method: 'GET'
1069
+ })
1070
+ .reply(
1071
+ 200,
1072
+ 'content/extensions/schemas/foo.json\ncontent/extensions/schemas/bar.json\n'
1073
+ );
1074
+ mockPool
1075
+ .intercept({
1076
+ path: `${item}browser/components/extensions/schemas/foo.json`,
1077
+ method: 'GET'
1078
+ })
1079
+ .reply(200, '{ "browser": "foo.json" }');
1080
+ mockPool
1081
+ .intercept({
1082
+ path: `${item}browser/components/extensions/schemas/bar.json`,
1083
+ method: 'GET'
1084
+ })
1085
+ .reply(200, '{ "browser": "bar.json" }');
1086
+ mockPool
1087
+ .intercept({
1088
+ path: `${item}toolkit/components/extensions/schemas/jar.mn`,
1089
+ method: 'GET'
1090
+ })
1091
+ .reply(
1092
+ 200,
1093
+ 'content/extensions/schemas/baz.json\ncontent/extensions/schemas/qux.json\n'
1094
+ );
1095
+ mockPool
1096
+ .intercept({
1097
+ path: `${item}toolkit/components/extensions/schemas/baz.json`,
1098
+ method: 'GET'
1099
+ })
1100
+ .reply(200, '{ "toolkit": "baz.json" }');
1101
+ mockPool
1102
+ .intercept({
1103
+ path: `${item}toolkit/components/extensions/schemas/qux.json`,
1104
+ method: 'GET'
1105
+ })
1106
+ .reply(200, '{ "toolkit": "qux.json" }');
826
1107
  }
827
- const browserItems = [
828
- 'commands.json',
829
- 'pkcs11.json'
830
- ];
1108
+ const browserItems = ['commands.json', 'pkcs11.json'];
831
1109
  for (const item of browserItems) {
832
- mockPool.intercept({
833
- path: `${centralPath}browser/components/extensions/schemas/${item}`,
834
- method: 'GET'
835
- }).reply(200, `{ "browser": "${item}" }`);
1110
+ mockPool
1111
+ .intercept({
1112
+ path: `${centralPath}browser/components/extensions/schemas/${item}`,
1113
+ method: 'GET'
1114
+ })
1115
+ .reply(200, `{ "browser": "${item}" }`);
836
1116
  }
837
1117
  const toolkitItems = [
838
- 'content_scripts.json', 'experiments.json', 'extension.json', 'i18n.json',
839
- 'management.json', 'permissions.json', 'runtime.json', 'theme.json'
1118
+ 'content_scripts.json',
1119
+ 'experiments.json',
1120
+ 'extension.json',
1121
+ 'i18n.json',
1122
+ 'management.json',
1123
+ 'permissions.json',
1124
+ 'runtime.json',
1125
+ 'theme.json'
840
1126
  ];
841
1127
  for (const item of toolkitItems) {
842
- mockPool.intercept({
843
- path: `${centralPath}toolkit/components/extensions/schemas/${item}`,
844
- method: 'GET'
845
- }).reply(200, `{ "toolkit": "${item}" }`);
1128
+ mockPool
1129
+ .intercept({
1130
+ path: `${centralPath}toolkit/components/extensions/schemas/${item}`,
1131
+ method: 'GET'
1132
+ })
1133
+ .reply(200, `{ "toolkit": "${item}" }`);
846
1134
  }
847
- mockPool.intercept({
848
- path: `${mailPath}mail/components/extensions/jar.mn`,
849
- method: 'GET'
850
- }).reply(200, 'content/messenger/schemas/quux.json\n');
851
- mockPool.intercept({
852
- path: `${mailPath}mail/components/extensions/schemas/quux.json`,
853
- method: 'GET'
854
- }).reply(200, '{ "mail": "quux.json" }');
1135
+ mockPool
1136
+ .intercept({
1137
+ path: `${mailPath}mail/components/extensions/jar.mn`,
1138
+ method: 'GET'
1139
+ })
1140
+ .reply(200, 'content/messenger/schemas/quux.json\n');
1141
+ mockPool
1142
+ .intercept({
1143
+ path: `${mailPath}mail/components/extensions/schemas/quux.json`,
1144
+ method: 'GET'
1145
+ })
1146
+ .reply(200, '{ "mail": "quux.json" }');
855
1147
  const stubWrite = sinon.stub(fs.promises, 'writeFile');
856
1148
  const stubTrace = sinon.stub(console, 'trace');
857
1149
  const i = stubTrace.callCount;
@@ -865,65 +1157,96 @@ describe('update schemas files', () => {
865
1157
  });
866
1158
 
867
1159
  it('should not call function', async () => {
868
- const url = new URL('https://hg.mozilla.org/mozilla-central/raw-file/tip/');
1160
+ const url = new URL(
1161
+ 'https://hg-edge.mozilla.org/mozilla-central/raw-file/tip/'
1162
+ );
869
1163
  const centralPath = url.pathname;
870
1164
  const betaPath = '/releases/mozilla-beta/raw-file/tip/';
871
1165
  const mailPath = '/comm-central/raw-file/tip/';
872
1166
  const mockPool = mockAgent.get(url.origin);
873
1167
  for (const item of [centralPath, betaPath]) {
874
- mockPool.intercept({
875
- path: `${item}browser/components/extensions/schemas/jar.mn`,
876
- method: 'GET'
877
- }).reply(200, 'content/extensions/schemas/foo.json\ncontent/extensions/schemas/bar.json\n');
878
- mockPool.intercept({
879
- path: `${item}browser/components/extensions/schemas/foo.json`,
880
- method: 'GET'
881
- }).reply(200, '{ "browser": "foo.json" }');
882
- mockPool.intercept({
883
- path: `${item}browser/components/extensions/schemas/bar.json`,
884
- method: 'GET'
885
- }).reply(200, '{ "browser": "bar.json" }');
886
- mockPool.intercept({
887
- path: `${item}toolkit/components/extensions/schemas/jar.mn`,
888
- method: 'GET'
889
- }).reply(200, 'content/extensions/schemas/baz.json\ncontent/extensions/schemas/qux.json\n');
890
- mockPool.intercept({
891
- path: `${item}toolkit/components/extensions/schemas/baz.json`,
892
- method: 'GET'
893
- }).reply(200, '{ "toolkit": "baz.json" }');
894
- mockPool.intercept({
895
- path: `${item}toolkit/components/extensions/schemas/qux.json`,
896
- method: 'GET'
897
- }).reply(200, '{ "toolkit": "qux.json" }');
1168
+ mockPool
1169
+ .intercept({
1170
+ path: `${item}browser/components/extensions/schemas/jar.mn`,
1171
+ method: 'GET'
1172
+ })
1173
+ .reply(
1174
+ 200,
1175
+ 'content/extensions/schemas/foo.json\ncontent/extensions/schemas/bar.json\n'
1176
+ );
1177
+ mockPool
1178
+ .intercept({
1179
+ path: `${item}browser/components/extensions/schemas/foo.json`,
1180
+ method: 'GET'
1181
+ })
1182
+ .reply(200, '{ "browser": "foo.json" }');
1183
+ mockPool
1184
+ .intercept({
1185
+ path: `${item}browser/components/extensions/schemas/bar.json`,
1186
+ method: 'GET'
1187
+ })
1188
+ .reply(200, '{ "browser": "bar.json" }');
1189
+ mockPool
1190
+ .intercept({
1191
+ path: `${item}toolkit/components/extensions/schemas/jar.mn`,
1192
+ method: 'GET'
1193
+ })
1194
+ .reply(
1195
+ 200,
1196
+ 'content/extensions/schemas/baz.json\ncontent/extensions/schemas/qux.json\n'
1197
+ );
1198
+ mockPool
1199
+ .intercept({
1200
+ path: `${item}toolkit/components/extensions/schemas/baz.json`,
1201
+ method: 'GET'
1202
+ })
1203
+ .reply(200, '{ "toolkit": "baz.json" }');
1204
+ mockPool
1205
+ .intercept({
1206
+ path: `${item}toolkit/components/extensions/schemas/qux.json`,
1207
+ method: 'GET'
1208
+ })
1209
+ .reply(200, '{ "toolkit": "qux.json" }');
898
1210
  }
899
- const browserItems = [
900
- 'commands.json',
901
- 'pkcs11.json'
902
- ];
1211
+ const browserItems = ['commands.json', 'pkcs11.json'];
903
1212
  for (const item of browserItems) {
904
- mockPool.intercept({
905
- path: `${centralPath}browser/components/extensions/schemas/${item}`,
906
- method: 'GET'
907
- }).reply(200, `{ "browser": "${item}" }`);
1213
+ mockPool
1214
+ .intercept({
1215
+ path: `${centralPath}browser/components/extensions/schemas/${item}`,
1216
+ method: 'GET'
1217
+ })
1218
+ .reply(200, `{ "browser": "${item}" }`);
908
1219
  }
909
1220
  const toolkitItems = [
910
- 'content_scripts.json', 'experiments.json', 'extension.json', 'i18n.json',
911
- 'management.json', 'permissions.json', 'runtime.json', 'theme.json'
1221
+ 'content_scripts.json',
1222
+ 'experiments.json',
1223
+ 'extension.json',
1224
+ 'i18n.json',
1225
+ 'management.json',
1226
+ 'permissions.json',
1227
+ 'runtime.json',
1228
+ 'theme.json'
912
1229
  ];
913
1230
  for (const item of toolkitItems) {
914
- mockPool.intercept({
915
- path: `${centralPath}toolkit/components/extensions/schemas/${item}`,
916
- method: 'GET'
917
- }).reply(200, `{ "toolkit": "${item}" }`);
1231
+ mockPool
1232
+ .intercept({
1233
+ path: `${centralPath}toolkit/components/extensions/schemas/${item}`,
1234
+ method: 'GET'
1235
+ })
1236
+ .reply(200, `{ "toolkit": "${item}" }`);
918
1237
  }
919
- mockPool.intercept({
920
- path: `${mailPath}mail/components/extensions/jar.mn`,
921
- method: 'GET'
922
- }).reply(200, 'content/messenger/schemas/quux.json\n');
923
- mockPool.intercept({
924
- path: `${mailPath}mail/components/extensions/schemas/quux.json`,
925
- method: 'GET'
926
- }).reply(400, '{ "ok": false, "status": 400 }');
1238
+ mockPool
1239
+ .intercept({
1240
+ path: `${mailPath}mail/components/extensions/jar.mn`,
1241
+ method: 'GET'
1242
+ })
1243
+ .reply(200, 'content/messenger/schemas/quux.json\n');
1244
+ mockPool
1245
+ .intercept({
1246
+ path: `${mailPath}mail/components/extensions/schemas/quux.json`,
1247
+ method: 'GET'
1248
+ })
1249
+ .reply(400, '{ "ok": false, "status": 400 }');
927
1250
  const stubWrite = sinon.stub(fs.promises, 'writeFile');
928
1251
  const stubTrace = sinon.stub(console, 'trace');
929
1252
  const i = stubTrace.callCount;
@@ -937,33 +1260,52 @@ describe('update schemas files', () => {
937
1260
  });
938
1261
 
939
1262
  it('should not call function', async () => {
940
- const url =
941
- new URL('https://hg.mozilla.org/releases/mozilla-beta/raw-file/tip/');
1263
+ const url = new URL(
1264
+ 'https://hg-edge.mozilla.org/releases/mozilla-beta/raw-file/tip/'
1265
+ );
942
1266
  const mockPool = mockAgent.get(url.origin);
943
- mockPool.intercept({
944
- path: `${url.pathname}browser/components/extensions/schemas/jar.mn`,
945
- method: 'GET'
946
- }).reply(200, 'content/extensions/schemas/foo.json\ncontent/extensions/schemas/bar.json\n');
947
- mockPool.intercept({
948
- path: `${url.pathname}browser/components/extensions/schemas/foo.json`,
949
- method: 'GET'
950
- }).reply(200, '{ "browser": "foo.json" }');
951
- mockPool.intercept({
952
- path: `${url.pathname}browser/components/extensions/schemas/bar.json`,
953
- method: 'GET'
954
- }).reply(200, '{ "browser": "bar.json" }');
955
- mockPool.intercept({
956
- path: `${url.pathname}toolkit/components/extensions/schemas/jar.mn`,
957
- method: 'GET'
958
- }).reply(200, 'content/extensions/schemas/baz.json\ncontent/extensions/schemas/qux.json\n');
959
- mockPool.intercept({
960
- path: `${url.pathname}toolkit/components/extensions/schemas/baz.json`,
961
- method: 'GET'
962
- }).reply(200, '{ "toolkit": "baz.json" }');
963
- mockPool.intercept({
964
- path: `${url.pathname}toolkit/components/extensions/schemas/qux.json`,
965
- method: 'GET'
966
- }).reply(200, '{ "toolkit": "qux.json" }');
1267
+ mockPool
1268
+ .intercept({
1269
+ path: `${url.pathname}browser/components/extensions/schemas/jar.mn`,
1270
+ method: 'GET'
1271
+ })
1272
+ .reply(
1273
+ 200,
1274
+ 'content/extensions/schemas/foo.json\ncontent/extensions/schemas/bar.json\n'
1275
+ );
1276
+ mockPool
1277
+ .intercept({
1278
+ path: `${url.pathname}browser/components/extensions/schemas/foo.json`,
1279
+ method: 'GET'
1280
+ })
1281
+ .reply(200, '{ "browser": "foo.json" }');
1282
+ mockPool
1283
+ .intercept({
1284
+ path: `${url.pathname}browser/components/extensions/schemas/bar.json`,
1285
+ method: 'GET'
1286
+ })
1287
+ .reply(200, '{ "browser": "bar.json" }');
1288
+ mockPool
1289
+ .intercept({
1290
+ path: `${url.pathname}toolkit/components/extensions/schemas/jar.mn`,
1291
+ method: 'GET'
1292
+ })
1293
+ .reply(
1294
+ 200,
1295
+ 'content/extensions/schemas/baz.json\ncontent/extensions/schemas/qux.json\n'
1296
+ );
1297
+ mockPool
1298
+ .intercept({
1299
+ path: `${url.pathname}toolkit/components/extensions/schemas/baz.json`,
1300
+ method: 'GET'
1301
+ })
1302
+ .reply(200, '{ "toolkit": "baz.json" }');
1303
+ mockPool
1304
+ .intercept({
1305
+ path: `${url.pathname}toolkit/components/extensions/schemas/qux.json`,
1306
+ method: 'GET'
1307
+ })
1308
+ .reply(200, '{ "toolkit": "qux.json" }');
967
1309
  const stubWrite = sinon.stub(fs.promises, 'writeFile');
968
1310
  const stubTrace = sinon.stub(console, 'trace');
969
1311
  const i = stubTrace.callCount;
@@ -979,33 +1321,52 @@ describe('update schemas files', () => {
979
1321
  });
980
1322
 
981
1323
  it('should not call function', async () => {
982
- const url =
983
- new URL('https://hg.mozilla.org/releases/mozilla-beta/raw-file/tip/');
1324
+ const url = new URL(
1325
+ 'https://hg-edge.mozilla.org/releases/mozilla-beta/raw-file/tip/'
1326
+ );
984
1327
  const mockPool = mockAgent.get(url.origin);
985
- mockPool.intercept({
986
- path: `${url.pathname}browser/components/extensions/schemas/jar.mn`,
987
- method: 'GET'
988
- }).reply(200, 'content/extensions/schemas/foo.json\ncontent/extensions/schemas/bar.json\n');
989
- mockPool.intercept({
990
- path: `${url.pathname}browser/components/extensions/schemas/foo.json`,
991
- method: 'GET'
992
- }).reply(200, '{ "browser": "foo.json" }');
993
- mockPool.intercept({
994
- path: `${url.pathname}browser/components/extensions/schemas/bar.json`,
995
- method: 'GET'
996
- }).reply(200, '{ "browser": "bar.json" }');
997
- mockPool.intercept({
998
- path: `${url.pathname}toolkit/components/extensions/schemas/jar.mn`,
999
- method: 'GET'
1000
- }).reply(200, 'content/extensions/schemas/baz.json\ncontent/extensions/schemas/qux.json\n');
1001
- mockPool.intercept({
1002
- path: `${url.pathname}toolkit/components/extensions/schemas/baz.json`,
1003
- method: 'GET'
1004
- }).reply(200, '{ "toolkit": "baz.json" }');
1005
- mockPool.intercept({
1006
- path: `${url.pathname}toolkit/components/extensions/schemas/qux.json`,
1007
- method: 'GET'
1008
- }).reply(400, '{ "ok": false, "status": 400 }');
1328
+ mockPool
1329
+ .intercept({
1330
+ path: `${url.pathname}browser/components/extensions/schemas/jar.mn`,
1331
+ method: 'GET'
1332
+ })
1333
+ .reply(
1334
+ 200,
1335
+ 'content/extensions/schemas/foo.json\ncontent/extensions/schemas/bar.json\n'
1336
+ );
1337
+ mockPool
1338
+ .intercept({
1339
+ path: `${url.pathname}browser/components/extensions/schemas/foo.json`,
1340
+ method: 'GET'
1341
+ })
1342
+ .reply(200, '{ "browser": "foo.json" }');
1343
+ mockPool
1344
+ .intercept({
1345
+ path: `${url.pathname}browser/components/extensions/schemas/bar.json`,
1346
+ method: 'GET'
1347
+ })
1348
+ .reply(200, '{ "browser": "bar.json" }');
1349
+ mockPool
1350
+ .intercept({
1351
+ path: `${url.pathname}toolkit/components/extensions/schemas/jar.mn`,
1352
+ method: 'GET'
1353
+ })
1354
+ .reply(
1355
+ 200,
1356
+ 'content/extensions/schemas/baz.json\ncontent/extensions/schemas/qux.json\n'
1357
+ );
1358
+ mockPool
1359
+ .intercept({
1360
+ path: `${url.pathname}toolkit/components/extensions/schemas/baz.json`,
1361
+ method: 'GET'
1362
+ })
1363
+ .reply(200, '{ "toolkit": "baz.json" }');
1364
+ mockPool
1365
+ .intercept({
1366
+ path: `${url.pathname}toolkit/components/extensions/schemas/qux.json`,
1367
+ method: 'GET'
1368
+ })
1369
+ .reply(400, '{ "ok": false, "status": 400 }');
1009
1370
  const stubWrite = sinon.stub(fs.promises, 'writeFile');
1010
1371
  const stubTrace = sinon.stub(console, 'trace');
1011
1372
  const i = stubTrace.callCount;