Closed Bug 1206491 Opened 6 years ago Closed 6 years ago

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

Categories

(Core :: Networking: Cache, defect)

43 Branch
defect
Not set
minor

Tracking

()

RESOLVED FIXED
mozilla44
Tracking Status
firefox43 --- affected
firefox44 --- fixed

People

(Reporter: yfdyh000, Assigned: yfdyh000)

References

()

Details

Attachments

(1 file)

Attached patch patch v1Splinter Review
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]);
(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+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/6b9e4e20ce06
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla44
You need to log in before you can comment on or make changes to this bug.