(nobug) - Remove mochitests that expect strings or locales (#5151)

This commit is contained in:
Ed Lee 2019-07-03 07:22:32 -07:00 коммит произвёл GitHub
Родитель 80c8e21c9b
Коммит 0dfae2b3af
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 1 добавлений и 95 удалений

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

@ -19,7 +19,7 @@ const TOPIC_CONTENT_DOCUMENT_INTERACTIVE = "content-document-interactive";
// Automated tests ensure packaged locales are in this list. Copied output of:
// https://github.com/mozilla/activity-stream/blob/master/bin/render-activity-stream-html.js
const ACTIVITY_STREAM_BCP47 = "en-US ach an ar ast az be bg bn br bs ca cak crh cs cy da de dsb el en-CA en-GB eo es-AR es-CL es-ES es-MX et eu fa ff fi fr fy-NL ga-IE gd gl gn gu-IN he hi-IN hr hsb hu hy-AM ia id is it ja ja-JP-macos ka kab kk km kn ko lij lo lt ltg lv mk mr ms my nb-NO ne-NP nl nn-NO oc pa-IN pl pt-BR pt-PT rm ro ru si sk sl sq sr sv-SE ta te th tl tr trs uk ur uz vi zh-CN zh-TW".split(" ");
const ACTIVITY_STREAM_BCP47 = "en-US".split(" ");
const ABOUT_URL = "about:newtab";
const BASE_URL = "resource://activity-stream/";

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

@ -10,7 +10,6 @@ prefs =
browser.newtabpage.activity-stream.feeds.section.topstories.options={"provider_name":""}
[browser_aboutwelcome.js]
[browser_activity_stream_strings.js]
[browser_as_load_location.js]
[browser_as_render.js]
[browser_asrouter_snippets.js]
@ -21,7 +20,6 @@ prefs =
[browser_highlights_section.js]
[browser_getScreenshots.js]
[browser_newtab_overrides.js]
[browser_packaged_as_locales.js]
[browser_topsites_contextMenu_options.js]
[browser_topsites_section.js]
[browser_asrouter_cfr.js]

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

@ -1,19 +0,0 @@
XPCOMUtils.defineLazyServiceGetter(this, "aboutNewTabService",
"@mozilla.org/browser/aboutnewtab-service;1",
"nsIAboutNewTabService");
const LOCALE_PATH = "resource://activity-stream/prerendered/";
/**
* Test current locale strings can be fetched the way activity stream does it.
*/
add_task(async function test_activity_stream_fetch_strings() {
const file = `${LOCALE_PATH}${aboutNewTabService.activityStreamLocale}/activity-stream-strings.js`;
const strings = JSON.parse((await
// eslint-disable-next-line fetch-options/no-fetch-credentials
(await fetch(file)).text()).match(/{[^]*}/)[0]);
const ids = Object.keys(strings);
info(`Got string ids: ${ids}`);
Assert.ok(ids.length, "Localized strings are available");
});

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

@ -1,73 +0,0 @@
XPCOMUtils.defineLazyServiceGetter(this, "aboutNewTabService",
"@mozilla.org/browser/aboutnewtab-service;1",
"nsIAboutNewTabService");
// Tests are by default run with non-debug en-US configuration
const DEFAULT_URL = SpecialPowers.getBoolPref("browser.tabs.remote.separatePrivilegedContentProcess") ?
"resource://activity-stream/prerendered/en-US/activity-stream-noscripts.html" :
"resource://activity-stream/prerendered/en-US/activity-stream.html";
/**
* Temporarily change the app locale to get the localized activity stream url
*/
async function getUrlForLocale(locale) {
const origAvailable = Services.locale.availableLocales;
const origRequested = Services.locale.requestedLocales;
try {
Services.locale.availableLocales = [locale];
Services.locale.requestedLocales = [locale];
return aboutNewTabService.defaultURL;
} finally {
// Always clean up after returning the url
Services.locale.availableLocales = origAvailable;
Services.locale.requestedLocales = origRequested;
}
}
/**
* Test that an unknown locale defaults to en-US
*/
add_task(async function test_unknown_locale() {
const url = await getUrlForLocale("und");
Assert.equal(url, DEFAULT_URL);
});
/**
* Test that we at least have en-US
*/
add_task(async function test_default_locale() {
const url = await getUrlForLocale("en-US");
Assert.equal(url, DEFAULT_URL);
});
/**
* Test that we use a shared language before en-US
*/
add_task(async function test_default_locale() {
const url = await getUrlForLocale("de-UNKNOWN");
Assert.equal(url, DEFAULT_URL.replace("en-US", "de"));
});
/**
* Tests that all activity stream packaged locales can be referenced / accessed
*/
add_task(async function test_all_packaged_locales() {
let gotID = false;
const listing = await (await fetch("resource://activity-stream/prerendered/")).text();
for (const line of listing.split("\n").slice(2)) {
const [file, , , type] = line.split(" ").slice(1);
if (type === "DIRECTORY") {
const locale = file.replace("/", "");
if (locale !== "static") {
const url = await getUrlForLocale(locale);
Assert.equal(url, DEFAULT_URL.replace("en-US", locale), `can reference "${locale}" files`);
// Specially remember if we saw an ID locale packaged as it can be
// easily ignored by source control, e.g., .gitignore
gotID |= locale === "id";
}
}
}
Assert.ok(gotID, `"id" locale packaged and not ignored`);
});