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/schema.test.js
CHANGED
|
@@ -200,13 +200,16 @@ describe('Schema', () => {
|
|
|
200
200
|
namespace: 'foo'
|
|
201
201
|
});
|
|
202
202
|
schema._assignImportMap();
|
|
203
|
-
assert.deepEqual(
|
|
204
|
-
|
|
205
|
-
|
|
203
|
+
assert.deepEqual(
|
|
204
|
+
schema._browser,
|
|
205
|
+
{
|
|
206
|
+
foo: {
|
|
207
|
+
baz: {}
|
|
208
|
+
},
|
|
209
|
+
bar: {}
|
|
206
210
|
},
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}, 'browser');
|
|
211
|
+
'browser'
|
|
212
|
+
);
|
|
210
213
|
assert.strictEqual(schema._importMap.size, 0, 'size');
|
|
211
214
|
});
|
|
212
215
|
|
|
@@ -223,14 +226,18 @@ describe('Schema', () => {
|
|
|
223
226
|
namespace: 'bar'
|
|
224
227
|
});
|
|
225
228
|
schema._assignImportMap();
|
|
226
|
-
assert.deepEqual(
|
|
227
|
-
|
|
228
|
-
|
|
229
|
+
assert.deepEqual(
|
|
230
|
+
schema._browser,
|
|
231
|
+
{
|
|
232
|
+
foo: {
|
|
233
|
+
baz: {}
|
|
234
|
+
},
|
|
235
|
+
bar: {
|
|
236
|
+
baz: {}
|
|
237
|
+
}
|
|
229
238
|
},
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
}, 'browser');
|
|
239
|
+
'browser'
|
|
240
|
+
);
|
|
234
241
|
assert.strictEqual(schema._importMap.size, 0, 'size');
|
|
235
242
|
});
|
|
236
243
|
|
|
@@ -249,16 +256,20 @@ describe('Schema', () => {
|
|
|
249
256
|
namespace: 'bar'
|
|
250
257
|
});
|
|
251
258
|
schema._assignImportMap();
|
|
252
|
-
assert.deepEqual(
|
|
253
|
-
|
|
254
|
-
|
|
259
|
+
assert.deepEqual(
|
|
260
|
+
schema._browser,
|
|
261
|
+
{
|
|
262
|
+
foo: {
|
|
263
|
+
baz: {
|
|
264
|
+
qux: {}
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
bar: {
|
|
255
268
|
qux: {}
|
|
256
269
|
}
|
|
257
270
|
},
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}
|
|
261
|
-
}, 'browser');
|
|
271
|
+
'browser'
|
|
272
|
+
);
|
|
262
273
|
assert.strictEqual(schema._importMap.size, 0, 'size');
|
|
263
274
|
});
|
|
264
275
|
|
|
@@ -279,18 +290,22 @@ describe('Schema', () => {
|
|
|
279
290
|
namespace: 'bar'
|
|
280
291
|
});
|
|
281
292
|
schema._assignImportMap();
|
|
282
|
-
assert.deepEqual(
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
293
|
+
assert.deepEqual(
|
|
294
|
+
schema._browser,
|
|
295
|
+
{
|
|
296
|
+
foo: {
|
|
297
|
+
baz: {
|
|
298
|
+
qux: {}
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
bar: {
|
|
302
|
+
quux: {
|
|
303
|
+
qux: {}
|
|
304
|
+
}
|
|
286
305
|
}
|
|
287
306
|
},
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
qux: {}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}, 'browser');
|
|
307
|
+
'browser'
|
|
308
|
+
);
|
|
294
309
|
assert.strictEqual(schema._importMap.size, 0, 'size');
|
|
295
310
|
});
|
|
296
311
|
|
|
@@ -309,16 +324,20 @@ describe('Schema', () => {
|
|
|
309
324
|
namespace: 'foo'
|
|
310
325
|
});
|
|
311
326
|
schema._assignImportMap();
|
|
312
|
-
assert.deepEqual(
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
327
|
+
assert.deepEqual(
|
|
328
|
+
schema._browser,
|
|
329
|
+
{
|
|
330
|
+
foo: {
|
|
331
|
+
bar: {
|
|
332
|
+
qux: {}
|
|
333
|
+
},
|
|
334
|
+
baz: {
|
|
335
|
+
qux: {}
|
|
336
|
+
}
|
|
319
337
|
}
|
|
320
|
-
}
|
|
321
|
-
|
|
338
|
+
},
|
|
339
|
+
'browser'
|
|
340
|
+
);
|
|
322
341
|
assert.strictEqual(schema._importMap.size, 0, 'size');
|
|
323
342
|
});
|
|
324
343
|
});
|
|
@@ -345,13 +364,16 @@ describe('Schema', () => {
|
|
|
345
364
|
namespace: 'foo'
|
|
346
365
|
});
|
|
347
366
|
schema._assignRefMap();
|
|
348
|
-
assert.deepEqual(
|
|
349
|
-
|
|
350
|
-
|
|
367
|
+
assert.deepEqual(
|
|
368
|
+
schema._browser,
|
|
369
|
+
{
|
|
370
|
+
foo: {
|
|
371
|
+
baz: {}
|
|
372
|
+
},
|
|
373
|
+
bar: {}
|
|
351
374
|
},
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
}, 'browser');
|
|
375
|
+
'browser'
|
|
376
|
+
);
|
|
355
377
|
assert.strictEqual(schema._refMap.size, 0, 'size');
|
|
356
378
|
});
|
|
357
379
|
|
|
@@ -368,14 +390,18 @@ describe('Schema', () => {
|
|
|
368
390
|
namespace: 'bar'
|
|
369
391
|
});
|
|
370
392
|
schema._assignRefMap();
|
|
371
|
-
assert.deepEqual(
|
|
372
|
-
|
|
373
|
-
|
|
393
|
+
assert.deepEqual(
|
|
394
|
+
schema._browser,
|
|
395
|
+
{
|
|
396
|
+
foo: {
|
|
397
|
+
baz: {}
|
|
398
|
+
},
|
|
399
|
+
bar: {
|
|
400
|
+
baz: {}
|
|
401
|
+
}
|
|
374
402
|
},
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
}
|
|
378
|
-
}, 'browser');
|
|
403
|
+
'browser'
|
|
404
|
+
);
|
|
379
405
|
assert.strictEqual(schema._refMap.size, 0, 'size');
|
|
380
406
|
});
|
|
381
407
|
|
|
@@ -394,16 +420,20 @@ describe('Schema', () => {
|
|
|
394
420
|
namespace: 'bar'
|
|
395
421
|
});
|
|
396
422
|
schema._assignRefMap();
|
|
397
|
-
assert.deepEqual(
|
|
398
|
-
|
|
399
|
-
|
|
423
|
+
assert.deepEqual(
|
|
424
|
+
schema._browser,
|
|
425
|
+
{
|
|
426
|
+
foo: {
|
|
427
|
+
baz: {
|
|
428
|
+
qux: {}
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
bar: {
|
|
400
432
|
qux: {}
|
|
401
433
|
}
|
|
402
434
|
},
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
}
|
|
406
|
-
}, 'browser');
|
|
435
|
+
'browser'
|
|
436
|
+
);
|
|
407
437
|
assert.strictEqual(schema._refMap.size, 0, 'size');
|
|
408
438
|
});
|
|
409
439
|
|
|
@@ -424,18 +454,22 @@ describe('Schema', () => {
|
|
|
424
454
|
namespace: 'bar'
|
|
425
455
|
});
|
|
426
456
|
schema._assignRefMap();
|
|
427
|
-
assert.deepEqual(
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
457
|
+
assert.deepEqual(
|
|
458
|
+
schema._browser,
|
|
459
|
+
{
|
|
460
|
+
foo: {
|
|
461
|
+
baz: {
|
|
462
|
+
qux: {}
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
bar: {
|
|
466
|
+
quux: {
|
|
467
|
+
qux: {}
|
|
468
|
+
}
|
|
431
469
|
}
|
|
432
470
|
},
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
qux: {}
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
}, 'browser');
|
|
471
|
+
'browser'
|
|
472
|
+
);
|
|
439
473
|
assert.strictEqual(schema._refMap.size, 0, 'size');
|
|
440
474
|
});
|
|
441
475
|
|
|
@@ -454,16 +488,20 @@ describe('Schema', () => {
|
|
|
454
488
|
namespace: 'foo'
|
|
455
489
|
});
|
|
456
490
|
schema._assignRefMap();
|
|
457
|
-
assert.deepEqual(
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
491
|
+
assert.deepEqual(
|
|
492
|
+
schema._browser,
|
|
493
|
+
{
|
|
494
|
+
foo: {
|
|
495
|
+
bar: {
|
|
496
|
+
qux: {}
|
|
497
|
+
},
|
|
498
|
+
baz: {
|
|
499
|
+
qux: {}
|
|
500
|
+
}
|
|
464
501
|
}
|
|
465
|
-
}
|
|
466
|
-
|
|
502
|
+
},
|
|
503
|
+
'browser'
|
|
504
|
+
);
|
|
467
505
|
assert.strictEqual(schema._refMap.size, 0, 'size');
|
|
468
506
|
});
|
|
469
507
|
});
|
|
@@ -520,26 +558,35 @@ describe('Schema', () => {
|
|
|
520
558
|
assert.strictEqual(typeof res.foo, 'object', 'result');
|
|
521
559
|
assert.strictEqual(typeof res.foo.addListener, 'function', 'addListener');
|
|
522
560
|
assert.strictEqual(typeof res.foo.hasListener, 'function', 'hasListener');
|
|
523
|
-
assert.strictEqual(
|
|
524
|
-
|
|
561
|
+
assert.strictEqual(
|
|
562
|
+
typeof res.foo.removeListener,
|
|
563
|
+
'function',
|
|
564
|
+
'removeListener'
|
|
565
|
+
);
|
|
525
566
|
});
|
|
526
567
|
|
|
527
568
|
it('should add listeners', () => {
|
|
528
569
|
const schema = new Schema();
|
|
529
|
-
const res = schema._mockEvents(
|
|
530
|
-
foo: {}
|
|
531
|
-
}, [
|
|
570
|
+
const res = schema._mockEvents(
|
|
532
571
|
{
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
572
|
+
foo: {}
|
|
573
|
+
},
|
|
574
|
+
[
|
|
575
|
+
{
|
|
576
|
+
name: 'foo',
|
|
577
|
+
type: 'function'
|
|
578
|
+
}
|
|
579
|
+
]
|
|
580
|
+
);
|
|
537
581
|
assert.strictEqual(typeof res, 'object', 'result');
|
|
538
582
|
assert.strictEqual(typeof res.foo, 'object', 'result');
|
|
539
583
|
assert.strictEqual(typeof res.foo.addListener, 'function', 'addListener');
|
|
540
584
|
assert.strictEqual(typeof res.foo.hasListener, 'function', 'hasListener');
|
|
541
|
-
assert.strictEqual(
|
|
542
|
-
|
|
585
|
+
assert.strictEqual(
|
|
586
|
+
typeof res.foo.removeListener,
|
|
587
|
+
'function',
|
|
588
|
+
'removeListener'
|
|
589
|
+
);
|
|
543
590
|
});
|
|
544
591
|
});
|
|
545
592
|
|
|
@@ -597,14 +644,17 @@ describe('Schema', () => {
|
|
|
597
644
|
|
|
598
645
|
it('should add functions', () => {
|
|
599
646
|
const schema = new Schema();
|
|
600
|
-
const res = schema._mockFunctions(
|
|
601
|
-
foo: {}
|
|
602
|
-
}, [
|
|
647
|
+
const res = schema._mockFunctions(
|
|
603
648
|
{
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
649
|
+
foo: {}
|
|
650
|
+
},
|
|
651
|
+
[
|
|
652
|
+
{
|
|
653
|
+
name: 'foo',
|
|
654
|
+
type: 'function'
|
|
655
|
+
}
|
|
656
|
+
]
|
|
657
|
+
);
|
|
608
658
|
assert.strictEqual(typeof res, 'object', 'result');
|
|
609
659
|
assert.strictEqual(typeof res.foo, 'function', 'function');
|
|
610
660
|
});
|
|
@@ -634,107 +684,154 @@ describe('Schema', () => {
|
|
|
634
684
|
|
|
635
685
|
it('should not add properties', () => {
|
|
636
686
|
const schema = new Schema();
|
|
637
|
-
const res = schema._mockProperties(
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
687
|
+
const res = schema._mockProperties(
|
|
688
|
+
{},
|
|
689
|
+
{
|
|
690
|
+
bar: {
|
|
691
|
+
name: 'baz',
|
|
692
|
+
type: 'function',
|
|
693
|
+
unsupported: true
|
|
694
|
+
}
|
|
695
|
+
},
|
|
696
|
+
'foo'
|
|
697
|
+
);
|
|
644
698
|
assert.deepEqual(res, {}, 'result');
|
|
645
699
|
});
|
|
646
700
|
|
|
647
701
|
it('should set map', () => {
|
|
648
702
|
const schema = new Schema();
|
|
649
|
-
const res = schema._mockProperties(
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
}, 'foo');
|
|
655
|
-
assert.deepEqual(res, {
|
|
656
|
-
bar: {}
|
|
657
|
-
}, 'result');
|
|
658
|
-
assert.deepEqual(Array.from(schema._refMap), [
|
|
659
|
-
[
|
|
660
|
-
'foo.bar',
|
|
661
|
-
{
|
|
662
|
-
$ref: 'baz',
|
|
663
|
-
namespace: 'foo'
|
|
703
|
+
const res = schema._mockProperties(
|
|
704
|
+
{},
|
|
705
|
+
{
|
|
706
|
+
bar: {
|
|
707
|
+
$ref: 'baz'
|
|
664
708
|
}
|
|
665
|
-
|
|
666
|
-
|
|
709
|
+
},
|
|
710
|
+
'foo'
|
|
711
|
+
);
|
|
712
|
+
assert.deepEqual(
|
|
713
|
+
res,
|
|
714
|
+
{
|
|
715
|
+
bar: {}
|
|
716
|
+
},
|
|
717
|
+
'result'
|
|
718
|
+
);
|
|
719
|
+
assert.deepEqual(
|
|
720
|
+
Array.from(schema._refMap),
|
|
721
|
+
[
|
|
722
|
+
[
|
|
723
|
+
'foo.bar',
|
|
724
|
+
{
|
|
725
|
+
$ref: 'baz',
|
|
726
|
+
namespace: 'foo'
|
|
727
|
+
}
|
|
728
|
+
]
|
|
729
|
+
],
|
|
730
|
+
'map'
|
|
731
|
+
);
|
|
667
732
|
});
|
|
668
733
|
|
|
669
734
|
it('should add properties', () => {
|
|
670
735
|
const schema = new Schema();
|
|
671
|
-
const res = schema._mockProperties(
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
736
|
+
const res = schema._mockProperties(
|
|
737
|
+
{},
|
|
738
|
+
{
|
|
739
|
+
bar: {
|
|
740
|
+
value: -1
|
|
741
|
+
}
|
|
742
|
+
},
|
|
743
|
+
'foo'
|
|
744
|
+
);
|
|
745
|
+
assert.deepEqual(
|
|
746
|
+
res,
|
|
747
|
+
{
|
|
748
|
+
bar: -1
|
|
749
|
+
},
|
|
750
|
+
'result'
|
|
751
|
+
);
|
|
680
752
|
});
|
|
681
753
|
|
|
682
754
|
it('should add properties', () => {
|
|
683
755
|
const schema = new Schema();
|
|
684
|
-
const res = schema._mockProperties(
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
756
|
+
const res = schema._mockProperties(
|
|
757
|
+
{},
|
|
758
|
+
{
|
|
759
|
+
bar: {
|
|
760
|
+
type: 'function'
|
|
761
|
+
}
|
|
762
|
+
},
|
|
763
|
+
'foo'
|
|
764
|
+
);
|
|
690
765
|
assert.strictEqual(typeof res, 'object', 'result');
|
|
691
766
|
assert.strictEqual(typeof res.bar, 'function', 'property');
|
|
692
767
|
});
|
|
693
768
|
|
|
694
769
|
it('should add properties', () => {
|
|
695
770
|
const schema = new Schema();
|
|
696
|
-
const res = schema._mockProperties(
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
771
|
+
const res = schema._mockProperties(
|
|
772
|
+
{},
|
|
773
|
+
{
|
|
774
|
+
bar: {
|
|
775
|
+
type: 'object'
|
|
776
|
+
}
|
|
777
|
+
},
|
|
778
|
+
'foo'
|
|
779
|
+
);
|
|
780
|
+
assert.deepEqual(
|
|
781
|
+
res,
|
|
782
|
+
{
|
|
783
|
+
bar: {}
|
|
784
|
+
},
|
|
785
|
+
'result'
|
|
786
|
+
);
|
|
705
787
|
});
|
|
706
788
|
|
|
707
789
|
it('should add properties', () => {
|
|
708
790
|
const schema = new Schema();
|
|
709
|
-
const res = schema._mockProperties(
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
791
|
+
const res = schema._mockProperties(
|
|
792
|
+
{
|
|
793
|
+
bar: {}
|
|
794
|
+
},
|
|
795
|
+
{
|
|
796
|
+
bar: {
|
|
797
|
+
properties: {
|
|
798
|
+
baz: {
|
|
799
|
+
type: 'object'
|
|
800
|
+
}
|
|
716
801
|
}
|
|
717
802
|
}
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
803
|
+
},
|
|
804
|
+
'foo'
|
|
805
|
+
);
|
|
806
|
+
assert.deepEqual(
|
|
807
|
+
res,
|
|
808
|
+
{
|
|
809
|
+
bar: {
|
|
810
|
+
baz: {}
|
|
811
|
+
}
|
|
812
|
+
},
|
|
813
|
+
'result'
|
|
814
|
+
);
|
|
725
815
|
});
|
|
726
816
|
|
|
727
817
|
it('should add properties', () => {
|
|
728
818
|
const schema = new Schema();
|
|
729
|
-
const res = schema._mockProperties(
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
819
|
+
const res = schema._mockProperties(
|
|
820
|
+
{},
|
|
821
|
+
{
|
|
822
|
+
bar: {
|
|
823
|
+
type: 'string'
|
|
824
|
+
}
|
|
825
|
+
},
|
|
826
|
+
'foo'
|
|
827
|
+
);
|
|
828
|
+
assert.deepEqual(
|
|
829
|
+
res,
|
|
830
|
+
{
|
|
831
|
+
bar: null
|
|
832
|
+
},
|
|
833
|
+
'result'
|
|
834
|
+
);
|
|
738
835
|
});
|
|
739
836
|
});
|
|
740
837
|
|
|
@@ -762,57 +859,83 @@ describe('Schema', () => {
|
|
|
762
859
|
|
|
763
860
|
it('should set map', () => {
|
|
764
861
|
const schema = new Schema();
|
|
765
|
-
const res = schema._mockTypes(
|
|
766
|
-
|
|
767
|
-
{
|
|
768
|
-
$import: 'bar',
|
|
769
|
-
id: 'baz'
|
|
770
|
-
}
|
|
771
|
-
], 'foo');
|
|
772
|
-
assert.deepEqual(res, {
|
|
773
|
-
baz: {}
|
|
774
|
-
}, 'result');
|
|
775
|
-
assert.deepEqual(Array.from(schema._importMap), [
|
|
862
|
+
const res = schema._mockTypes(
|
|
863
|
+
{},
|
|
776
864
|
[
|
|
777
|
-
'foo.baz',
|
|
778
865
|
{
|
|
779
866
|
$import: 'bar',
|
|
780
|
-
|
|
867
|
+
id: 'baz'
|
|
781
868
|
}
|
|
782
|
-
]
|
|
783
|
-
|
|
869
|
+
],
|
|
870
|
+
'foo'
|
|
871
|
+
);
|
|
872
|
+
assert.deepEqual(
|
|
873
|
+
res,
|
|
874
|
+
{
|
|
875
|
+
baz: {}
|
|
876
|
+
},
|
|
877
|
+
'result'
|
|
878
|
+
);
|
|
879
|
+
assert.deepEqual(
|
|
880
|
+
Array.from(schema._importMap),
|
|
881
|
+
[
|
|
882
|
+
[
|
|
883
|
+
'foo.baz',
|
|
884
|
+
{
|
|
885
|
+
$import: 'bar',
|
|
886
|
+
namespace: 'foo'
|
|
887
|
+
}
|
|
888
|
+
]
|
|
889
|
+
],
|
|
890
|
+
'map'
|
|
891
|
+
);
|
|
784
892
|
});
|
|
785
893
|
|
|
786
894
|
it('should add types', () => {
|
|
787
895
|
const schema = new Schema();
|
|
788
|
-
const res = schema._mockTypes(
|
|
789
|
-
|
|
896
|
+
const res = schema._mockTypes(
|
|
897
|
+
{},
|
|
898
|
+
[
|
|
899
|
+
{
|
|
900
|
+
id: 'baz',
|
|
901
|
+
type: 'object'
|
|
902
|
+
}
|
|
903
|
+
],
|
|
904
|
+
'foo'
|
|
905
|
+
);
|
|
906
|
+
assert.deepEqual(
|
|
907
|
+
res,
|
|
790
908
|
{
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
assert.deepEqual(res, {
|
|
796
|
-
baz: {}
|
|
797
|
-
}, 'result');
|
|
909
|
+
baz: {}
|
|
910
|
+
},
|
|
911
|
+
'result'
|
|
912
|
+
);
|
|
798
913
|
});
|
|
799
914
|
|
|
800
915
|
it('should add types', () => {
|
|
801
916
|
const schema = new Schema();
|
|
802
|
-
const res = schema._mockTypes(
|
|
803
|
-
baz: {}
|
|
804
|
-
}, [
|
|
917
|
+
const res = schema._mockTypes(
|
|
805
918
|
{
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
919
|
+
baz: {}
|
|
920
|
+
},
|
|
921
|
+
[
|
|
922
|
+
{
|
|
923
|
+
events: [],
|
|
924
|
+
functions: [],
|
|
925
|
+
id: 'baz',
|
|
926
|
+
properties: {},
|
|
927
|
+
type: 'object'
|
|
928
|
+
}
|
|
929
|
+
],
|
|
930
|
+
'foo'
|
|
931
|
+
);
|
|
932
|
+
assert.deepEqual(
|
|
933
|
+
res,
|
|
934
|
+
{
|
|
935
|
+
baz: {}
|
|
936
|
+
},
|
|
937
|
+
'result'
|
|
938
|
+
);
|
|
816
939
|
});
|
|
817
940
|
});
|
|
818
941
|
|
|
@@ -865,8 +988,11 @@ describe('Schema', () => {
|
|
|
865
988
|
describe('get schema', () => {
|
|
866
989
|
it('should throw', () => {
|
|
867
990
|
const schema = new Schema();
|
|
868
|
-
assert.throws(
|
|
869
|
-
|
|
991
|
+
assert.throws(
|
|
992
|
+
() => schema.get(),
|
|
993
|
+
TypeError,
|
|
994
|
+
'Expected String but got Undefined.'
|
|
995
|
+
);
|
|
870
996
|
});
|
|
871
997
|
|
|
872
998
|
it('should get null', () => {
|
|
@@ -973,137 +1099,276 @@ describe('Schema', () => {
|
|
|
973
1099
|
const browser = schema.mock();
|
|
974
1100
|
assert.strictEqual(typeof browser, 'object', 'browser');
|
|
975
1101
|
const {
|
|
976
|
-
bookmarks,
|
|
977
|
-
|
|
978
|
-
|
|
1102
|
+
bookmarks,
|
|
1103
|
+
browserAction,
|
|
1104
|
+
browserSettings,
|
|
1105
|
+
commands,
|
|
1106
|
+
contextMenus,
|
|
1107
|
+
contextualIdentities,
|
|
1108
|
+
devtools,
|
|
1109
|
+
i18n,
|
|
1110
|
+
management,
|
|
1111
|
+
menus,
|
|
1112
|
+
notifications,
|
|
1113
|
+
permissions,
|
|
1114
|
+
privacy,
|
|
1115
|
+
runtime,
|
|
1116
|
+
sessions,
|
|
1117
|
+
storage,
|
|
1118
|
+
tabs,
|
|
1119
|
+
theme,
|
|
1120
|
+
windows
|
|
979
1121
|
} = browser;
|
|
980
1122
|
const { inspectedWindow } = devtools;
|
|
981
1123
|
assert.strictEqual(typeof bookmarks, 'object', 'bookmarks');
|
|
982
|
-
assert.strictEqual(
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
'
|
|
1124
|
+
assert.strictEqual(
|
|
1125
|
+
typeof bookmarks.create,
|
|
1126
|
+
'function',
|
|
1127
|
+
'bookmarks.create'
|
|
1128
|
+
);
|
|
1129
|
+
assert.strictEqual(
|
|
1130
|
+
typeof bookmarks.create.callCount,
|
|
1131
|
+
'number',
|
|
1132
|
+
'stub bookmarks.create'
|
|
1133
|
+
);
|
|
986
1134
|
assert.strictEqual(typeof browserAction, 'object', 'browserAction');
|
|
987
|
-
assert.strictEqual(
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
'
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
'
|
|
995
|
-
|
|
996
|
-
|
|
1135
|
+
assert.strictEqual(
|
|
1136
|
+
typeof browserAction.setTitle,
|
|
1137
|
+
'function',
|
|
1138
|
+
'browserAction.setTitle'
|
|
1139
|
+
);
|
|
1140
|
+
assert.strictEqual(
|
|
1141
|
+
typeof browserAction.setTitle.callCount,
|
|
1142
|
+
'number',
|
|
1143
|
+
'stub browserAction.setTitle'
|
|
1144
|
+
);
|
|
1145
|
+
assert.strictEqual(
|
|
1146
|
+
typeof browserAction.onClicked,
|
|
1147
|
+
'object',
|
|
1148
|
+
'browserAction.onClicked'
|
|
1149
|
+
);
|
|
1150
|
+
assert.strictEqual(
|
|
1151
|
+
typeof browserAction.onClicked.addListener,
|
|
1152
|
+
'function',
|
|
1153
|
+
'browserAction.onClicked.addListener'
|
|
1154
|
+
);
|
|
1155
|
+
assert.strictEqual(
|
|
1156
|
+
typeof browserAction.onClicked.addListener.callCount,
|
|
1157
|
+
'number',
|
|
1158
|
+
'stub browserAction.onClicked.addListener.callCount'
|
|
1159
|
+
);
|
|
997
1160
|
assert.strictEqual(typeof browserSettings, 'object', 'browserSettings');
|
|
998
|
-
assert.strictEqual(
|
|
999
|
-
|
|
1161
|
+
assert.strictEqual(
|
|
1162
|
+
typeof browserSettings.closeTabsByDoubleClick,
|
|
1163
|
+
'object',
|
|
1164
|
+
'browserSettings.closeTabsByDoubleClick'
|
|
1165
|
+
);
|
|
1000
1166
|
assert.strictEqual(typeof commands, 'object', 'commands');
|
|
1001
|
-
assert.strictEqual(typeof commands.update, 'function',
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
'
|
|
1167
|
+
assert.strictEqual(typeof commands.update, 'function', 'commands.update');
|
|
1168
|
+
assert.strictEqual(
|
|
1169
|
+
typeof commands.update.callCount,
|
|
1170
|
+
'number',
|
|
1171
|
+
'stub commands.update'
|
|
1172
|
+
);
|
|
1005
1173
|
assert.strictEqual(typeof contextMenus, 'object', 'contextMenus');
|
|
1006
|
-
assert.strictEqual(
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
'
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
'
|
|
1014
|
-
|
|
1015
|
-
|
|
1174
|
+
assert.strictEqual(
|
|
1175
|
+
typeof contextMenus.create,
|
|
1176
|
+
'function',
|
|
1177
|
+
'contextMenus.create'
|
|
1178
|
+
);
|
|
1179
|
+
assert.strictEqual(
|
|
1180
|
+
typeof contextMenus.create.callCount,
|
|
1181
|
+
'number',
|
|
1182
|
+
'stub contextMenus.create'
|
|
1183
|
+
);
|
|
1184
|
+
assert.strictEqual(
|
|
1185
|
+
typeof contextualIdentities,
|
|
1186
|
+
'object',
|
|
1187
|
+
'contextualIdentities'
|
|
1188
|
+
);
|
|
1189
|
+
assert.strictEqual(
|
|
1190
|
+
typeof contextualIdentities.get,
|
|
1191
|
+
'function',
|
|
1192
|
+
'contextualIdentities.get'
|
|
1193
|
+
);
|
|
1194
|
+
assert.strictEqual(
|
|
1195
|
+
typeof contextualIdentities.get.callCount,
|
|
1196
|
+
'number',
|
|
1197
|
+
'stub contextualIdentities.get'
|
|
1198
|
+
);
|
|
1016
1199
|
assert.strictEqual(typeof devtools, 'object', 'devtools');
|
|
1017
1200
|
assert.strictEqual(typeof inspectedWindow, 'object', 'inspectedWindow');
|
|
1018
|
-
assert.strictEqual(
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
'
|
|
1201
|
+
assert.strictEqual(
|
|
1202
|
+
typeof inspectedWindow.reload,
|
|
1203
|
+
'function',
|
|
1204
|
+
'inspectedWindow.reload'
|
|
1205
|
+
);
|
|
1206
|
+
assert.strictEqual(
|
|
1207
|
+
typeof inspectedWindow.reload.callCount,
|
|
1208
|
+
'number',
|
|
1209
|
+
'stub inspectedWindow.reload'
|
|
1210
|
+
);
|
|
1022
1211
|
assert.strictEqual(typeof i18n, 'object', 'i18n');
|
|
1023
|
-
assert.strictEqual(typeof i18n.getMessage, 'function',
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
'
|
|
1212
|
+
assert.strictEqual(typeof i18n.getMessage, 'function', 'i18n.getMessage');
|
|
1213
|
+
assert.strictEqual(
|
|
1214
|
+
typeof i18n.getMessage.callCount,
|
|
1215
|
+
'number',
|
|
1216
|
+
'stub i18n.getMessage'
|
|
1217
|
+
);
|
|
1027
1218
|
assert.strictEqual(typeof management, 'object', 'management');
|
|
1028
|
-
assert.strictEqual(typeof management.get, 'function',
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
'
|
|
1219
|
+
assert.strictEqual(typeof management.get, 'function', 'management.get');
|
|
1220
|
+
assert.strictEqual(
|
|
1221
|
+
typeof management.get.callCount,
|
|
1222
|
+
'number',
|
|
1223
|
+
'stub management.get'
|
|
1224
|
+
);
|
|
1032
1225
|
assert.strictEqual(typeof menus, 'object', 'menus');
|
|
1033
|
-
assert.strictEqual(typeof menus.create, 'function',
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
'
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
assert.strictEqual(
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
'menus.
|
|
1043
|
-
|
|
1044
|
-
|
|
1226
|
+
assert.strictEqual(typeof menus.create, 'function', 'menus.create');
|
|
1227
|
+
assert.strictEqual(
|
|
1228
|
+
typeof menus.create.callCount,
|
|
1229
|
+
'number',
|
|
1230
|
+
'stub menus.create'
|
|
1231
|
+
);
|
|
1232
|
+
assert.strictEqual(
|
|
1233
|
+
typeof menus.getTargetElement,
|
|
1234
|
+
'function',
|
|
1235
|
+
'menus.getTargetElement'
|
|
1236
|
+
);
|
|
1237
|
+
assert.strictEqual(
|
|
1238
|
+
typeof menus.getTargetElement.callCount,
|
|
1239
|
+
'number',
|
|
1240
|
+
'stub menus.getTargetElement'
|
|
1241
|
+
);
|
|
1242
|
+
assert.strictEqual(typeof menus.removeAll, 'function', 'menus.removeAll');
|
|
1243
|
+
assert.strictEqual(
|
|
1244
|
+
typeof menus.removeAll.callCount,
|
|
1245
|
+
'number',
|
|
1246
|
+
'stub menus.removeAll'
|
|
1247
|
+
);
|
|
1045
1248
|
assert.strictEqual(typeof notifications, 'object', 'notifications');
|
|
1046
|
-
assert.strictEqual(
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
'
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
'
|
|
1054
|
-
|
|
1055
|
-
|
|
1249
|
+
assert.strictEqual(
|
|
1250
|
+
typeof notifications.create,
|
|
1251
|
+
'function',
|
|
1252
|
+
'notifications.create'
|
|
1253
|
+
);
|
|
1254
|
+
assert.strictEqual(
|
|
1255
|
+
typeof notifications.create.callCount,
|
|
1256
|
+
'number',
|
|
1257
|
+
'stub notifications.create'
|
|
1258
|
+
);
|
|
1259
|
+
assert.strictEqual(
|
|
1260
|
+
typeof notifications.onClosed,
|
|
1261
|
+
'object',
|
|
1262
|
+
'notifications.onClosed'
|
|
1263
|
+
);
|
|
1264
|
+
assert.strictEqual(
|
|
1265
|
+
typeof notifications.onClosed.addListener,
|
|
1266
|
+
'function',
|
|
1267
|
+
'notifications.onClosed.addListener'
|
|
1268
|
+
);
|
|
1269
|
+
assert.strictEqual(
|
|
1270
|
+
typeof notifications.onClosed.addListener.callCount,
|
|
1271
|
+
'number',
|
|
1272
|
+
'stub notifications.onClosed.addListener'
|
|
1273
|
+
);
|
|
1056
1274
|
assert.strictEqual(typeof permissions, 'object', 'permissions');
|
|
1057
|
-
assert.strictEqual(
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
'
|
|
1061
|
-
|
|
1062
|
-
|
|
1275
|
+
assert.strictEqual(
|
|
1276
|
+
typeof permissions.request,
|
|
1277
|
+
'function',
|
|
1278
|
+
'permissions.request'
|
|
1279
|
+
);
|
|
1280
|
+
assert.strictEqual(
|
|
1281
|
+
typeof permissions.request.callCount,
|
|
1282
|
+
'number',
|
|
1283
|
+
'stub permissions.request'
|
|
1284
|
+
);
|
|
1285
|
+
assert.strictEqual(
|
|
1286
|
+
typeof privacy.network.tlsVersionRestrictionConfig,
|
|
1287
|
+
'object',
|
|
1288
|
+
'privacy.network.tlsVersionRestrictionConfig'
|
|
1289
|
+
);
|
|
1063
1290
|
assert.strictEqual(typeof runtime, 'object', 'runtime');
|
|
1064
|
-
assert.strictEqual(typeof runtime.connect, 'function',
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
'
|
|
1291
|
+
assert.strictEqual(typeof runtime.connect, 'function', 'runtime.connect');
|
|
1292
|
+
assert.strictEqual(
|
|
1293
|
+
typeof runtime.connect.callCount,
|
|
1294
|
+
'number',
|
|
1295
|
+
'stub runtime.connect'
|
|
1296
|
+
);
|
|
1068
1297
|
assert.strictEqual(typeof runtime.Port, 'object', 'runtime.Port');
|
|
1069
|
-
assert.strictEqual(
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
'
|
|
1073
|
-
|
|
1074
|
-
|
|
1298
|
+
assert.strictEqual(
|
|
1299
|
+
typeof runtime.Port.disconnect,
|
|
1300
|
+
'function',
|
|
1301
|
+
'runtime.Port.disconnect'
|
|
1302
|
+
);
|
|
1303
|
+
assert.strictEqual(
|
|
1304
|
+
typeof runtime.Port.onDisconnect.addListener,
|
|
1305
|
+
'function',
|
|
1306
|
+
'runtime.Port.disconnect'
|
|
1307
|
+
);
|
|
1308
|
+
assert.strictEqual(
|
|
1309
|
+
typeof runtime.Port.onDisconnect.addListener,
|
|
1310
|
+
'function',
|
|
1311
|
+
'runtime.Port.onDisconnect.addListener'
|
|
1312
|
+
);
|
|
1075
1313
|
assert.strictEqual(typeof sessions, 'object', 'sessions');
|
|
1076
|
-
assert.strictEqual(
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
'
|
|
1314
|
+
assert.strictEqual(
|
|
1315
|
+
typeof sessions.getRecentlyClosed,
|
|
1316
|
+
'function',
|
|
1317
|
+
'sessions.getRecentlyClosed'
|
|
1318
|
+
);
|
|
1319
|
+
assert.strictEqual(
|
|
1320
|
+
typeof sessions.getRecentlyClosed.callCount,
|
|
1321
|
+
'number',
|
|
1322
|
+
'stub sessions.getRecentlyClosed'
|
|
1323
|
+
);
|
|
1080
1324
|
assert.strictEqual(typeof storage, 'object', 'storage');
|
|
1081
1325
|
assert.strictEqual(typeof storage.local, 'object', 'storage.local');
|
|
1082
|
-
assert.strictEqual(
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
'
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
'
|
|
1090
|
-
|
|
1091
|
-
|
|
1326
|
+
assert.strictEqual(
|
|
1327
|
+
typeof storage.local.get,
|
|
1328
|
+
'function',
|
|
1329
|
+
'storage.local.get'
|
|
1330
|
+
);
|
|
1331
|
+
assert.strictEqual(
|
|
1332
|
+
typeof storage.local.get.callCount,
|
|
1333
|
+
'number',
|
|
1334
|
+
'stub storage.local.get'
|
|
1335
|
+
);
|
|
1336
|
+
assert.strictEqual(
|
|
1337
|
+
typeof storage.onChanged,
|
|
1338
|
+
'object',
|
|
1339
|
+
'storage.onChanged'
|
|
1340
|
+
);
|
|
1341
|
+
assert.strictEqual(
|
|
1342
|
+
typeof storage.onChanged.addListener,
|
|
1343
|
+
'function',
|
|
1344
|
+
'storage.onChanged.addListener'
|
|
1345
|
+
);
|
|
1346
|
+
assert.strictEqual(
|
|
1347
|
+
typeof storage.onChanged.addListener.callCount,
|
|
1348
|
+
'number',
|
|
1349
|
+
'stub storage.onChanged.addListener'
|
|
1350
|
+
);
|
|
1092
1351
|
assert.strictEqual(typeof tabs, 'object', 'tabs');
|
|
1093
|
-
assert.strictEqual(typeof tabs.get, 'function',
|
|
1094
|
-
|
|
1095
|
-
assert.strictEqual(typeof tabs.get.callCount, 'number',
|
|
1096
|
-
'stub tabs.get');
|
|
1352
|
+
assert.strictEqual(typeof tabs.get, 'function', 'tabs.get');
|
|
1353
|
+
assert.strictEqual(typeof tabs.get.callCount, 'number', 'stub tabs.get');
|
|
1097
1354
|
assert.strictEqual(typeof theme, 'object', 'theme');
|
|
1098
|
-
assert.strictEqual(
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
'
|
|
1355
|
+
assert.strictEqual(
|
|
1356
|
+
typeof theme.getCurrent,
|
|
1357
|
+
'function',
|
|
1358
|
+
'theme.getCurrent'
|
|
1359
|
+
);
|
|
1360
|
+
assert.strictEqual(
|
|
1361
|
+
typeof theme.getCurrent.callCount,
|
|
1362
|
+
'number',
|
|
1363
|
+
'stub theme.getCurrent'
|
|
1364
|
+
);
|
|
1102
1365
|
assert.strictEqual(typeof windows, 'object', 'windows');
|
|
1103
|
-
assert.strictEqual(typeof windows.get, 'function',
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
'
|
|
1366
|
+
assert.strictEqual(typeof windows.get, 'function', 'windows.get');
|
|
1367
|
+
assert.strictEqual(
|
|
1368
|
+
typeof windows.get.callCount,
|
|
1369
|
+
'number',
|
|
1370
|
+
'stub windows.get'
|
|
1371
|
+
);
|
|
1107
1372
|
});
|
|
1108
1373
|
|
|
1109
1374
|
it('should get stubbed api', () => {
|
|
@@ -1111,144 +1376,282 @@ describe('Schema', () => {
|
|
|
1111
1376
|
const browser = schema.mock();
|
|
1112
1377
|
assert.strictEqual(typeof browser, 'object', 'browser');
|
|
1113
1378
|
const {
|
|
1114
|
-
bookmarks,
|
|
1115
|
-
|
|
1116
|
-
|
|
1379
|
+
bookmarks,
|
|
1380
|
+
browserAction,
|
|
1381
|
+
browserSettings,
|
|
1382
|
+
commands,
|
|
1383
|
+
contextMenus,
|
|
1384
|
+
contextualIdentities,
|
|
1385
|
+
devtools,
|
|
1386
|
+
i18n,
|
|
1387
|
+
management,
|
|
1388
|
+
menus,
|
|
1389
|
+
notifications,
|
|
1390
|
+
permissions,
|
|
1391
|
+
privacy,
|
|
1392
|
+
runtime,
|
|
1393
|
+
sessions,
|
|
1394
|
+
storage,
|
|
1395
|
+
tabs,
|
|
1396
|
+
theme,
|
|
1397
|
+
windows
|
|
1117
1398
|
} = browser;
|
|
1118
1399
|
const { inspectedWindow } = devtools;
|
|
1119
1400
|
assert.strictEqual(typeof bookmarks, 'object', 'bookmarks');
|
|
1120
|
-
assert.strictEqual(
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
'
|
|
1401
|
+
assert.strictEqual(
|
|
1402
|
+
typeof bookmarks.create,
|
|
1403
|
+
'function',
|
|
1404
|
+
'bookmarks.create'
|
|
1405
|
+
);
|
|
1406
|
+
assert.strictEqual(
|
|
1407
|
+
typeof bookmarks.create.callCount,
|
|
1408
|
+
'number',
|
|
1409
|
+
'stub bookmarks.create'
|
|
1410
|
+
);
|
|
1124
1411
|
assert.strictEqual(typeof browserAction, 'object', 'browserAction');
|
|
1125
|
-
assert.strictEqual(
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
'
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
'
|
|
1133
|
-
|
|
1134
|
-
|
|
1412
|
+
assert.strictEqual(
|
|
1413
|
+
typeof browserAction.setTitle,
|
|
1414
|
+
'function',
|
|
1415
|
+
'browserAction.setTitle'
|
|
1416
|
+
);
|
|
1417
|
+
assert.strictEqual(
|
|
1418
|
+
typeof browserAction.setTitle.callCount,
|
|
1419
|
+
'number',
|
|
1420
|
+
'stub browserAction.setTitle'
|
|
1421
|
+
);
|
|
1422
|
+
assert.strictEqual(
|
|
1423
|
+
typeof browserAction.onClicked,
|
|
1424
|
+
'object',
|
|
1425
|
+
'browserAction.onClicked'
|
|
1426
|
+
);
|
|
1427
|
+
assert.strictEqual(
|
|
1428
|
+
typeof browserAction.onClicked.addListener,
|
|
1429
|
+
'function',
|
|
1430
|
+
'browserAction.onClicked.addListener'
|
|
1431
|
+
);
|
|
1432
|
+
assert.strictEqual(
|
|
1433
|
+
typeof browserAction.onClicked.addListener.callCount,
|
|
1434
|
+
'number',
|
|
1435
|
+
'stub browserAction.onClicked.addListener.callCount'
|
|
1436
|
+
);
|
|
1135
1437
|
assert.strictEqual(typeof browserSettings, 'object', 'browserSettings');
|
|
1136
|
-
assert.strictEqual(
|
|
1137
|
-
|
|
1438
|
+
assert.strictEqual(
|
|
1439
|
+
typeof browserSettings.closeTabsByDoubleClick,
|
|
1440
|
+
'object',
|
|
1441
|
+
'browserSettings.closeTabsByDoubleClick'
|
|
1442
|
+
);
|
|
1138
1443
|
assert.strictEqual(typeof commands, 'object', 'commands');
|
|
1139
|
-
assert.strictEqual(typeof commands.update, 'function',
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
'
|
|
1444
|
+
assert.strictEqual(typeof commands.update, 'function', 'commands.update');
|
|
1445
|
+
assert.strictEqual(
|
|
1446
|
+
typeof commands.update.callCount,
|
|
1447
|
+
'number',
|
|
1448
|
+
'stub commands.update'
|
|
1449
|
+
);
|
|
1143
1450
|
assert.strictEqual(typeof contextMenus, 'object', 'contextMenus');
|
|
1144
|
-
assert.strictEqual(
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
'
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
'
|
|
1152
|
-
|
|
1153
|
-
|
|
1451
|
+
assert.strictEqual(
|
|
1452
|
+
typeof contextMenus.create,
|
|
1453
|
+
'function',
|
|
1454
|
+
'contextMenus.create'
|
|
1455
|
+
);
|
|
1456
|
+
assert.strictEqual(
|
|
1457
|
+
typeof contextMenus.create.callCount,
|
|
1458
|
+
'number',
|
|
1459
|
+
'stub contextMenus.create'
|
|
1460
|
+
);
|
|
1461
|
+
assert.strictEqual(
|
|
1462
|
+
typeof contextualIdentities,
|
|
1463
|
+
'object',
|
|
1464
|
+
'contextualIdentities'
|
|
1465
|
+
);
|
|
1466
|
+
assert.strictEqual(
|
|
1467
|
+
typeof contextualIdentities.get,
|
|
1468
|
+
'function',
|
|
1469
|
+
'contextualIdentities.get'
|
|
1470
|
+
);
|
|
1471
|
+
assert.strictEqual(
|
|
1472
|
+
typeof contextualIdentities.get.callCount,
|
|
1473
|
+
'number',
|
|
1474
|
+
'stub contextualIdentities.get'
|
|
1475
|
+
);
|
|
1154
1476
|
assert.strictEqual(typeof devtools, 'object', 'devtools');
|
|
1155
1477
|
assert.strictEqual(typeof inspectedWindow, 'object', 'inspectedWindow');
|
|
1156
|
-
assert.strictEqual(
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
'
|
|
1478
|
+
assert.strictEqual(
|
|
1479
|
+
typeof inspectedWindow.reload,
|
|
1480
|
+
'function',
|
|
1481
|
+
'inspectedWindow.reload'
|
|
1482
|
+
);
|
|
1483
|
+
assert.strictEqual(
|
|
1484
|
+
typeof inspectedWindow.reload.callCount,
|
|
1485
|
+
'number',
|
|
1486
|
+
'stub inspectedWindow.reload'
|
|
1487
|
+
);
|
|
1160
1488
|
assert.strictEqual(typeof i18n, 'object', 'i18n');
|
|
1161
|
-
assert.strictEqual(typeof i18n.getMessage, 'function',
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
'
|
|
1489
|
+
assert.strictEqual(typeof i18n.getMessage, 'function', 'i18n.getMessage');
|
|
1490
|
+
assert.strictEqual(
|
|
1491
|
+
typeof i18n.getMessage.callCount,
|
|
1492
|
+
'number',
|
|
1493
|
+
'stub i18n.getMessage'
|
|
1494
|
+
);
|
|
1165
1495
|
assert.strictEqual(typeof management, 'object', 'management');
|
|
1166
|
-
assert.strictEqual(typeof management.get, 'function',
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
'
|
|
1496
|
+
assert.strictEqual(typeof management.get, 'function', 'management.get');
|
|
1497
|
+
assert.strictEqual(
|
|
1498
|
+
typeof management.get.callCount,
|
|
1499
|
+
'number',
|
|
1500
|
+
'stub management.get'
|
|
1501
|
+
);
|
|
1170
1502
|
assert.strictEqual(typeof menus, 'object', 'menus');
|
|
1171
|
-
assert.strictEqual(typeof menus.create, 'function',
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
'
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
assert.strictEqual(
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
'menus.
|
|
1181
|
-
|
|
1182
|
-
|
|
1503
|
+
assert.strictEqual(typeof menus.create, 'function', 'menus.create');
|
|
1504
|
+
assert.strictEqual(
|
|
1505
|
+
typeof menus.create.callCount,
|
|
1506
|
+
'number',
|
|
1507
|
+
'stub menus.create'
|
|
1508
|
+
);
|
|
1509
|
+
assert.strictEqual(
|
|
1510
|
+
typeof menus.getTargetElement,
|
|
1511
|
+
'function',
|
|
1512
|
+
'menus.getTargetElement'
|
|
1513
|
+
);
|
|
1514
|
+
assert.strictEqual(
|
|
1515
|
+
typeof menus.getTargetElement.callCount,
|
|
1516
|
+
'number',
|
|
1517
|
+
'stub menus.getTargetElement'
|
|
1518
|
+
);
|
|
1519
|
+
assert.strictEqual(typeof menus.removeAll, 'function', 'menus.removeAll');
|
|
1520
|
+
assert.strictEqual(
|
|
1521
|
+
typeof menus.removeAll.callCount,
|
|
1522
|
+
'number',
|
|
1523
|
+
'stub menus.removeAll'
|
|
1524
|
+
);
|
|
1183
1525
|
assert.strictEqual(typeof notifications, 'object', 'notifications');
|
|
1184
|
-
assert.strictEqual(
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
'
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
'
|
|
1192
|
-
|
|
1193
|
-
|
|
1526
|
+
assert.strictEqual(
|
|
1527
|
+
typeof notifications.create,
|
|
1528
|
+
'function',
|
|
1529
|
+
'notifications.create'
|
|
1530
|
+
);
|
|
1531
|
+
assert.strictEqual(
|
|
1532
|
+
typeof notifications.create.callCount,
|
|
1533
|
+
'number',
|
|
1534
|
+
'stub notifications.create'
|
|
1535
|
+
);
|
|
1536
|
+
assert.strictEqual(
|
|
1537
|
+
typeof notifications.onClosed,
|
|
1538
|
+
'object',
|
|
1539
|
+
'notifications.onClosed'
|
|
1540
|
+
);
|
|
1541
|
+
assert.strictEqual(
|
|
1542
|
+
typeof notifications.onClosed.addListener,
|
|
1543
|
+
'function',
|
|
1544
|
+
'notifications.onClosed.addListener'
|
|
1545
|
+
);
|
|
1546
|
+
assert.strictEqual(
|
|
1547
|
+
typeof notifications.onClosed.addListener.callCount,
|
|
1548
|
+
'number',
|
|
1549
|
+
'stub notifications.onClosed.addListener'
|
|
1550
|
+
);
|
|
1194
1551
|
assert.strictEqual(typeof permissions, 'object', 'permissions');
|
|
1195
|
-
assert.strictEqual(
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
'
|
|
1199
|
-
|
|
1200
|
-
|
|
1552
|
+
assert.strictEqual(
|
|
1553
|
+
typeof permissions.request,
|
|
1554
|
+
'function',
|
|
1555
|
+
'permissions.request'
|
|
1556
|
+
);
|
|
1557
|
+
assert.strictEqual(
|
|
1558
|
+
typeof permissions.request.callCount,
|
|
1559
|
+
'number',
|
|
1560
|
+
'stub permissions.request'
|
|
1561
|
+
);
|
|
1562
|
+
assert.strictEqual(
|
|
1563
|
+
typeof privacy.network.tlsVersionRestrictionConfig,
|
|
1564
|
+
'object',
|
|
1565
|
+
'privacy.network.tlsVersionRestrictionConfig'
|
|
1566
|
+
);
|
|
1201
1567
|
assert.strictEqual(typeof runtime, 'object', 'runtime');
|
|
1202
|
-
assert.strictEqual(typeof runtime.connect, 'function',
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
'
|
|
1568
|
+
assert.strictEqual(typeof runtime.connect, 'function', 'runtime.connect');
|
|
1569
|
+
assert.strictEqual(
|
|
1570
|
+
typeof runtime.connect.callCount,
|
|
1571
|
+
'number',
|
|
1572
|
+
'stub runtime.connect'
|
|
1573
|
+
);
|
|
1206
1574
|
assert.strictEqual(typeof runtime.Port, 'object', 'runtime.Port');
|
|
1207
|
-
assert.strictEqual(
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
'
|
|
1211
|
-
|
|
1212
|
-
|
|
1575
|
+
assert.strictEqual(
|
|
1576
|
+
typeof runtime.Port.disconnect,
|
|
1577
|
+
'function',
|
|
1578
|
+
'runtime.Port.disconnect'
|
|
1579
|
+
);
|
|
1580
|
+
assert.strictEqual(
|
|
1581
|
+
typeof runtime.Port.onDisconnect.addListener,
|
|
1582
|
+
'function',
|
|
1583
|
+
'runtime.Port.disconnect'
|
|
1584
|
+
);
|
|
1585
|
+
assert.strictEqual(
|
|
1586
|
+
typeof runtime.Port.onDisconnect.addListener,
|
|
1587
|
+
'function',
|
|
1588
|
+
'runtime.Port.onDisconnect.addListener'
|
|
1589
|
+
);
|
|
1213
1590
|
assert.strictEqual(typeof sessions, 'object', 'sessions');
|
|
1214
|
-
assert.strictEqual(
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
'
|
|
1591
|
+
assert.strictEqual(
|
|
1592
|
+
typeof sessions.getRecentlyClosed,
|
|
1593
|
+
'function',
|
|
1594
|
+
'sessions.getRecentlyClosed'
|
|
1595
|
+
);
|
|
1596
|
+
assert.strictEqual(
|
|
1597
|
+
typeof sessions.getRecentlyClosed.callCount,
|
|
1598
|
+
'number',
|
|
1599
|
+
'stub sessions.getRecentlyClosed'
|
|
1600
|
+
);
|
|
1218
1601
|
assert.strictEqual(typeof storage, 'object', 'storage');
|
|
1219
1602
|
assert.strictEqual(typeof storage.local, 'object', 'storage.local');
|
|
1220
|
-
assert.strictEqual(
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
'
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
'
|
|
1228
|
-
|
|
1229
|
-
|
|
1603
|
+
assert.strictEqual(
|
|
1604
|
+
typeof storage.local.get,
|
|
1605
|
+
'function',
|
|
1606
|
+
'storage.local.get'
|
|
1607
|
+
);
|
|
1608
|
+
assert.strictEqual(
|
|
1609
|
+
typeof storage.local.get.callCount,
|
|
1610
|
+
'number',
|
|
1611
|
+
'stub storage.local.get'
|
|
1612
|
+
);
|
|
1613
|
+
assert.strictEqual(
|
|
1614
|
+
typeof storage.onChanged,
|
|
1615
|
+
'object',
|
|
1616
|
+
'storage.onChanged'
|
|
1617
|
+
);
|
|
1618
|
+
assert.strictEqual(
|
|
1619
|
+
typeof storage.onChanged.addListener,
|
|
1620
|
+
'function',
|
|
1621
|
+
'storage.onChanged.addListener'
|
|
1622
|
+
);
|
|
1623
|
+
assert.strictEqual(
|
|
1624
|
+
typeof storage.onChanged.addListener.callCount,
|
|
1625
|
+
'number',
|
|
1626
|
+
'stub storage.onChanged.addListener'
|
|
1627
|
+
);
|
|
1230
1628
|
assert.strictEqual(typeof tabs, 'object', 'tabs');
|
|
1231
|
-
assert.strictEqual(typeof tabs.get, 'function',
|
|
1232
|
-
|
|
1233
|
-
assert.strictEqual(typeof tabs.get.callCount, 'number',
|
|
1234
|
-
'stub tabs.get');
|
|
1629
|
+
assert.strictEqual(typeof tabs.get, 'function', 'tabs.get');
|
|
1630
|
+
assert.strictEqual(typeof tabs.get.callCount, 'number', 'stub tabs.get');
|
|
1235
1631
|
assert.strictEqual(typeof theme, 'object', 'theme');
|
|
1236
|
-
assert.strictEqual(
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
'
|
|
1632
|
+
assert.strictEqual(
|
|
1633
|
+
typeof theme.getCurrent,
|
|
1634
|
+
'function',
|
|
1635
|
+
'theme.getCurrent'
|
|
1636
|
+
);
|
|
1637
|
+
assert.strictEqual(
|
|
1638
|
+
typeof theme.getCurrent.callCount,
|
|
1639
|
+
'number',
|
|
1640
|
+
'stub theme.getCurrent'
|
|
1641
|
+
);
|
|
1240
1642
|
assert.strictEqual(typeof windows, 'object', 'windows');
|
|
1241
|
-
assert.strictEqual(typeof windows.get, 'function',
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
'
|
|
1643
|
+
assert.strictEqual(typeof windows.get, 'function', 'windows.get');
|
|
1644
|
+
assert.strictEqual(
|
|
1645
|
+
typeof windows.get.callCount,
|
|
1646
|
+
'number',
|
|
1647
|
+
'stub windows.get'
|
|
1648
|
+
);
|
|
1245
1649
|
});
|
|
1246
1650
|
|
|
1247
1651
|
it('should access sandbox', () => {
|
|
1248
1652
|
const browser = new Schema().mock();
|
|
1249
1653
|
assert.strictEqual(typeof browser._sandbox, 'object', 'sandbox');
|
|
1250
|
-
assert.strictEqual(typeof browser._sandbox.stub, 'function',
|
|
1251
|
-
'stub');
|
|
1654
|
+
assert.strictEqual(typeof browser._sandbox.stub, 'function', 'stub');
|
|
1252
1655
|
const i = browser.runtime.connect.callCount;
|
|
1253
1656
|
browser.runtime.connect();
|
|
1254
1657
|
assert.strictEqual(browser.runtime.connect.callCount, i + 1, 'called');
|
|
@@ -1268,10 +1671,16 @@ describe('Schema', () => {
|
|
|
1268
1671
|
const port2 = mockConnect({ name: 'bar' });
|
|
1269
1672
|
assert.strictEqual(port1.name, 'foo', 'name');
|
|
1270
1673
|
assert.strictEqual(port2.name, 'bar', 'name');
|
|
1271
|
-
assert.strictEqual(
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
'function'
|
|
1674
|
+
assert.strictEqual(
|
|
1675
|
+
typeof port1.onDisconnect.addListener,
|
|
1676
|
+
'function',
|
|
1677
|
+
'function'
|
|
1678
|
+
);
|
|
1679
|
+
assert.strictEqual(
|
|
1680
|
+
typeof port2.onDisconnect.addListener,
|
|
1681
|
+
'function',
|
|
1682
|
+
'function'
|
|
1683
|
+
);
|
|
1275
1684
|
|
|
1276
1685
|
// reset
|
|
1277
1686
|
mockConnect.reset();
|