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.
- package/.github/workflows/node.js.yml +2 -2
- package/.prettierignore +8 -0
- package/README.md +37 -6
- package/SECURITY.md +30 -0
- package/eslint.config.mjs +27 -19
- package/index.js +9 -3
- package/modules/browser.js +81 -25
- package/modules/commander.js +8 -5
- package/modules/common.js +1 -1
- package/modules/file-util.js +23 -10
- package/modules/schema.js +21 -14
- package/modules/update.js +34 -23
- package/package.json +25 -24
- package/prettier.config.mjs +14 -0
- package/schemas/beta/webext.json +902 -204
- package/schemas/central/webext.json +902 -204
- package/schemas/mail/mailext.json +552 -17
- package/test/browser.test.js +1045 -495
- package/test/commander.test.js +7 -21
- package/test/common.test.js +7 -1
- package/test/file-util.test.js +65 -35
- package/test/index.test.js +55 -1
- package/test/schema.test.js +839 -430
- package/test/update.test.js +872 -511
- package/types/index.d.ts +8 -1
- package/types/modules/browser.d.ts +61 -61
- package/types/modules/commander.d.ts +3 -3
- package/types/modules/common.d.ts +7 -7
- package/types/modules/constant.d.ts +3 -3
- package/types/modules/file-util.d.ts +16 -16
- package/types/modules/schema.d.ts +6 -6
- package/types/modules/update.d.ts +10 -10
package/test/update.test.js
CHANGED
|
@@ -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 {
|
|
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,
|
|
13
|
-
|
|
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(
|
|
32
|
-
|
|
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
|
|
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(
|
|
45
|
-
|
|
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
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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(
|
|
107
|
-
|
|
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(
|
|
114
|
-
|
|
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
|
|
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(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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(
|
|
147
|
-
|
|
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
|
|
154
|
-
.
|
|
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(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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(
|
|
180
|
-
|
|
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
|
|
189
|
-
.
|
|
190
|
-
|
|
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
|
|
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(
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
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
|
-
|
|
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
|
|
218
|
-
.
|
|
219
|
-
|
|
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
|
|
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(
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
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
|
-
|
|
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(
|
|
258
|
-
|
|
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(
|
|
265
|
-
|
|
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
|
|
359
|
+
mockPool
|
|
360
|
+
.intercept({ path: '/foo.json', method: 'GET' })
|
|
274
361
|
.reply(200, '{ "foo": "foobar" }');
|
|
275
|
-
mockPool
|
|
362
|
+
mockPool
|
|
363
|
+
.intercept({ path: '/bar.json', method: 'GET' })
|
|
276
364
|
.reply(200, '{ "baz": "qux" }');
|
|
277
|
-
const res = await getListedSchemaData('https://example.com/',
|
|
278
|
-
|
|
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(
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
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
|
-
|
|
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
|
|
395
|
+
mockPool
|
|
396
|
+
.intercept({ path: '/foo.json', method: 'GET' })
|
|
302
397
|
.reply(200, '{ "foo": "foobar" }');
|
|
303
|
-
mockPool
|
|
398
|
+
mockPool
|
|
399
|
+
.intercept({ path: '/bar.json', method: 'GET' })
|
|
304
400
|
.reply(200, '{ "baz": "qux" }');
|
|
305
|
-
const res = await getListedSchemaData(
|
|
306
|
-
|
|
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(
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
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
|
-
|
|
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(
|
|
341
|
-
|
|
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
|
|
350
|
-
.
|
|
351
|
-
|
|
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
|
|
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(
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
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
|
-
|
|
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
|
|
379
|
-
.
|
|
380
|
-
|
|
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
|
|
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(
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
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
|
-
|
|
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
|
-
|
|
423
|
-
|
|
424
|
-
`${
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
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
|
|
563
|
+
mockPool
|
|
564
|
+
.intercept({ path: `${browserUrl}bar.json`, method: 'GET' })
|
|
430
565
|
.reply(200, '{ "bar": "Bar" }');
|
|
431
|
-
mockPool
|
|
432
|
-
.
|
|
433
|
-
|
|
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
|
|
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(
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
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
|
-
'
|
|
451
|
-
|
|
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
|
-
|
|
463
|
-
|
|
464
|
-
`${
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
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
|
|
617
|
+
mockPool
|
|
618
|
+
.intercept({ path: `${browserUrl}bar.json`, method: 'GET' })
|
|
470
619
|
.reply(200, '{ "bar": "Bar" }');
|
|
471
|
-
mockPool
|
|
472
|
-
.
|
|
473
|
-
|
|
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
|
|
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(
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
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
|
-
'
|
|
491
|
-
|
|
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
|
-
|
|
504
|
-
const
|
|
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
|
|
665
|
+
mockPool
|
|
666
|
+
.intercept({ path: `${browserUrl}commands.json`, method: 'GET' })
|
|
510
667
|
.reply(200, '{ "commands": "Commands" }');
|
|
511
|
-
mockPool
|
|
668
|
+
mockPool
|
|
669
|
+
.intercept({ path: `${browserUrl}pkcs11.json`, method: 'GET' })
|
|
512
670
|
.reply(200, '{ "pkcs11": "Pkcs11" }');
|
|
513
|
-
mockPool
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
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
|
|
680
|
+
mockPool
|
|
681
|
+
.intercept({ path: `${toolkitUrl}extension.json`, method: 'GET' })
|
|
520
682
|
.reply(200, '{ "extension": "Extension" }');
|
|
521
|
-
mockPool
|
|
683
|
+
mockPool
|
|
684
|
+
.intercept({ path: `${toolkitUrl}i18n.json`, method: 'GET' })
|
|
522
685
|
.reply(200, '{ "i18n": "I18n" }');
|
|
523
|
-
mockPool
|
|
686
|
+
mockPool
|
|
687
|
+
.intercept({ path: `${toolkitUrl}management.json`, method: 'GET' })
|
|
524
688
|
.reply(200, '{ "management": "Management" }');
|
|
525
|
-
mockPool
|
|
689
|
+
mockPool
|
|
690
|
+
.intercept({ path: `${toolkitUrl}permissions.json`, method: 'GET' })
|
|
526
691
|
.reply(200, '{ "permissions": "Permissions" }');
|
|
527
|
-
mockPool
|
|
692
|
+
mockPool
|
|
693
|
+
.intercept({ path: `${toolkitUrl}runtime.json`, method: 'GET' })
|
|
528
694
|
.reply(200, '{ "runtime": "Runtime" }');
|
|
529
|
-
mockPool
|
|
695
|
+
mockPool
|
|
696
|
+
.intercept({ path: `${toolkitUrl}theme.json`, method: 'GET' })
|
|
530
697
|
.reply(200, '{ "theme": "Theme" }');
|
|
531
|
-
mockPool
|
|
532
|
-
.
|
|
533
|
-
|
|
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
|
|
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(
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
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
|
-
'
|
|
575
|
-
|
|
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(
|
|
596
|
-
|
|
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(
|
|
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
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
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',
|
|
615
|
-
'
|
|
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
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
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
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
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',
|
|
662
|
-
'
|
|
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
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
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
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
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
|
-
|
|
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
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
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(
|
|
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
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
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
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
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',
|
|
839
|
-
'
|
|
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
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
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
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
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(
|
|
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
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
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
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
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',
|
|
911
|
-
'
|
|
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
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
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
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
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
|
-
|
|
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
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
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
|
-
|
|
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
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
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;
|