"Works Offline" should simulate a navigation request
See original GitHub issueThe “works offline” audit currently performs the following:
const requestPage = function() {
const oReq = new XMLHttpRequest();
oReq.onload = oReq.onerror = e => {
// __returnResults is injected by driver.evaluateAsync
__returnResults(e.currentTarget.status);
};
oReq.open('GET', '');
oReq.send();
};
Some service worker implementations (like the one sw-precache
uses) have logic in place to detect whether the incoming fetch
event is associated with a Request
whose mode
is set to 'navigate'
, and take specific action when that’s the case—like falling back to a cached Response
representing the App Shell, allowing them to work offline.
I understand that using an XMLHttpRequest
is much easier to script than properly triggering a navigation request, though. (Even if the code used fetch()
, it’s not possible to construct a Request
with mode
set to 'navigate'
.) Maybe there’s something that could be done with creating an <iframe>
and checking whether that loads properly? Or else scripting a navigation to the same URL and then detecting if that is successful? Any thoughts on those approaches?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (4 by maintainers)
@jeffposnick Do you fancy giving that PR a go?
i’m up for this one as well, no rush 😃 @jeffposnick