Bug 1776303 - Port osfile.jsm usage to IOUtils in browser/components/preferences r=Gijs,preferences-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D150202
This commit is contained in:
Barret Rennie 2022-08-04 03:53:05 +00:00
Родитель c18ae2e047
Коммит a1666dcde2
2 изменённых файлов: 8 добавлений и 6 удалений

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

@ -3,8 +3,6 @@
"use strict";
const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
var MockFilePicker = SpecialPowers.MockFilePicker;
function createTemporarySaveDirectory() {
@ -96,7 +94,13 @@ async function checkCertExportWorks(
await finishedExporting;
MockFilePicker.cleanup();
if (destFile && destFile.exists()) {
let contents = await OS.File.read(destFile.path, { encoding });
let contents;
if (encoding === "utf-8") {
contents = await IOUtils.readUTF8(destFile.path);
} else {
is(encoding, "", "expected either utf-8 or empty string for encoding");
contents = await IOUtils.read(destFile.path);
}
stringOrArrayEquals(
contents,
expectedFileContents,

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

@ -3,8 +3,6 @@
"use strict";
const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
const { HandlerServiceTestUtils } = ChromeUtils.import(
"resource://testing-common/HandlerServiceTestUtils.jsm"
);
@ -68,7 +66,7 @@ function downloadHadFinished(publicList) {
async function removeTheFile(download) {
Assert.ok(
await OS.File.exists(download.target.path),
await IOUtils.exists(download.target.path),
"The file should have been downloaded."
);