File tree Expand file tree Collapse file tree 2 files changed +24
-9
lines changed
Expand file tree Collapse file tree 2 files changed +24
-9
lines changed Original file line number Diff line number Diff line change @@ -39,20 +39,23 @@ class CacheStartUrl extends Audit {
3939 */
4040 static audit ( artifacts ) {
4141 let cacheHasStartUrl = false ;
42+ const manifest = artifacts . Manifest && artifacts . Manifest . value ;
43+ const cacheContents = artifacts . CacheContents ;
44+ const baseURL = artifacts . URL ;
4245
43- if ( ! ( artifacts . Manifest &&
44- artifacts . Manifest . value &&
45- artifacts . Manifest . value . start_url &&
46- Array . isArray ( artifacts . CacheContents ) &&
47- artifacts . URL ) ) {
46+ if ( ! ( manifest && manifest . start_url && manifest . start_url . raw ) ) {
4847 return CacheStartUrl . generateAuditResult ( {
49- rawValue : false
48+ rawValue : false ,
49+ debugString : 'start_url not present in Manifest'
5050 } ) ;
5151 }
5252
53- const manifest = artifacts . Manifest . value ;
54- const cacheContents = artifacts . CacheContents ;
55- const baseURL = artifacts . URL ;
53+ if ( ! ( Array . isArray ( cacheContents ) && artifacts . URL ) ) {
54+ return CacheStartUrl . generateAuditResult ( {
55+ rawValue : false ,
56+ debugString : 'No cache or URL detected'
57+ } ) ;
58+ }
5659
5760 // Remove any UTM strings.
5861 const startURL = url . resolve ( baseURL , manifest . start_url . raw ) . toString ( ) ;
Original file line number Diff line number Diff line change @@ -43,6 +43,18 @@ describe('Cache: start_url audit', () => {
4343 return assert . equal ( Audit . audit ( { Manifest, CacheContents} ) . rawValue , false ) ;
4444 } ) ;
4545
46+ // Need to disable camelcase check for dealing with short_name.
47+ /* eslint-disable camelcase */
48+ it ( 'fails when a manifest contains no start_url' , ( ) => {
49+ const inputs = {
50+ Manifest : {
51+
52+ }
53+ } ;
54+
55+ return assert . equal ( Audit . audit ( inputs ) . rawValue , false ) ;
56+ } ) ;
57+
4658 // Need to disable camelcase check for dealing with short_name.
4759 /* eslint-disable camelcase */
4860 it ( 'fails when a manifest contains no start_url' , ( ) => {
You can’t perform that action at this time.
0 commit comments