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:

committed by
Alex Rickabaugh

parent
ae9c25ff3d
commit
0d4fe38a09
@ -708,6 +708,15 @@ const manifestUpdateHash = sha1(JSON.stringify(manifestUpdate));
|
||||
|
||||
expect(driver.state).toEqual(DriverReadyState.EXISTING_CLIENTS_ONLY);
|
||||
});
|
||||
|
||||
async_it('ignores invalid `only-if-cached` requests ', async() => {
|
||||
const requestFoo = (cache: RequestCache | 'only-if-cached', mode: RequestMode) =>
|
||||
makeRequest(scope, '/foo.txt', undefined, {cache, mode});
|
||||
|
||||
expect(await requestFoo('default', 'no-cors')).toBe('this is foo');
|
||||
expect(await requestFoo('only-if-cached', 'same-origin')).toBe('this is foo');
|
||||
expect(await requestFoo('only-if-cached', 'no-cors')).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
Reference in New Issue
Block a user