Bug 1631957 - Clear the about:home cache on locale change. r=k88hudson

Differential Revision: https://phabricator.services.mozilla.com/D72490
This commit is contained in:
Mike Conley 2020-06-25 14:32:20 +00:00
Родитель f7c0240b75
Коммит bd45126cc1
3 изменённых файлов: 27 добавлений и 0 удалений

Просмотреть файл

@ -5003,6 +5003,7 @@ var AboutHomeStartupCache = {
Services.obs.addObserver(this, "ipc:content-created");
Services.obs.addObserver(this, "process-type-set");
Services.obs.addObserver(this, "ipc:content-shutdown");
Services.obs.addObserver(this, "intl:app-locales-changed");
this._cacheEntryPromise = new Promise(resolve => {
this._cacheEntryResolver = resolve;
@ -5046,6 +5047,7 @@ var AboutHomeStartupCache = {
Services.obs.removeObserver(this, "ipc:content-created");
Services.obs.removeObserver(this, "process-type-set");
Services.obs.removeObserver(this, "ipc:content-shutdown");
Services.obs.removeObserver(this, "intl:app-locales-changed");
if (this._cacheTask) {
this._cacheTask.disarm();
@ -5554,6 +5556,10 @@ var AboutHomeStartupCache = {
observe(aSubject, aTopic, aData) {
switch (aTopic) {
case "intl:app-locales-changed": {
this.clearCache();
break;
}
case "process-type-set":
// Intentional fall-through
case "ipc:content-created": {

Просмотреть файл

@ -14,6 +14,7 @@ prefs =
[browser_basic_endtoend.js]
[browser_bump_version.js]
[browser_locale_change.js]
[browser_no_cache.js]
[browser_overwrite_cache.js]
[browser_process_crash.js]

Просмотреть файл

@ -0,0 +1,20 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Tests that the about:home startup cache is cleared if the app
* locale changes.
*/
add_task(async function test_locale_change() {
await BrowserTestUtils.withNewTab("about:home", async browser => {
await simulateRestart(browser);
await ensureCachedAboutHome(browser);
Services.obs.notifyObservers(null, "intl:app-locales-changed");
await simulateRestart(browser, false);
await ensureDynamicAboutHome(browser);
});
});