@@ -13,7 +13,7 @@ const IMAGE_ARRAYBUFFER = Uint8Array.from(image, byte => byte.charCodeAt(0))
13
13
. buffer ;
14
14
15
15
add_task ( async function test_web_accessible_resources_matching ( ) {
16
- let extension = await ExtensionTestUtils . loadExtension ( {
16
+ let extension = ExtensionTestUtils . loadExtension ( {
17
17
manifest : {
18
18
manifest_version : 3 ,
19
19
web_accessible_resources : [
@@ -30,7 +30,7 @@ add_task(async function test_web_accessible_resources_matching() {
30
30
"web_accessible_resources object format incorrect"
31
31
) ;
32
32
33
- extension = await ExtensionTestUtils . loadExtension ( {
33
+ extension = ExtensionTestUtils . loadExtension ( {
34
34
manifest : {
35
35
manifest_version : 3 ,
36
36
web_accessible_resources : [
@@ -46,7 +46,7 @@ add_task(async function test_web_accessible_resources_matching() {
46
46
ok ( true , "web_accessible_resources with matches loads" ) ;
47
47
await extension . unload ( ) ;
48
48
49
- extension = await ExtensionTestUtils . loadExtension ( {
49
+ extension = ExtensionTestUtils . loadExtension ( {
50
50
manifest : {
51
51
manifest_version : 3 ,
52
52
web_accessible_resources : [
@@ -62,7 +62,7 @@ add_task(async function test_web_accessible_resources_matching() {
62
62
ok ( true , "web_accessible_resources with extensions loads" ) ;
63
63
await extension . unload ( ) ;
64
64
65
- extension = await ExtensionTestUtils . loadExtension ( {
65
+ extension = ExtensionTestUtils . loadExtension ( {
66
66
manifest : {
67
67
manifest_version : 3 ,
68
68
web_accessible_resources : [
@@ -79,7 +79,7 @@ add_task(async function test_web_accessible_resources_matching() {
79
79
ok ( true , "web_accessible_resources with matches and extensions loads" ) ;
80
80
await extension . unload ( ) ;
81
81
82
- extension = await ExtensionTestUtils . loadExtension ( {
82
+ extension = ExtensionTestUtils . loadExtension ( {
83
83
manifest : {
84
84
manifest_version : 3 ,
85
85
web_accessible_resources : [
@@ -95,7 +95,7 @@ add_task(async function test_web_accessible_resources_matching() {
95
95
ok ( true , "web_accessible_resources with empty extensions loads" ) ;
96
96
await extension . unload ( ) ;
97
97
98
- extension = await ExtensionTestUtils . loadExtension ( {
98
+ extension = ExtensionTestUtils . loadExtension ( {
99
99
manifest : {
100
100
manifest_version : 3 ,
101
101
web_accessible_resources : [
@@ -446,23 +446,99 @@ add_task(async function test_web_accessible_resources_empty_extension_ids() {
446
446
"expected access to the extension's resource"
447
447
) ;
448
448
449
-
450
-
451
-
452
- try {
453
- await ExtensionTestUtils . fetch (
449
+ await Assert . rejects (
450
+ ExtensionTestUtils . fetch (
454
451
secondExtension . extension . baseURI . resolve ( "page.html" ) ,
455
452
fileURL
456
- ) ;
457
- ok ( false , "expected an error to be thrown" ) ;
458
- } catch ( e ) {
459
- Assert . equal (
460
- e ?. message ,
461
- "NetworkError when attempting to fetch resource." ,
462
- "expected a network error"
463
- ) ;
464
- }
453
+ ) ,
454
+ e => e ?. message === "NetworkError when attempting to fetch resource." ,
455
+ "other extension should not be able to fetch when extension_ids is empty"
456
+ ) ;
465
457
466
458
await extension . unload ( ) ;
467
459
await secondExtension . unload ( ) ;
468
460
} ) ;
461
+
462
+ add_task ( async function test_web_accessible_resources_empty_array ( ) {
463
+ let extension = ExtensionTestUtils . loadExtension ( {
464
+ manifest : {
465
+ manifest_version : 3 ,
466
+ web_accessible_resources : [ ] ,
467
+ } ,
468
+ } ) ;
469
+ await extension . startup ( ) ;
470
+ ok ( true , "empty web_accessible_resources loads" ) ;
471
+ await extension . unload ( ) ;
472
+ } ) ;
473
+
474
+ add_task ( async function test_web_accessible_resources_empty_resources ( ) {
475
+ let extension = ExtensionTestUtils . loadExtension ( {
476
+ manifest : {
477
+ manifest_version : 3 ,
478
+ web_accessible_resources : [ { resources : [ ] , matches : [ "*://*/*" ] } ] ,
479
+ } ,
480
+ } ) ;
481
+ await extension . startup ( ) ;
482
+ ok ( true , "empty web_accessible_resources[0].resources loads" ) ;
483
+ await extension . unload ( ) ;
484
+ } ) ;
485
+
486
+ add_task ( async function test_web_accessible_resources_empty_everything ( ) {
487
+ let extension = ExtensionTestUtils . loadExtension ( {
488
+ manifest : {
489
+ manifest_version : 3 ,
490
+ web_accessible_resources : [
491
+ { resources : [ ] , matches : [ ] , extension_ids : [ ] } ,
492
+ ] ,
493
+ } ,
494
+ } ) ;
495
+ await extension . startup ( ) ;
496
+ ok ( true , "empty resources, matches & extension_ids loads" ) ;
497
+ await extension . unload ( ) ;
498
+ } ) ;
499
+
500
+ add_task ( async function test_web_accessible_resources_empty_matches ( ) {
501
+ let extension = ExtensionTestUtils . loadExtension ( {
502
+ manifest : {
503
+ manifest_version : 3 ,
504
+ web_accessible_resources : [ { resources : [ "file.txt" ] , matches : [ ] } ] ,
505
+ } ,
506
+ files : {
507
+ "file.txt" : "some content" ,
508
+ } ,
509
+ } ) ;
510
+ await extension . startup ( ) ;
511
+ ok ( true , "empty web_accessible_resources[0].matches loads" ) ;
512
+
513
+ const fileURL = extension . extension . baseURI . resolve ( "file.txt" ) ;
514
+ await Assert . rejects (
515
+ ExtensionTestUtils . fetch ( "http://example.com" , fileURL ) ,
516
+ e => e ?. message === "NetworkError when attempting to fetch resource." ,
517
+ "empty matches[] = not web-accessible"
518
+ ) ;
519
+ await extension . unload ( ) ;
520
+ } ) ;
521
+
522
+ add_task ( async function test_web_accessible_resources_unknown_property ( ) {
523
+ let extension = ExtensionTestUtils . loadExtension ( {
524
+ manifest : {
525
+ manifest_version : 3 ,
526
+ web_accessible_resources : [ { resources : [ ] , matches : [ ] , idk : null } ] ,
527
+ } ,
528
+ } ) ;
529
+
530
+ let { messages } = await promiseConsoleOutput ( async ( ) => {
531
+ ExtensionTestUtils . failOnSchemaWarnings ( false ) ;
532
+ await extension . startup ( ) ;
533
+ ExtensionTestUtils . failOnSchemaWarnings ( true ) ;
534
+ } ) ;
535
+
536
+ AddonTestUtils . checkMessages ( messages , {
537
+ expected : [
538
+ {
539
+ message : / R e a d i n g m a n i f e s t : W a r n i n g p r o c e s s i n g w e b _ a c c e s s i b l e _ r e s o u r c e s .0 .i d k : A n u n e x p e c t e d p r o p e r t y w a s f o u n d i n t h e W e b E x t e n s i o n m a n i f e s t ./ ,
540
+ } ,
541
+ ] ,
542
+ } ) ;
543
+ await extension . unload ( ) ;
544
+ } ) ;
0 commit comments