Fix a JavaScript error while about:cache opened and no incoming parameters

RESOLVED FIXED in Firefox 44

Status

()

--
minor
RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: yfdyh000, Assigned: yfdyh000)

Tracking

43 Branch
mozilla44
Points:
---

Firefox Tracking Flags

(firefox43 affected, firefox44 fixed)

Details

(URL)

Attachments

(1 attachment)

(Assignee)

Description

3 years ago
Created attachment 8663391 [details] [diff] [review]
patch v1

STR:
Open about:cache and see Web Console.


TypeError: context is null aboutCache.js:13:5

No other abnormalities. Just eliminate an error.
Attachment #8663391 - Flags: review?(mcmanus)
Attachment #8663391 - Flags: review?(mcmanus) → review?(michal.novotny)
Comment on attachment 8663391 [details] [diff] [review]
patch v1

Review of attachment 8663391 [details] [diff] [review]:
-----------------------------------------------------------------

::: toolkit/components/aboutcache/content/aboutCache.js
@@ +10,5 @@
>  var context = searchParams.get('context');
>  
>  // The context is in a format as used by the HTTP cache v2 back end
> +if (context)
> +  var [context, isAnon, isInBrowser, appId, isPrivate] = context.match(/(a,)?(b,)?(i\d+,)?(p,)?/);

better is:

var [context, isAnon, isInBrowser, appId, isPrivate] = (context ? context.match(/(a,)?(b,)?(i\d+,)?(p,)?/) : [null, false, false, null, false];
Attachment #8663391 - Flags: review?(michal.novotny) → review-
* false]);
(Assignee)

Comment 3

3 years ago
(In reply to Honza Bambas (not reviewing) (:mayhemer) from comment #1)
> Comment on attachment 8663391 [details] [diff] [review]
> patch v1
> 
> Review of attachment 8663391 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: toolkit/components/aboutcache/content/aboutCache.js
> @@ +10,5 @@
> >  var context = searchParams.get('context');
> >  
> >  // The context is in a format as used by the HTTP cache v2 back end
> > +if (context)
> > +  var [context, isAnon, isInBrowser, appId, isPrivate] = context.match(/(a,)?(b,)?(i\d+,)?(p,)?/);
> 
> better is:
> 
> var [context, isAnon, isInBrowser, appId, isPrivate] = (context ?
> context.match(/(a,)?(b,)?(i\d+,)?(p,)?/) : [null, false, false, null, false];

var [context, isAnon, isInBrowser, appId, isPrivate] = (context ? 
  context.match(/(a,)?(b,)?(i\d+,)?(p,)?/) : [null, false, false, null, false]);

Like this?

I don't see the necessity, and this increases the complexity, why we need it?
Flags: needinfo?(honzab.moz)
Comment on attachment 8663391 [details] [diff] [review]
patch v1

Hmm.. we are probably ok with the variables at the default 'undefined' value.  OK then.
Flags: needinfo?(honzab.moz)
Attachment #8663391 - Flags: review- → review+
(Assignee)

Updated

3 years ago
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/6b9e4e20ce06
Status: ASSIGNED → RESOLVED
Last Resolved: 3 years ago
status-firefox44: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla44
You need to log in before you can comment on or make changes to this bug.