(requests)
| 61756 | async add(request3) { |
| 61757 | webidl.brandCheck(this, _Cache); |
| 61758 | webidl.argumentLengthCheck(arguments, 1, { header: "Cache.add" }); |
| 61759 | request3 = webidl.converters.RequestInfo(request3); |
| 61760 | const requests = [request3]; |
| 61761 | const responseArrayPromise = this.addAll(requests); |
| 61762 | return await responseArrayPromise; |
| 61763 | } |
| 61764 | async addAll(requests) { |
| 61765 | webidl.brandCheck(this, _Cache); |
| 61766 | webidl.argumentLengthCheck(arguments, 1, { header: "Cache.addAll" }); |
| 61767 | requests = webidl.converters["sequence<RequestInfo>"](requests); |
| 61768 | const responsePromises = []; |
| 61769 | const requestList = []; |
| 61770 | for (const request3 of requests) { |
| 61771 | if (typeof request3 === "string") { |
| 61772 | continue; |
| 61773 | } |
| 61774 | const r3 = request3[kState]; |
| 61775 | if (!urlIsHttpHttpsScheme(r3.url) || r3.method !== "GET") { |
| 61776 | throw webidl.errors.exception({ |
| 61777 | header: "Cache.addAll", |
| 61778 | message: "Expected http/s scheme when method is not GET." |
| 61779 | }); |
| 61780 | } |
| 61781 | } |
| 61782 | const fetchControllers = []; |
| 61783 | for (const request3 of requests) { |
| 61784 | const r3 = new Request6(request3)[kState]; |
| 61785 | if (!urlIsHttpHttpsScheme(r3.url)) { |
| 61786 | throw webidl.errors.exception({ |
| 61787 | header: "Cache.addAll", |
| 61788 | message: "Expected http/s scheme." |
| 61789 | }); |
| 61790 | } |
| 61791 | r3.initiator = "fetch"; |
| 61792 | r3.destination = "subresource"; |
| 61793 | requestList.push(r3); |
| 61794 | const responsePromise = createDeferredPromise(); |
| 61795 | fetchControllers.push(fetching({ |
| 61796 | request: r3, |
| 61797 | dispatcher: getGlobalDispatcher(), |
| 61798 | processResponse(response) { |
| 61799 | if (response.type === "error" || response.status === 206 || response.status < 200 || response.status > 299) { |
| 61800 | responsePromise.reject(webidl.errors.exception({ |
| 61801 | header: "Cache.addAll", |
| 61802 | message: "Received an invalid status code or the request failed." |
| 61803 | })); |
| 61804 | } else if (response.headersList.contains("vary")) { |
| 61805 | const fieldValues = getFieldValues(response.headersList.get("vary")); |
| 61806 | for (const fieldValue of fieldValues) { |
| 61807 | if (fieldValue === "*") { |
| 61808 | responsePromise.reject(webidl.errors.exception({ |
| 61809 | header: "Cache.addAll", |
| 61810 | message: "invalid vary field value" |
| 61811 | })); |
| 61812 | for (const controller of fetchControllers) { |
| 61813 | controller.abort(); |
| 61814 | } |
| 61815 | return; |
no test coverage detected