Closed Bug 1429964 Opened 6 years ago Closed 6 years ago

Re-enable browser_packaged_as_locales.js with dynamically testing app locales

Categories

(Firefox :: New Tab Page, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 60
Iteration:
60.4 - Mar 12
Tracking Status
firefox59 --- wontfix
firefox60 --- fixed

People

(Reporter: Mardak, Assigned: Mardak)

References

Details

Attachments

(1 file)

Bug 1423703 disabled browser_packaged_as_locales.js because there isn't a good way to dynamically change the app locale for the test. See 1423703 comment 20.

gandalf, do you have a bug already that we can set blocking this bug?
Flags: needinfo?(gandalf)
Let's block on bug 1358653.
Depends on: 1358653
Flags: needinfo?(gandalf)
Assignee: nobody → edilee
Comment on attachment 8957268 [details]
Bug 1429964 - Re-enable browser_packaged_as_locales.js with dynamically testing app locales.

https://reviewboard.mozilla.org/r/226188/#review232134

::: browser/components/newtab/aboutNewTabService.js:20
(Diff revision 1)
>  
>  // Dummy references to the files that this service no longer allows loading.
>  // Bug 1409054 to remove "chrome://browser/content/abouthome/aboutHome.xhtml"
>  
>  const TOPIC_APP_QUIT = "quit-application-granted";
> -const TOPIC_LOCALES_CHANGE = "intl:requested-locales-changed";
> +const TOPIC_LOCALES_CHANGE = "intl:app-locales-changed";

Yay! Was planning to poke you about it. Glad to see that!

::: browser/components/newtab/tests/browser/browser_packaged_as_locales.js:10
(Diff revision 1)
>  
>  const DEFAULT_URL = "resource://activity-stream/prerendered/en-US/activity-stream-prerendered.html";
>  async function getUrlForLocale(locale) {
> +  const origAvailable = Services.locale.getAvailableLocales();
> +  const origRequested = Services.locale.getRequestedLocales();
> +  try {

Why do you wrap it in try/catch? 

The only scenario in which any of those LocaleService methods throw is if you pass it an incorrectly formatted BCP47 tag.

And in this case, I think it would be better to blow the test rather than silently pass. :)
Attachment #8957268 - Flags: review?(gandalf) → review+
(In reply to Zibi Braniecki [:gandalf][:zibi] from comment #3)
> Why do you wrap it in try/catch? 
Technically, there's no `catch` ;) ;) The finally is so that code can run after the return statement. But.. I guess I can just make it store the return url value and return that after restoring the locale.
oh! That got me, I'm not used to use try/finally for that - neat trick.

Up to you if you want to change that. Maybe just a docstring explaining the technique for folks like me will be enough? :)
Comment on attachment 8957268 [details]
Bug 1429964 - Re-enable browser_packaged_as_locales.js with dynamically testing app locales.

https://reviewboard.mozilla.org/r/226188/#review232134

> Why do you wrap it in try/catch? 
> 
> The only scenario in which any of those LocaleService methods throw is if you pass it an incorrectly formatted BCP47 tag.
> 
> And in this case, I think it would be better to blow the test rather than silently pass. :)

Added comments before for the function and inline
Pushed by edilee@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/543721b84a36
Re-enable browser_packaged_as_locales.js with dynamically testing app locales. r=gandalf
https://hg.mozilla.org/mozilla-central/rev/543721b84a36
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 60
Iteration: --- → 60.4 - Mar 12
Whiteboard: [blocked]
Component: Activity Streams: Newtab → New Tab Page
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: