@@ -65,48 +65,48 @@ test('Allow both extensions', async t => {
6565 t . end ( ) ;
6666} ) ;
6767
68- test ( 'canFetchResource ' , async t => {
68+ test ( 'canFetch ' , async t => {
6969 const vm = new VirtualMachine ( ) ;
7070 setupUnsandboxedExtensionAPI ( vm ) ;
7171 global . location = {
7272 href : 'https://example.com/'
7373 } ;
7474
7575 // data: and blob: are always allowed, shouldn't call security manager
76- vm . securityManager . canFetchResource = ( ) => t . fail ( 'security manager should be ignored for these protocols' ) ;
77- t . equal ( await global . Scratch . canFetchResource ( 'data:text/html,test' ) , true ) ;
78- t . equal ( await global . Scratch . canFetchResource ( 'blob:https://example.com/8c071bf8-c0b6-4a48-81d7-6413c2adf3dd' ) , true ) ;
79-
80- vm . securityManager . canFetchResource = ( ) => false ;
81- t . equal ( await global . Scratch . canFetchResource ( 'file:///etc/hosts' ) , false ) ;
82- t . equal ( await global . Scratch . canFetchResource ( 'http://example.com/' ) , false ) ;
83- t . equal ( await global . Scratch . canFetchResource ( 'https://example.com/' ) , false ) ;
84- t . equal ( await global . Scratch . canFetchResource ( 'special.html' ) , false ) ;
85-
86- vm . securityManager . canFetchResource = ( ) => Promise . resolve ( false ) ;
87- t . equal ( await global . Scratch . canFetchResource ( 'file:///etc/hosts' ) , false ) ;
88- t . equal ( await global . Scratch . canFetchResource ( 'http://example.com/' ) , false ) ;
89- t . equal ( await global . Scratch . canFetchResource ( 'https://example.com/' ) , false ) ;
90- t . equal ( await global . Scratch . canFetchResource ( 'boring.html' ) , false ) ;
91- t . equal ( await global . Scratch . canFetchResource ( 'special.html' ) , false ) ;
92-
93- vm . securityManager . canFetchResource = ( ) => true ;
94- t . equal ( await global . Scratch . canFetchResource ( 'file:///etc/hosts' ) , true ) ;
95- t . equal ( await global . Scratch . canFetchResource ( 'http://example.com/' ) , true ) ;
96- t . equal ( await global . Scratch . canFetchResource ( 'https://example.com/' ) , true ) ;
97- t . equal ( await global . Scratch . canFetchResource ( 'boring.html' ) , true ) ;
98- t . equal ( await global . Scratch . canFetchResource ( 'special.html' ) , true ) ;
76+ vm . securityManager . canFetch = ( ) => t . fail ( 'security manager should be ignored for these protocols' ) ;
77+ t . equal ( await global . Scratch . canFetch ( 'data:text/html,test' ) , true ) ;
78+ t . equal ( await global . Scratch . canFetch ( 'blob:https://example.com/8c071bf8-c0b6-4a48-81d7-6413c2adf3dd' ) , true ) ;
79+
80+ vm . securityManager . canFetch = ( ) => false ;
81+ t . equal ( await global . Scratch . canFetch ( 'file:///etc/hosts' ) , false ) ;
82+ t . equal ( await global . Scratch . canFetch ( 'http://example.com/' ) , false ) ;
83+ t . equal ( await global . Scratch . canFetch ( 'https://example.com/' ) , false ) ;
84+ t . equal ( await global . Scratch . canFetch ( 'special.html' ) , false ) ;
85+
86+ vm . securityManager . canFetch = ( ) => Promise . resolve ( false ) ;
87+ t . equal ( await global . Scratch . canFetch ( 'file:///etc/hosts' ) , false ) ;
88+ t . equal ( await global . Scratch . canFetch ( 'http://example.com/' ) , false ) ;
89+ t . equal ( await global . Scratch . canFetch ( 'https://example.com/' ) , false ) ;
90+ t . equal ( await global . Scratch . canFetch ( 'boring.html' ) , false ) ;
91+ t . equal ( await global . Scratch . canFetch ( 'special.html' ) , false ) ;
92+
93+ vm . securityManager . canFetch = ( ) => true ;
94+ t . equal ( await global . Scratch . canFetch ( 'file:///etc/hosts' ) , true ) ;
95+ t . equal ( await global . Scratch . canFetch ( 'http://example.com/' ) , true ) ;
96+ t . equal ( await global . Scratch . canFetch ( 'https://example.com/' ) , true ) ;
97+ t . equal ( await global . Scratch . canFetch ( 'boring.html' ) , true ) ;
98+ t . equal ( await global . Scratch . canFetch ( 'special.html' ) , true ) ;
9999
100100 const calledWithURLs = [ ] ;
101- vm . securityManager . canFetchResource = async url => {
101+ vm . securityManager . canFetch = async url => {
102102 calledWithURLs . push ( url ) ;
103103 return url === 'https://example.com/special.html' ;
104104 } ;
105- t . equal ( await global . Scratch . canFetchResource ( 'file:///etc/hosts' ) , false ) ;
106- t . equal ( await global . Scratch . canFetchResource ( 'http://example.com/' ) , false ) ;
107- t . equal ( await global . Scratch . canFetchResource ( 'https://example.com/special.html' ) , true ) ;
108- t . equal ( await global . Scratch . canFetchResource ( 'boring.html' ) , false ) ;
109- t . equal ( await global . Scratch . canFetchResource ( 'special.html' ) , true ) ;
105+ t . equal ( await global . Scratch . canFetch ( 'file:///etc/hosts' ) , false ) ;
106+ t . equal ( await global . Scratch . canFetch ( 'http://example.com/' ) , false ) ;
107+ t . equal ( await global . Scratch . canFetch ( 'https://example.com/special.html' ) , true ) ;
108+ t . equal ( await global . Scratch . canFetch ( 'boring.html' ) , false ) ;
109+ t . equal ( await global . Scratch . canFetch ( 'special.html' ) , true ) ;
110110 t . same ( calledWithURLs , [
111111 'file:///etc/hosts' ,
112112 'http://example.com/' ,
0 commit comments