(fetchParams)
| 1147 | |
| 1148 | // https://fetch.spec.whatwg.org/#http-fetch |
| 1149 | async function httpFetch (fetchParams) { |
| 1150 | // 1. Let request be fetchParams’s request. |
| 1151 | const request = fetchParams.request |
| 1152 | |
| 1153 | // 2. Let response be null. |
| 1154 | let response = null |
| 1155 | |
| 1156 | // 3. Let actualResponse be null. |
| 1157 | let actualResponse = null |
| 1158 | |
| 1159 | // 4. Let timingInfo be fetchParams’s timing info. |
| 1160 | const timingInfo = fetchParams.timingInfo |
| 1161 | |
| 1162 | // 5. If request’s service-workers mode is "all", then: |
| 1163 | if (request.serviceWorkers === 'all') { |
| 1164 | // TODO |
| 1165 | } |
| 1166 | |
| 1167 | // 6. If response is null, then: |
| 1168 | if (response === null) { |
| 1169 | // 1. If makeCORSPreflight is true and one of these conditions is true: |
| 1170 | // TODO |
| 1171 | |
| 1172 | // 2. If request’s redirect mode is "follow", then set request’s |
| 1173 | // service-workers mode to "none". |
| 1174 | if (request.redirect === 'follow') { |
| 1175 | request.serviceWorkers = 'none' |
| 1176 | } |
| 1177 | |
| 1178 | // 3. Set response and actualResponse to the result of running |
| 1179 | // HTTP-network-or-cache fetch given fetchParams. |
| 1180 | actualResponse = response = await httpNetworkOrCacheFetch(fetchParams) |
| 1181 | |
| 1182 | // 4. If request’s response tainting is "cors" and a CORS check |
| 1183 | // for request and response returns failure, then return a network error. |
| 1184 | if ( |
| 1185 | request.responseTainting === 'cors' && |
| 1186 | corsCheck(request, response) === 'failure' |
| 1187 | ) { |
| 1188 | return makeNetworkError('cors failure') |
| 1189 | } |
| 1190 | |
| 1191 | // 5. If the TAO check for request and response returns failure, then set |
| 1192 | // request’s timing allow failed flag. |
| 1193 | if (TAOCheck(request, response) === 'failure') { |
| 1194 | request.timingAllowFailed = true |
| 1195 | } |
| 1196 | } |
| 1197 | |
| 1198 | // 7. If either request’s response tainting or response’s type |
| 1199 | // is "opaque", and the cross-origin resource policy check with |
| 1200 | // request’s origin, request’s client, request’s destination, |
| 1201 | // and actualResponse returns blocked, then return a network error. |
| 1202 | if ( |
| 1203 | (request.responseTainting === 'opaque' || response.type === 'opaque') && |
| 1204 | crossOriginResourcePolicyCheck( |
| 1205 | request.origin, |
| 1206 | request.client, |
no test coverage detected