Skip to content

Commit

Permalink
more precise offline message
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhulce committed May 17, 2017
1 parent 519da14 commit fe1b87d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions lighthouse-core/audits/works-offline.js
Expand Up @@ -41,15 +41,16 @@ class WorksOffline extends Audit {
*/
static audit(artifacts) {
let debugString;
if (artifacts.Offline !== 200 &&
!URL.equalWithExcludedFragments(artifacts.URL.initialUrl, artifacts.URL.finalUrl)) {
debugString = 'WARNING: You may be failing this check because your test URL ' +
`(${artifacts.URL.initialUrl}) was redirected to "${artifacts.URL.finalUrl}". ` +
'Try testing the second URL directly.';
const passed = artifacts.Offline === 200;
if (!URL.equalWithExcludedFragments(artifacts.URL.initialUrl, artifacts.URL.finalUrl)) {
const explanation = passed ? 'Your test URL' :
'You may be failing this check because your test URL';
debugString = `WARNING: ${explanation} (${artifacts.URL.initialUrl}) was redirected to ` +
`"${artifacts.URL.finalUrl}". Try testing the second URL directly to verify .`;
}

return {
rawValue: artifacts.Offline === 200,
rawValue: passed,
debugString
};
}
Expand Down
4 changes: 2 additions & 2 deletions lighthouse-core/test/audits/load-fast-enough-for-pwa-test.js
Expand Up @@ -53,7 +53,7 @@ describe('PWA: load-fast-enough-for-pwa audit', () => {
});
});

it('fails a good TTI value with no throttling', () => {
it('warns on a good TTI value with no throttling', () => {
// latencies are very short
const mockNetworkRecords = [
{_timing: {sendEnd: 0, receiveHeadersEnd: 50}, finished: true, _url: 'https://google.com/'},
Expand All @@ -62,7 +62,7 @@ describe('PWA: load-fast-enough-for-pwa audit', () => {
{_timing: {sendEnd: 0, receiveHeadersEnd: 50}, finished: true, _url: 'https://google.com/b'},
];
return FastPWAAudit.audit(generateArtifacts(5000, mockNetworkRecords)).then(result => {
assert.equal(result.rawValue, false);
assert.equal(result.rawValue, true);
assert.ok(result.debugString.includes('network request latencies'));
assert.ok(result.details, 'contains details when latencies were not realistic');
});
Expand Down

0 comments on commit fe1b87d

Please sign in to comment.