From a1666dcde2ce3168be62f51743251ff338563254 Mon Sep 17 00:00:00 2001 From: Barret Rennie Date: Thu, 4 Aug 2022 03:53:05 +0000 Subject: [PATCH] Bug 1776303 - Port osfile.jsm usage to IOUtils in browser/components/preferences r=Gijs,preferences-reviewers Differential Revision: https://phabricator.services.mozilla.com/D150202 --- .../preferences/tests/browser_cert_export.js | 10 +++++++--- .../tests/browser_open_download_preferences.js | 4 +--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/browser/components/preferences/tests/browser_cert_export.js b/browser/components/preferences/tests/browser_cert_export.js index a19ebd72ebd8..1516b5834919 100644 --- a/browser/components/preferences/tests/browser_cert_export.js +++ b/browser/components/preferences/tests/browser_cert_export.js @@ -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, diff --git a/browser/components/preferences/tests/browser_open_download_preferences.js b/browser/components/preferences/tests/browser_open_download_preferences.js index 14aa6c03c9c3..f97206a5ebaf 100644 --- a/browser/components/preferences/tests/browser_open_download_preferences.js +++ b/browser/components/preferences/tests/browser_open_download_preferences.js @@ -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." );