@@ -43,17 +43,25 @@ function makeTest (test) {
43
43
var uuid = token ( )
44
44
var requests = expandTemplates ( test )
45
45
var fetchFunctions = makeFetchFunctions ( requests , uuid )
46
- return runTest ( fetchFunctions , requests , uuid )
46
+ return runTest ( fetchFunctions , test , requests , uuid )
47
47
}
48
48
}
49
49
50
50
function makeFetchFunctions ( requests , uuid ) {
51
51
var fetchFunctions = [ ]
52
52
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
+ }
53
61
fetchFunctions . push ( {
54
62
code : function ( idx ) {
55
63
var config = requests [ idx ]
56
- var url = makeTestUrl ( uuid , config )
64
+ var url = makeTestUrl ( uuid , config ) ;
57
65
var init = fetchInit ( requests , config )
58
66
return fetch ( url , init )
59
67
. then ( makeCheckResponse ( idx , config ) )
@@ -71,7 +79,7 @@ function makeFetchFunctions(requests, uuid) {
71
79
return fetchFunctions
72
80
}
73
81
74
- function runTest ( fetchFunctions , requests , uuid ) {
82
+ function runTest ( fetchFunctions , test , requests , uuid ) {
75
83
var idx = 0
76
84
function runNextStep ( ) {
77
85
if ( fetchFunctions . length ) {
@@ -93,7 +101,7 @@ function runTest(fetchFunctions, requests, uuid) {
93
101
. then ( function ( ) {
94
102
return getServerState ( uuid )
95
103
} ) . then ( function ( testState ) {
96
- checkRequests ( requests , testState )
104
+ checkRequests ( test , requests , testState )
97
105
return Promise . resolve ( )
98
106
} )
99
107
}
@@ -153,7 +161,7 @@ function makeCheckResponse (idx, config) {
153
161
if ( 'expected_status' in config ) {
154
162
assert_equals ( response . status , config . expected_status ,
155
163
`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 ) {
157
165
assert_equals ( response . status , config . response_status [ 0 ] ,
158
166
`Response ${ reqNum } status is ${ response . status } , not ${ config . response_status [ 0 ] } ` )
159
167
} else {
@@ -197,7 +205,7 @@ function makeCheckResponseBody (config, uuid) {
197
205
}
198
206
}
199
207
200
- function checkRequests ( requests , testState ) {
208
+ function checkRequests ( test , requests , testState ) {
201
209
var testIdx = 0
202
210
for ( let i = 0 ; i < requests . length ; ++ i ) {
203
211
var expectedValidatingHeaders = [ ]
@@ -225,6 +233,9 @@ function checkRequests (requests, testState) {
225
233
} )
226
234
}
227
235
}
236
+ if ( test ?. check_count && testState ) {
237
+ assert_equals ( requests . length , testState . length ) ;
238
+ }
228
239
}
229
240
230
241
function pause ( ) {
0 commit comments