зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1726565 - Replace OS.File with IOUtils in the search service code. r=daleharvey
Differential Revision: https://phabricator.services.mozilla.com/D123112
This commit is contained in:
Родитель
285d9816ed
Коммит
dbb794b44f
|
@ -66,15 +66,14 @@ SearchSettings.SETTNGS_INVALIDATION_DELAY = 250;
|
|||
|
||||
async function promiseSettingsData() {
|
||||
let path = OS.Path.join(OS.Constants.Path.profileDir, SETTINGS_FILENAME);
|
||||
let bytes = await OS.File.read(path, { compression: "lz4" });
|
||||
return JSON.parse(new TextDecoder().decode(bytes));
|
||||
return JSON.parse(await IOUtils.readUTF8(path, { decompress: true }));
|
||||
}
|
||||
|
||||
function promiseSaveSettingsData(data) {
|
||||
return OS.File.writeAtomic(
|
||||
return IOUtils.write(
|
||||
OS.Path.join(OS.Constants.Path.profileDir, SETTINGS_FILENAME),
|
||||
new TextEncoder().encode(JSON.stringify(data)),
|
||||
{ compression: "lz4" }
|
||||
{ compress: true }
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -197,8 +196,7 @@ async function promiseSetLocale(locale) {
|
|||
* false otherwise.
|
||||
*/
|
||||
async function readJSONFile(file) {
|
||||
let bytes = await OS.File.read(file.path);
|
||||
return JSON.parse(new TextDecoder().decode(bytes));
|
||||
return JSON.parse(await IOUtils.readUTF8(file.path));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,7 +11,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
AddonTestUtils: "resource://testing-common/AddonTestUtils.jsm",
|
||||
AppConstants: "resource://gre/modules/AppConstants.jsm",
|
||||
ObjectUtils: "resource://gre/modules/ObjectUtils.jsm",
|
||||
OS: "resource://gre/modules/osfile.jsm",
|
||||
Region: "resource://gre/modules/Region.jsm",
|
||||
RemoteSettings: "resource://services-settings/remote-settings.js",
|
||||
SearchEngine: "resource://gre/modules/SearchEngine.jsm",
|
||||
|
@ -219,9 +218,7 @@ class SearchConfigTest {
|
|||
if (TEST_DEBUG) {
|
||||
return ["be", "en-US", "kk", "tr", "ru", "zh-CN", "ach", "unknown"];
|
||||
}
|
||||
const data = await OS.File.read(do_get_file("all-locales").path, {
|
||||
encoding: "utf-8",
|
||||
});
|
||||
const data = await IOUtils.readUTF8(do_get_file("all-locales").path);
|
||||
// "en-US" is not in all-locales as it is the default locale
|
||||
// add it manually to ensure it is tested.
|
||||
let locales = [...data.split("\n").filter(e => e != ""), "en-US"];
|
||||
|
|
|
@ -97,10 +97,10 @@ add_task(async function setup() {
|
|||
enginesSettings.buildID = appInfo.platformBuildID;
|
||||
enginesSettings.appVersion = appInfo.version;
|
||||
|
||||
await OS.File.writeAtomic(
|
||||
await IOUtils.write(
|
||||
OS.Path.join(OS.Constants.Path.profileDir, SETTINGS_FILENAME),
|
||||
new TextEncoder().encode(JSON.stringify(enginesSettings)),
|
||||
{ compression: "lz4" }
|
||||
{ compress: true }
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ add_task(async function test_removeAddonOnStartup() {
|
|||
// Now remove it, reset the search service and start up the add-on manager.
|
||||
// Note: the saved settings will have the engine in. If this didn't work,
|
||||
// the engine would still be present.
|
||||
await OS.File.remove(
|
||||
await IOUtils.remove(
|
||||
OS.Path.join(profile.path, "extensions", `${ENGINE_ID}.xpi`)
|
||||
);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче