@@ -851,6 +851,7 @@ describe('validateJsxElements', () => {
851851 isOnPhishingList,
852852 getSnap : jest . fn ( ) ,
853853 getAccountByAddress : jest . fn ( ) ,
854+ hasPermission : jest . fn ( ) ,
854855 } ) ,
855856 ) . not . toThrow ( ) ;
856857 } ) ;
@@ -868,6 +869,7 @@ describe('validateJsxElements', () => {
868869 isOnPhishingList,
869870 getSnap : jest . fn ( ) ,
870871 getAccountByAddress : jest . fn ( ) ,
872+ hasPermission : jest . fn ( ) ,
871873 } ,
872874 ) ,
873875 ) . not . toThrow ( ) ;
@@ -892,6 +894,7 @@ describe('validateJsxElements', () => {
892894 isOnPhishingList,
893895 getSnap : jest . fn ( ) ,
894896 getAccountByAddress : jest . fn ( ) ,
897+ hasPermission : jest . fn ( ) ,
895898 } ) ,
896899 ) . toThrow ( 'Invalid URL: The specified URL is not allowed.' ) ;
897900 } ) ;
@@ -904,6 +907,7 @@ describe('validateJsxElements', () => {
904907 isOnPhishingList,
905908 getSnap : jest . fn ( ) ,
906909 getAccountByAddress : jest . fn ( ) ,
910+ hasPermission : jest . fn ( ) ,
907911 } ) ,
908912 ) . toThrow (
909913 'Invalid URL: Protocol must be one of: https:, mailto:, metamask:.' ,
@@ -918,6 +922,7 @@ describe('validateJsxElements', () => {
918922 isOnPhishingList,
919923 getSnap : jest . fn ( ) ,
920924 getAccountByAddress : jest . fn ( ) ,
925+ hasPermission : jest . fn ( ) ,
921926 } ) ,
922927 ) . toThrow ( 'Invalid URL: Unable to parse URL.' ) ;
923928 } ) ;
@@ -939,6 +944,7 @@ describe('validateJsxElements', () => {
939944 getAccountByAddress,
940945 isOnPhishingList : jest . fn ( ) ,
941946 getSnap : jest . fn ( ) ,
947+ hasPermission : jest . fn ( ) ,
942948 } ,
943949 ) ,
944950 ) . not . toThrow ( ) ;
@@ -959,12 +965,26 @@ describe('validateJsxElements', () => {
959965 getAccountByAddress,
960966 isOnPhishingList : jest . fn ( ) ,
961967 getSnap : jest . fn ( ) ,
968+ hasPermission : jest . fn ( ) ,
962969 } ,
963970 ) ,
964971 ) . toThrow (
965972 'Could not find account for address: solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp:7S3P4HxJpyyigGzodYwHtCxZyUQe9JiBMHyRWXArAaKv' ,
966973 ) ;
967974 } ) ;
975+
976+ it ( 'throws if the Snap tries to use external images without permission' , ( ) => {
977+ expect ( ( ) =>
978+ validateJsxElements ( < Image src = "https://metamask.io/foo.png" /> , {
979+ getAccountByAddress : jest . fn ( ) ,
980+ isOnPhishingList : jest . fn ( ) ,
981+ getSnap : jest . fn ( ) ,
982+ hasPermission : jest . fn ( ) . mockReturnValue ( false ) ,
983+ } ) ,
984+ ) . toThrow (
985+ 'Using external images is only permitted with the network access endowment.' ,
986+ ) ;
987+ } ) ;
968988} ) ;
969989
970990describe ( 'getTotalTextLength' , ( ) => {
0 commit comments