fix(service-worker): ignore invalid only-if-cached requests (#22883)

Under some circumstances (possibly related to opening Chrome DevTools),
requests are made with `cache: 'only-if-cached'` and `mode: 'no-cors'`.
These request will eventually fail, because `only-if-cached` is only
allowed to be used with `mode: 'same-origin'`.
This is likely a bug in Chrome DevTools.

This commit avoids errors related to such requests by not handling them.

Fixes #22362

PR Close #22883
This commit is contained in:
George Kalpakas
2018-03-20 15:10:59 +02:00
committed by Alex Rickabaugh
parent ae9c25ff3d
commit 0d4fe38a09
3 changed files with 43 additions and 6 deletions

View File

@ -108,6 +108,9 @@ export class MockRequest extends MockBody implements Request {
Object.keys(headers).forEach(header => { this.headers.set(header, headers[header]); });
}
}
if (init.cache !== undefined) {
this.cache = init.cache;
}
if (init.mode !== undefined) {
this.mode = init.mode;
}
@ -168,4 +171,4 @@ export class MockResponse extends MockBody implements Response {
return new MockResponse(
this._body, {status: this.status, statusText: this.statusText, headers: this.headers});
}
}
}