@@ -43,17 +43,25 @@ function makeTest (test) {
4343 var uuid = token ( )
4444 var requests = expandTemplates ( test )
4545 var fetchFunctions = makeFetchFunctions ( requests , uuid )
46- return runTest ( fetchFunctions , requests , uuid )
46+ return runTest ( fetchFunctions , test , requests , uuid )
4747 }
4848}
4949
5050function makeFetchFunctions ( requests , uuid ) {
5151 var fetchFunctions = [ ]
5252 for ( let i = 0 ; i < requests . length ; ++ i ) {
53+ var config = requests [ i ] ;
54+ if ( config . skip ) {
55+ // Skip request are ones that we expect the browser to make in
56+ // response to a redirect. We don't fetch them again, but
57+ // the server needs them in the config to be able to respond to
58+ // them.
59+ continue ;
60+ }
5361 fetchFunctions . push ( {
5462 code : function ( idx ) {
5563 var config = requests [ idx ]
56- var url = makeTestUrl ( uuid , config )
64+ var url = makeTestUrl ( uuid , config ) ;
5765 var init = fetchInit ( requests , config )
5866 return fetch ( url , init )
5967 . then ( makeCheckResponse ( idx , config ) )
@@ -71,7 +79,7 @@ function makeFetchFunctions(requests, uuid) {
7179 return fetchFunctions
7280}
7381
74- function runTest ( fetchFunctions , requests , uuid ) {
82+ function runTest ( fetchFunctions , test , requests , uuid ) {
7583 var idx = 0
7684 function runNextStep ( ) {
7785 if ( fetchFunctions . length ) {
@@ -93,7 +101,7 @@ function runTest(fetchFunctions, requests, uuid) {
93101 . then ( function ( ) {
94102 return getServerState ( uuid )
95103 } ) . then ( function ( testState ) {
96- checkRequests ( requests , testState )
104+ checkRequests ( test , requests , testState )
97105 return Promise . resolve ( )
98106 } )
99107}
@@ -153,7 +161,7 @@ function makeCheckResponse (idx, config) {
153161 if ( 'expected_status' in config ) {
154162 assert_equals ( response . status , config . expected_status ,
155163 `Response ${ reqNum } status is ${ response . status } , not ${ config . expected_status } ` )
156- } else if ( 'response_status' in config ) {
164+ } else if ( 'response_status' in config && config . response_status [ 0 ] != 301 ) {
157165 assert_equals ( response . status , config . response_status [ 0 ] ,
158166 `Response ${ reqNum } status is ${ response . status } , not ${ config . response_status [ 0 ] } ` )
159167 } else {
@@ -197,7 +205,7 @@ function makeCheckResponseBody (config, uuid) {
197205 }
198206}
199207
200- function checkRequests ( requests , testState ) {
208+ function checkRequests ( test , requests , testState ) {
201209 var testIdx = 0
202210 for ( let i = 0 ; i < requests . length ; ++ i ) {
203211 var expectedValidatingHeaders = [ ]
@@ -225,6 +233,9 @@ function checkRequests (requests, testState) {
225233 } )
226234 }
227235 }
236+ if ( test ?. check_count && testState ) {
237+ assert_equals ( requests . length , testState . length ) ;
238+ }
228239}
229240
230241function pause ( ) {
0 commit comments