@@ -127,4 +127,37 @@ describe('quicklink tests', function () {
127127 expect ( responseURLs ) . to . not . include ( 'https://example.com/1.html' ) ;
128128 expect ( responseURLs ) . to . not . include ( 'https://github.githubassets.com/images/spinners/octocat-spinner-32.gif' ) ;
129129 } ) ;
130+
131+ it ( 'should only prefetch links after ignore patterns allowed it' , async function ( ) {
132+ const responseURLs = [ ] ;
133+ page . on ( 'response' , resp => {
134+ responseURLs . push ( resp . url ( ) ) ;
135+ } ) ;
136+ await page . goto ( `${ server } /test-ignore-basic.html` ) ;
137+
138+ await page . waitFor ( 1000 ) ;
139+ expect ( responseURLs ) . to . be . an ( 'array' ) ;
140+ //=> origins: [location.hostname] (default)
141+ //=> ignores: /2.html/
142+ expect ( responseURLs ) . to . not . include ( `${ server } /2.html` ) ; // via ignores
143+ expect ( responseURLs ) . to . not . include ( 'https://example.com/1.html' ) ; // via same origin
144+ expect ( responseURLs ) . to . not . include ( 'https://github.githubassets.com/images/spinners/octocat-spinner-32.gif' ) ; // via same origin
145+ } ) ;
146+
147+ it ( 'should only prefetch links after ignore patterns allowed it (multiple)' , async function ( ) {
148+ const responseURLs = [ ] ;
149+ page . on ( 'response' , resp => {
150+ responseURLs . push ( resp . url ( ) ) ;
151+ } ) ;
152+ await page . goto ( `${ server } /test-ignore-multiple.html` ) ;
153+
154+ await page . waitFor ( 1000 ) ;
155+ expect ( responseURLs ) . to . be . an ( 'array' ) ;
156+ //=> origins: true (all)
157+ //=> ignores: [...]
158+ expect ( responseURLs ) . to . include ( `${ server } /2.html` ) ;
159+ expect ( responseURLs ) . to . not . include ( 'https://example.com/1.html' ) ; // /example/
160+ expect ( responseURLs ) . to . not . include ( 'https://foobar.com/3.html' ) ; // (uri) => uri.includes('foobar')
161+ expect ( responseURLs ) . to . not . include ( 'https://github.githubassets.com/images/spinners/octocat-spinner-32.gif' ) ; // (uri, elem) => elem.textContent.includes('Spinner')
162+ } ) ;
130163} ) ;
0 commit comments