mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 14:25:49 +00:00
Bug 1771608 - Eliminate mozilla/reject-osfile eslint warning in devTools code r=devtools-reviewers,perftest-reviewers,jdescottes,sparky
## Removed Some Osfile.jsm and ChromeUtils Dependencies ```diff - const { OS } = require("resource://gre/modules/osfile.jsm"); And / Or - const ChromeUtils = require("ChromeUtils"); ``` - devtools/client/memory/actions/io.js - devtools/client/memory/utils.js - devtools/client/netmonitor/src/har/har-menu-utils.js - devtools/client/responsive/test/browser/browser_screenshot_button.js - devtools/client/shared/remote-debugging/adb/adb-binary.js - devtools/client/shared/screenshot.js - devtools/client/styleeditor/StyleEditorUI.jsm - devtools/client/styleeditor/StyleSheetEditor.jsm - devtools/client/webconsole/components/Input/JSTerm.js - devtools/client/webconsole/test/browser/stub-generator-helpers.js - devtools/server/actors/heap-snapshot-file.js - devtools/server/actors/storage.js - devtools/server/tests/xpcshell/test_MemoryActor_saveHeapSnapshot_01.js - devtools/server/tests/xpcshell/test_MemoryActor_saveHeapSnapshot_02.js - devtools/server/tests/xpcshell/test_MemoryActor_saveHeapSnapshot_03.js - devtools/shared/DevToolsUtils.js - devtools/shared/heapsnapshot/HeapSnapshotFileUtils.js - devtools/shared/tests/xpcshell/test_fetch-file.js - testing/talos/talos/tests/devtools/addon/content/tests/toolbox/screenshot.js ## IOUtils.read() ```diff - OS.File.read(path); + IOUtils.read(path); ``` - devtools/client/aboutdebugging/test/browser/helper-real-usb.js - devtools/client/netmonitor/src/har/har-menu-utils.js - devtools/client/shared/remote-debugging/adb/adb-binary.js - devtools/client/styleeditor/StyleSheetEditor.jsm - devtools/client/webconsole/components/Input/JSTerm.js - devtools/client/webconsole/test/browser/browser_jsterm_file_load_save_keyboard_shortcut.js - devtools/client/webconsole/test/browser/browser_webconsole_context_menu_export_console_output.js - devtools/shared/DevToolsUtils.js ## IOUtils.write() ```diff - OS.File.writeAtomic(filePath, fileContent); + IOUtils.write(filePath, fileContent); ``` - devtools/client/webconsole/test/browser/stub-generator-helpers.js - devtools/shared/DevToolsUtils.js - devtools/shared/tests/xpcshell/test_fetch-file.js ## PathUtils.split() ```diff - OS.Path.split(path); + PathUtils.split(path); ``` - devtools/client/styleeditor/StyleSheetEditor.jsm ## PathUtils.join() ```diff - OS.Path.join(path, filename); + PathUtils.join(path, filename); ``` NOTE: If `filename` is an absolute path then `OS.Path` will ignore `path` and use `filename` but `PathUtils` will try to concatenate both paths. If filename can be an absolute path we need to use `PathUtils.isAbsolute()` and `PathUtils.joinRelative()` to make our desired behaviour explicit. - devtools/client/debugger/test/mochitest/browser_dbg-chrome-create.js - devtools/client/shared/remote-debugging/adb/adb-binary.js - devtools/client/styleeditor/StyleSheetEditor.jsm - devtools/shared/heapsnapshot/HeapSnapshotFileUtils.js ## PathUtils.isAbsolute() and PathUtils.joinRelative() ```diff - filename = OS.Path.join(path, filename); + filename = PathUtils.isAbsolute(filename) + ? filename + : PathUtils.joinRelative(path, filename); ``` - devtools/client/shared/screenshot.js ## IOUtils.remove() ```diff - OS.File.remove(filePath); + IOUtils.remove(filePath); ``` - devtools/client/framework/test/browser_toolbox_screenshot_tool.js - devtools/client/responsive/test/browser/browser_screenshot_button.js - devtools/client/responsive/test/browser/browser_screenshot_button_warning.js - devtools/client/shared/test/shared-head.js - devtools/client/webconsole/test/browser/browser_console_screenshot.js - devtools/client/webconsole/test/browser/browser_jsterm_screenshot_command_file.js - devtools/client/webconsole/test/browser/browser_jsterm_screenshot_command_fixed_header.js - devtools/client/webconsole/test/browser/browser_jsterm_screenshot_command_selector.js - testing/talos/talos/tests/devtools/addon/content/tests/toolbox/screenshot.js ## PathUtils.toFileURI() ```diff - OS.Path.toFileURI(filePath); + PathUtils.toFileURI(filePath); ``` - devtools/client/framework/test/browser_toolbox_screenshot_tool.js - devtools/client/responsive/test/browser/browser_screenshot_button.js - devtools/client/shared/test/shared-head.js - devtools/client/webconsole/test/browser/browser_console_screenshot.js - devtools/client/webconsole/test/browser/browser_jsterm_screenshot_command_file.js - devtools/client/webconsole/test/browser/browser_jsterm_screenshot_command_fixed_header.js - devtools/client/webconsole/test/browser/browser_jsterm_screenshot_command_selector.js ## PathUtils.filename() ```diff - OS.Path.basename(path), + PathUtils.filename(path), ``` - devtools/client/memory/actions/io.js - devtools/client/memory/utils.js - devtools/client/styleeditor/StyleEditorUI.jsm - devtools/client/styleeditor/StyleSheetEditor.jsm ## IOUtils.copy() ```diff - OS.File.copy(path, dest); + IOUtils.copy(path, dest); ``` - devtools/client/memory/actions/io.js ## IOUtils.stat() ```diff - OS.File.stat(filePath); + IOUtils.stat(filePath); ``` The objects that these `stat()` versions return differ from one another. This hasn't made much difference to the codebase but our changed usage is included here for completeness: ```diff - this._fileModDate = info.lastModificationDate.getTime(); + this._fileModDate = info.lastModified; ``` - devtools/client/memory/test/browser/browser_memory_transferHeapSnapshot_e10s_01.js - devtools/client/memory/test/xpcshell/head.js - devtools/client/memory/test/xpcshell/test_action-export-snapshot.js - devtools/client/styleeditor/StyleSheetEditor.jsm - devtools/server/actors/heap-snapshot-file.js - devtools/server/tests/xpcshell/test_MemoryActor_saveHeapSnapshot_01.js - devtools/server/tests/xpcshell/test_MemoryActor_saveHeapSnapshot_02.js - devtools/server/tests/xpcshell/test_MemoryActor_saveHeapSnapshot_03.js - devtools/shared/heapsnapshot/HeapSnapshotFileUtils.js ## IOUtils.setPermissions ```diff - OS.File.setPermissions(filePath, { unixMode: 0o744 }); + IOUtils.setPermissions(filePath, 0o744); ``` - devtools/client/shared/remote-debugging/adb/adb-binary.js ## IOUtils.makeDirectory ```diff - OS.File.makeDir(path); + IOUtils.makeDirectory(path); ``` - devtools/client/shared/remote-debugging/adb/adb-binary.js ## IOUtils.exists ```diff - OS.File.exists(path); + IOUtils.exists(path); ``` - devtools/client/shared/remote-debugging/adb/adb-binary.js - devtools/client/shared/screenshot.js - devtools/client/webconsole/test/browser/browser_jsterm_file_load_save_keyboard_shortcut.js - devtools/client/webconsole/test/browser/browser_webconsole_context_menu_export_console_output.js ## PathUtils.profileDir, PathUtils.localProfileDir and PathUtils.tempDir ```diff - const profileDir = OS.Constants.Path.profileDir; + const profileDir = PathUtils.profileDir; ``` We can reduce reliance on `Osfile.jsm` in another bug bug this is a small step in that direction. - devtools/client/shared/remote-debugging/adb/adb-binary.js - devtools/server/actors/storage.js - devtools/shared/heapsnapshot/HeapSnapshotFileUtils.js ## IOUtils.getChildren(storagePath) `IOUtils` does not have a direct equivalent of `OS.File.DirectoryIterator()` so we need to iterate more explicitely using `IOUtils.getChildren()`. ```diff - async findStorageTypePaths(storagePath) { - const iterator = new OS.File.DirectoryIterator(storagePath); - const typePaths = []; - - await iterator.forEach(entry => { - if (entry.isDir) { - typePaths.push(entry.path); - } - }); - - iterator.close(); - return typePaths; - } + async findStorageTypePaths(storagePath) { + const children = await IOUtils.getChildren(storagePath); + const typePaths = []; + + for (const path of children) { + const exists = await IOUtils.exists(path); + if (!exists) { + continue; + } + + const stats = await IOUtils.stat(path); + if (stats.type === "directory") { + typePaths.push(path); + } + } + + return typePaths; + } ``` - devtools/server/actors/storage.js ## Misc Made `IOUtils` and `PathUtils` available to DevTools modules. ```diff HeapSnapshot, + IOUtils, L10nRegistry, Localization, NamedNodeMap, NodeFilter, + PathUtils, StructuredCloneHolder, TelemetryStopwatch, ``` - devtools/shared/loader/builtin-modules.js Differential Revision: https://phabricator.services.mozilla.com/D147589
This commit is contained in:
parent
99677cea83
commit
3133e874e5
@ -17,7 +17,7 @@ async function getExpectedRuntimeAll() {
|
||||
const currentPath = env.get("PWD");
|
||||
const path = `${currentPath}/${runtimesPath}`;
|
||||
info(`Load ${path}`);
|
||||
const buffer = await OS.File.read(path);
|
||||
const buffer = await IOUtils.read(path);
|
||||
const data = new TextDecoder().decode(buffer);
|
||||
return JSON.parse(data);
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ add_task(async function() {
|
||||
|
||||
is(
|
||||
gProcess._dbgProfilePath,
|
||||
OS.Path.join(OS.Constants.Path.profileDir, "chrome_debugger_profile"),
|
||||
PathUtils.join(PathUtils.profileDir, "chrome_debugger_profile"),
|
||||
"The remote debugger profile isn't where we expect it!"
|
||||
);
|
||||
|
||||
|
@ -40,7 +40,7 @@ add_task(async function() {
|
||||
info("Create an image using the downloaded file as source");
|
||||
const image = new Image();
|
||||
const onImageLoad = once(image, "load");
|
||||
image.src = OS.Path.toFileURI(filePath);
|
||||
image.src = PathUtils.toFileURI(filePath);
|
||||
await onImageLoad;
|
||||
|
||||
const dpr = await SpecialPowers.spawn(
|
||||
@ -79,6 +79,6 @@ add_task(async function() {
|
||||
);
|
||||
|
||||
//Remove the downloaded screenshot file
|
||||
await OS.File.remove(filePath);
|
||||
await IOUtils.remove(filePath);
|
||||
await resetDownloads();
|
||||
});
|
||||
|
@ -17,7 +17,6 @@ const {
|
||||
openFilePicker,
|
||||
createSnapshot,
|
||||
} = require("devtools/client/memory/utils");
|
||||
const { OS } = require("resource://gre/modules/osfile.jsm");
|
||||
const {
|
||||
selectSnapshot,
|
||||
computeSnapshotData,
|
||||
@ -29,7 +28,7 @@ exports.pickFileAndExportSnapshot = function(snapshot) {
|
||||
return async function({ dispatch, getState }) {
|
||||
const outputFile = await openFilePicker({
|
||||
title: L10N.getFormatStr("snapshot.io.save.window"),
|
||||
defaultName: OS.Path.basename(snapshot.path),
|
||||
defaultName: PathUtils.filename(snapshot.path),
|
||||
filters: [[L10N.getFormatStr("snapshot.io.filter"), "*.fxsnapshot"]],
|
||||
mode: "save",
|
||||
});
|
||||
@ -52,7 +51,7 @@ const exportSnapshot = (exports.exportSnapshot = function(snapshot, dest) {
|
||||
);
|
||||
|
||||
try {
|
||||
await OS.File.copy(snapshot.path, dest);
|
||||
await IOUtils.copy(snapshot.path, dest);
|
||||
} catch (error) {
|
||||
reportException("exportSnapshot", error);
|
||||
dispatch({ type: actions.EXPORT_SNAPSHOT_ERROR, snapshot, error });
|
||||
|
@ -22,7 +22,7 @@ this.test = makeMemoryTest(TEST_URL, async function({ tab, panel }) {
|
||||
});
|
||||
|
||||
ok(
|
||||
!!(await OS.File.stat(snapshotFilePath)),
|
||||
!!(await IOUtils.stat(snapshotFilePath)),
|
||||
"Should have the heap snapshot file"
|
||||
);
|
||||
|
||||
|
@ -137,7 +137,7 @@ async function createTempFile() {
|
||||
const file = FileUtils.getFile("TmpD", ["tmp.fxsnapshot"]);
|
||||
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, FileUtils.PERMS_FILE);
|
||||
const destPath = file.path;
|
||||
const stat = await OS.File.stat(destPath);
|
||||
const stat = await IOUtils.stat(destPath);
|
||||
ok(stat.size === 0, "new file is 0 bytes at start");
|
||||
return destPath;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ add_task(async function() {
|
||||
dispatch(exportSnapshot(getState().snapshots[0], destPath));
|
||||
await exportEvents;
|
||||
|
||||
const stat = await OS.File.stat(destPath);
|
||||
const stat = await IOUtils.stat(destPath);
|
||||
info(stat.size);
|
||||
ok(stat.size > 0, "destination file is more than 0 bytes");
|
||||
|
||||
|
@ -10,7 +10,6 @@ const { LocalizationHelper } = require("devtools/shared/l10n");
|
||||
const STRINGS_URI = "devtools/client/locales/memory.properties";
|
||||
const L10N = (exports.L10N = new LocalizationHelper(STRINGS_URI));
|
||||
|
||||
const { OS } = require("resource://gre/modules/osfile.jsm");
|
||||
const { assert } = require("devtools/shared/DevToolsUtils");
|
||||
const { Preferences } = require("resource://gre/modules/Preferences.jsm");
|
||||
const CUSTOM_CENSUS_DISPLAY_PREF = "devtools.memory.custom-census-displays";
|
||||
@ -43,7 +42,7 @@ exports.getSnapshotTitle = function(snapshot) {
|
||||
|
||||
if (snapshot.imported) {
|
||||
// Strip out the extension if it's the expected ".fxsnapshot"
|
||||
return OS.Path.basename(snapshot.path.replace(/\.fxsnapshot$/, ""));
|
||||
return PathUtils.filename(snapshot.path.replace(/\.fxsnapshot$/, ""));
|
||||
}
|
||||
|
||||
const date = new Date(snapshot.creationTime / 1000);
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const ChromeUtils = require("ChromeUtils");
|
||||
const { L10N } = require("devtools/client/netmonitor/src/utils/l10n");
|
||||
|
||||
loader.lazyRequireGetter(
|
||||
@ -94,8 +93,7 @@ var HarMenuUtils = {
|
||||
|
||||
function readFile(file) {
|
||||
return new Promise(resolve => {
|
||||
const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
|
||||
OS.File.read(file.path).then(data => {
|
||||
IOUtils.read(file.path).then(data => {
|
||||
const decoder = new TextDecoder();
|
||||
resolve(decoder.decode(data));
|
||||
});
|
||||
|
@ -7,8 +7,6 @@
|
||||
|
||||
const TEST_URL = "data:text/html;charset=utf-8,";
|
||||
|
||||
const { OS } = require("resource://gre/modules/osfile.jsm");
|
||||
|
||||
addRDMTask(TEST_URL, async function({ ui }) {
|
||||
const { toolWindow } = ui;
|
||||
const { store, document } = toolWindow;
|
||||
@ -21,7 +19,7 @@ addRDMTask(TEST_URL, async function({ ui }) {
|
||||
|
||||
const filePath = await whenScreenshotSucceeded;
|
||||
const image = new Image();
|
||||
image.src = OS.Path.toFileURI(filePath);
|
||||
image.src = PathUtils.toFileURI(filePath);
|
||||
|
||||
await once(image, "load");
|
||||
|
||||
@ -41,5 +39,5 @@ addRDMTask(TEST_URL, async function({ ui }) {
|
||||
"screenshot width has the expected height"
|
||||
);
|
||||
|
||||
await OS.File.remove(filePath);
|
||||
await IOUtils.remove(filePath);
|
||||
});
|
||||
|
@ -52,7 +52,7 @@ addRDMTask(
|
||||
);
|
||||
|
||||
//Remove the downloaded screenshot file
|
||||
await OS.File.remove(filePath);
|
||||
await IOUtils.remove(filePath);
|
||||
await resetDownloads();
|
||||
},
|
||||
{ waitForDeviceList: true }
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
const { dumpn } = require("devtools/shared/DevToolsUtils");
|
||||
|
||||
loader.lazyImporter(this, "OS", "resource://gre/modules/osfile.jsm");
|
||||
loader.lazyImporter(
|
||||
this,
|
||||
"ExtensionParent",
|
||||
@ -26,13 +25,13 @@ loader.lazyRequireGetter(
|
||||
true
|
||||
);
|
||||
loader.lazyGetter(this, "UNPACKED_ROOT_PATH", () => {
|
||||
return OS.Path.join(OS.Constants.Path.localProfileDir, "adb");
|
||||
return PathUtils.join(PathUtils.localProfileDir, "adb");
|
||||
});
|
||||
loader.lazyGetter(this, "EXTENSION_ID", () => {
|
||||
return Services.prefs.getCharPref("devtools.remote.adb.extensionID");
|
||||
});
|
||||
loader.lazyGetter(this, "ADB_BINARY_PATH", () => {
|
||||
let adbBinaryPath = OS.Path.join(UNPACKED_ROOT_PATH, "adb");
|
||||
let adbBinaryPath = PathUtils.join(UNPACKED_ROOT_PATH, "adb");
|
||||
if (Services.appinfo.OS === "WINNT") {
|
||||
adbBinaryPath += ".exe";
|
||||
}
|
||||
@ -83,7 +82,7 @@ async function unpackFile(file) {
|
||||
|
||||
// Assumes that destination dir already exists.
|
||||
const basePath = file.substring(file.lastIndexOf("/") + 1);
|
||||
const filePath = OS.Path.join(UNPACKED_ROOT_PATH, basePath);
|
||||
const filePath = PathUtils.join(UNPACKED_ROOT_PATH, basePath);
|
||||
await new Promise((resolve, reject) => {
|
||||
NetUtil.asyncFetch(
|
||||
{
|
||||
@ -93,7 +92,7 @@ async function unpackFile(file) {
|
||||
input => {
|
||||
try {
|
||||
// Since we have to use NetUtil to read, probably it's okay to use for
|
||||
// writing, rather than bouncing to OS.File...?
|
||||
// writing, rather than bouncing to IOUtils...?
|
||||
const outputFile = new FileUtils.File(filePath);
|
||||
const output = FileUtils.openAtomicFileOutputStream(outputFile);
|
||||
NetUtil.asyncCopy(input, output, resolve);
|
||||
@ -105,7 +104,7 @@ async function unpackFile(file) {
|
||||
);
|
||||
});
|
||||
// Mark binaries as executable.
|
||||
await OS.File.setPermissions(filePath, { unixMode: 0o744 });
|
||||
await IOUtils.setPermissions(filePath, 0o744);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -154,7 +153,7 @@ async function extractFiles() {
|
||||
// comparison
|
||||
filesForAdb.push(MANIFEST);
|
||||
|
||||
await OS.File.makeDir(UNPACKED_ROOT_PATH);
|
||||
await IOUtils.makeDirectory(UNPACKED_ROOT_PATH);
|
||||
|
||||
for (const file of filesForAdb) {
|
||||
try {
|
||||
@ -185,21 +184,21 @@ async function getManifestFromExtension() {
|
||||
* Returns whether manifest.json has already been unpacked.
|
||||
*/
|
||||
async function isManifestUnpacked() {
|
||||
const manifestPath = OS.Path.join(UNPACKED_ROOT_PATH, MANIFEST);
|
||||
return OS.File.exists(manifestPath);
|
||||
const manifestPath = PathUtils.join(UNPACKED_ROOT_PATH, MANIFEST);
|
||||
return IOUtils.exists(manifestPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the manifest from the unpacked binary directory.
|
||||
* Uses OS.File since this is a local file.
|
||||
* Uses IOUtils since this is a local file.
|
||||
*/
|
||||
async function getManifestFromUnpacked() {
|
||||
if (!(await isManifestUnpacked())) {
|
||||
throw new Error("Manifest doesn't exist at unpacked path");
|
||||
}
|
||||
|
||||
const manifestPath = OS.Path.join(UNPACKED_ROOT_PATH, MANIFEST);
|
||||
const binary = await OS.File.read(manifestPath);
|
||||
const manifestPath = PathUtils.join(UNPACKED_ROOT_PATH, MANIFEST);
|
||||
const binary = await IOUtils.read(manifestPath);
|
||||
const json = new TextDecoder().decode(binary);
|
||||
let data;
|
||||
try {
|
||||
|
@ -9,7 +9,6 @@ const { LocalizationHelper } = require("devtools/shared/l10n");
|
||||
const Services = require("Services");
|
||||
|
||||
loader.lazyImporter(this, "Downloads", "resource://gre/modules/Downloads.jsm");
|
||||
loader.lazyImporter(this, "OS", "resource://gre/modules/osfile.jsm");
|
||||
loader.lazyImporter(this, "FileUtils", "resource://gre/modules/FileUtils.jsm");
|
||||
|
||||
const STRINGS_URI = "devtools/shared/locales/screenshot.properties";
|
||||
@ -347,11 +346,13 @@ async function saveToFile(image) {
|
||||
}
|
||||
|
||||
const downloadsDir = await Downloads.getPreferredDownloadsDirectory();
|
||||
const downloadsDirExists = await OS.File.exists(downloadsDir);
|
||||
const downloadsDirExists = await IOUtils.exists(downloadsDir);
|
||||
if (downloadsDirExists) {
|
||||
// If filename is absolute, it will override the downloads directory and
|
||||
// still be applied as expected.
|
||||
filename = OS.Path.join(downloadsDir, filename);
|
||||
filename = PathUtils.isAbsolute(filename)
|
||||
? filename
|
||||
: PathUtils.joinRelative(downloadsDir, filename);
|
||||
}
|
||||
|
||||
const sourceURI = Services.io.newURI(image.data);
|
||||
|
@ -1580,11 +1580,11 @@ async function takeNodeScreenshot(inspector) {
|
||||
info("Create an image using the downloaded fileas source");
|
||||
const image = new Image();
|
||||
const onImageLoad = once(image, "load");
|
||||
image.src = OS.Path.toFileURI(filePath);
|
||||
image.src = PathUtils.toFileURI(filePath);
|
||||
await onImageLoad;
|
||||
|
||||
info("Remove the downloaded screenshot file");
|
||||
await OS.File.remove(filePath);
|
||||
await IOUtils.remove(filePath);
|
||||
|
||||
// See intermittent Bug 1508435. Even after removing the file, tests still manage to
|
||||
// reuse files from the previous test if they have the same name. Since our file name
|
||||
|
@ -51,8 +51,6 @@ loader.lazyRequireGetter(
|
||||
"resource://gre/modules/NetUtil.jsm",
|
||||
true
|
||||
);
|
||||
loader.lazyRequireGetter(this, "OS", "resource://gre/modules/osfile.jsm", true);
|
||||
|
||||
loader.lazyRequireGetter(
|
||||
this,
|
||||
"ResponsiveUIManager",
|
||||
@ -1239,7 +1237,7 @@ class StyleEditorUI extends EventEmitter {
|
||||
|
||||
let linkedCSSSource = "";
|
||||
if (editor.linkedCSSFile) {
|
||||
linkedCSSSource = OS.Path.basename(editor.linkedCSSFile);
|
||||
linkedCSSSource = PathUtils.filename(editor.linkedCSSFile);
|
||||
} else if (editor.styleSheet.relatedEditorName) {
|
||||
linkedCSSSource = editor.styleSheet.relatedEditorName;
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ loader.lazyRequireGetter(
|
||||
"resource://gre/modules/NetUtil.jsm",
|
||||
true
|
||||
);
|
||||
loader.lazyRequireGetter(this, "OS", "resource://gre/modules/osfile.jsm", true);
|
||||
|
||||
const {
|
||||
getString,
|
||||
@ -263,8 +262,8 @@ StyleSheetEditor.prototype = {
|
||||
this.linkedCSSFileError = null;
|
||||
|
||||
// save last file change time so we can compare when we check for changes.
|
||||
OS.File.stat(path).then(info => {
|
||||
this._fileModDate = info.lastModificationDate.getTime();
|
||||
IOUtils.stat(path).then(info => {
|
||||
this._fileModDate = info.lastModified;
|
||||
}, this.markLinkedFileBroken);
|
||||
|
||||
this.emit("linked-css-file");
|
||||
@ -777,7 +776,9 @@ StyleSheetEditor.prototype = {
|
||||
|
||||
let defaultName;
|
||||
if (this._friendlyName) {
|
||||
defaultName = OS.Path.basename(this._friendlyName);
|
||||
defaultName = PathUtils.isAbsolute(this._friendlyName)
|
||||
? PathUtils.filename(this._friendlyName)
|
||||
: this._friendlyName;
|
||||
}
|
||||
showFilePicker(
|
||||
file || this._styleSheetFilePath,
|
||||
@ -818,8 +819,8 @@ StyleSheetEditor.prototype = {
|
||||
* if so, update the live style sheet.
|
||||
*/
|
||||
checkLinkedFileForChanges: function() {
|
||||
OS.File.stat(this.linkedCSSFile).then(info => {
|
||||
const lastChange = info.lastModificationDate.getTime();
|
||||
IOUtils.stat(this.linkedCSSFile).then(info => {
|
||||
const lastChange = info.lastModified;
|
||||
|
||||
if (this._fileModDate && lastChange != this._fileModDate) {
|
||||
this._fileModDate = lastChange;
|
||||
@ -866,7 +867,7 @@ StyleSheetEditor.prototype = {
|
||||
* file from disk and live update the stylesheet object with the contents.
|
||||
*/
|
||||
updateLinkedStyleSheet: function() {
|
||||
OS.File.read(this.linkedCSSFile).then(async array => {
|
||||
IOUtils.read(this.linkedCSSFile).then(async array => {
|
||||
const decoder = new TextDecoder();
|
||||
const text = decoder.decode(array);
|
||||
|
||||
@ -957,7 +958,7 @@ function findLinkedFilePath(uri, origUri, file) {
|
||||
const project = findProjectPath(file, origBranch);
|
||||
|
||||
const parts = project.concat(branch);
|
||||
const path = OS.Path.join.apply(this, parts);
|
||||
const path = PathUtils.join.apply(this, parts);
|
||||
|
||||
return path;
|
||||
}
|
||||
@ -976,7 +977,7 @@ function findLinkedFilePath(uri, origUri, file) {
|
||||
* array of path parts
|
||||
*/
|
||||
function findProjectPath(file, branch) {
|
||||
const path = OS.Path.split(file.path).components;
|
||||
const path = PathUtils.split(file.path);
|
||||
|
||||
for (let i = 2; i <= branch.length; i++) {
|
||||
// work backwards until we find a differing directory name
|
||||
@ -1002,8 +1003,8 @@ function findProjectPath(file, branch) {
|
||||
* object with 'branch' and 'origBranch' array of path parts for branch
|
||||
*/
|
||||
function findUnsharedBranches(origUri, uri) {
|
||||
origUri = OS.Path.split(origUri.pathQueryRef).components;
|
||||
uri = OS.Path.split(uri.pathQueryRef).components;
|
||||
origUri = PathUtils.split(origUri.pathQueryRef);
|
||||
uri = PathUtils.split(uri.pathQueryRef);
|
||||
|
||||
for (let i = 0; i < uri.length - 1; i++) {
|
||||
if (uri[i] != origUri[i]) {
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const ChromeUtils = require("ChromeUtils");
|
||||
const Services = require("Services");
|
||||
const { debounce } = require("devtools/shared/debounce");
|
||||
const isMacOS = Services.appinfo.OS === "Darwin";
|
||||
@ -761,8 +760,7 @@ class JSTerm extends Component {
|
||||
|
||||
function readFile(file) {
|
||||
return new Promise(resolve => {
|
||||
const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
|
||||
OS.File.read(file.path).then(data => {
|
||||
IOUtils.read(file.path).then(data => {
|
||||
const decoder = new TextDecoder();
|
||||
resolve(decoder.decode(data));
|
||||
});
|
||||
|
@ -54,7 +54,7 @@ add_task(async function() {
|
||||
|
||||
info("Create an image using the downloaded file as source");
|
||||
const image = new Image();
|
||||
image.src = OS.Path.toFileURI(file.path);
|
||||
image.src = PathUtils.toFileURI(file.path);
|
||||
await once(image, "load");
|
||||
|
||||
info(
|
||||
@ -106,6 +106,6 @@ add_task(async function() {
|
||||
});
|
||||
|
||||
info("Remove the downloaded screenshot file and cleanup downloads");
|
||||
await OS.File.remove(file.path);
|
||||
await IOUtils.remove(file.path);
|
||||
await resetDownloads();
|
||||
});
|
||||
|
@ -56,8 +56,8 @@ add_task(async function() {
|
||||
[isMacOS ? "metaKey" : "ctrlKey"]: true,
|
||||
});
|
||||
|
||||
await waitFor(() => OS.File.exists(nsiFile.path));
|
||||
const buffer = await OS.File.read(nsiFile.path);
|
||||
await waitFor(() => IOUtils.exists(nsiFile.path));
|
||||
const buffer = await IOUtils.read(nsiFile.path);
|
||||
const fileContent = new TextDecoder().decode(buffer);
|
||||
is(
|
||||
fileContent,
|
||||
|
@ -45,7 +45,7 @@ add_task(async function() {
|
||||
|
||||
info("Create an image using the downloaded file as source");
|
||||
const image = new Image();
|
||||
image.src = OS.Path.toFileURI(file.path);
|
||||
image.src = PathUtils.toFileURI(file.path);
|
||||
await once(image, "load");
|
||||
|
||||
// The page has the following structure
|
||||
@ -113,6 +113,6 @@ add_task(async function() {
|
||||
);
|
||||
|
||||
info("Remove the downloaded screenshot file and cleanup downloads");
|
||||
await OS.File.remove(file.path);
|
||||
await IOUtils.remove(file.path);
|
||||
await resetDownloads();
|
||||
});
|
||||
|
@ -40,7 +40,7 @@ add_task(async function() {
|
||||
|
||||
info("Create an image using the downloaded file as source");
|
||||
const image = new Image();
|
||||
image.src = OS.Path.toFileURI(actualFilePath);
|
||||
image.src = PathUtils.toFileURI(actualFilePath);
|
||||
await once(image, "load");
|
||||
|
||||
info("Check that the fixed element is rendered at the expected position");
|
||||
@ -67,6 +67,6 @@ add_task(async function() {
|
||||
);
|
||||
|
||||
info("Remove the downloaded screenshot file and cleanup downloads");
|
||||
await OS.File.remove(actualFilePath);
|
||||
await IOUtils.remove(actualFilePath);
|
||||
await resetDownloads();
|
||||
});
|
||||
|
@ -52,7 +52,7 @@ add_task(async function() {
|
||||
|
||||
info("Create an image using the downloaded file as source");
|
||||
let image = new Image();
|
||||
image.src = OS.Path.toFileURI(sameOriginIframeScreenshotFile.path);
|
||||
image.src = PathUtils.toFileURI(sameOriginIframeScreenshotFile.path);
|
||||
await once(image, "load");
|
||||
|
||||
info("Check that the node was rendered as expected in the screenshot");
|
||||
@ -65,7 +65,7 @@ add_task(async function() {
|
||||
});
|
||||
|
||||
// Remove the downloaded screenshot file and cleanup downloads
|
||||
await OS.File.remove(sameOriginIframeScreenshotFile.path);
|
||||
await IOUtils.remove(sameOriginIframeScreenshotFile.path);
|
||||
await resetDownloads();
|
||||
|
||||
info("Check using :screenshot --selector in a remote-iframe context");
|
||||
@ -114,7 +114,7 @@ add_task(async function() {
|
||||
|
||||
info("Create an image using the downloaded file as source");
|
||||
image = new Image();
|
||||
image.src = OS.Path.toFileURI(remoteIframeSpanScreenshot.path);
|
||||
image.src = PathUtils.toFileURI(remoteIframeSpanScreenshot.path);
|
||||
await once(image, "load");
|
||||
|
||||
info("Check that the node was rendered as expected in the screenshot");
|
||||
@ -141,6 +141,6 @@ add_task(async function() {
|
||||
);
|
||||
|
||||
// Remove the downloaded screenshot file and cleanup downloads
|
||||
await OS.File.remove(remoteIframeSpanScreenshot.path);
|
||||
await IOUtils.remove(remoteIframeSpanScreenshot.path);
|
||||
await resetDownloads();
|
||||
});
|
||||
|
@ -161,8 +161,8 @@ async function exportAllToFile(hud, message) {
|
||||
menuPopup.hidePopup();
|
||||
|
||||
// The file may not be ready yet.
|
||||
await waitFor(() => OS.File.exists(nsiFile.path));
|
||||
const buffer = await OS.File.read(nsiFile.path);
|
||||
await waitFor(() => IOUtils.exists(nsiFile.path));
|
||||
const buffer = await IOUtils.read(nsiFile.path);
|
||||
return new TextDecoder().decode(buffer);
|
||||
}
|
||||
|
||||
|
@ -3,9 +3,6 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const ChromeUtils = require("ChromeUtils");
|
||||
const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
|
||||
|
||||
const {
|
||||
getAdHocFrontOrPrimitiveGrip,
|
||||
} = require("devtools/client/fronts/object");
|
||||
@ -305,7 +302,7 @@ module.exports = {
|
||||
};
|
||||
`;
|
||||
|
||||
await OS.File.writeAtomic(filePath, fileContent);
|
||||
await IOUtils.write(filePath, fileContent);
|
||||
}
|
||||
|
||||
function getStubFile(fileName) {
|
||||
|
@ -16,7 +16,6 @@ loader.lazyRequireGetter(
|
||||
"DevToolsUtils",
|
||||
"devtools/shared/DevToolsUtils"
|
||||
);
|
||||
loader.lazyRequireGetter(this, "OS", "resource://gre/modules/osfile.jsm", true);
|
||||
loader.lazyRequireGetter(
|
||||
this,
|
||||
"HeapSnapshotFileUtils",
|
||||
@ -64,7 +63,7 @@ exports.HeapSnapshotFileActor = protocol.ActorClassWithSpec(
|
||||
|
||||
const streamPromise = DevToolsUtils.openFileStream(snapshotFilePath);
|
||||
|
||||
const { size } = await OS.File.stat(snapshotFilePath);
|
||||
const { size } = await IOUtils.stat(snapshotFilePath);
|
||||
const bulkPromise = this.conn.startBulkSend({
|
||||
actor: this.actorID,
|
||||
type: "heap-snapshot",
|
||||
|
@ -49,7 +49,6 @@ const SAFE_HOSTS_PREFIXES_REGEX = /^(about\+|https?\+|file\+|moz-extension\+)/;
|
||||
// devtools/server/tests/browser/head.js
|
||||
const SEPARATOR_GUID = "{9d414cc5-8319-0a04-0586-c0a6ae01670a}";
|
||||
|
||||
loader.lazyImporter(this, "OS", "resource://gre/modules/osfile.jsm");
|
||||
loader.lazyImporter(this, "Sqlite", "resource://gre/modules/Sqlite.jsm");
|
||||
|
||||
// We give this a funny name to avoid confusion with the global
|
||||
@ -2900,17 +2899,26 @@ var indexedDBHelpers = {
|
||||
* the browser.
|
||||
*/
|
||||
async getInternalHosts() {
|
||||
const profileDir = OS.Constants.Path.profileDir;
|
||||
const storagePath = OS.Path.join(profileDir, "storage", "permanent");
|
||||
const iterator = new OS.File.DirectoryIterator(storagePath);
|
||||
const profileDir = PathUtils.profileDir;
|
||||
const storagePath = PathUtils.join(profileDir, "storage", "permanent");
|
||||
const children = await IOUtils.getChildren(storagePath);
|
||||
const hosts = [];
|
||||
|
||||
await iterator.forEach(entry => {
|
||||
if (entry.isDir && !SAFE_HOSTS_PREFIXES_REGEX.test(entry.name)) {
|
||||
hosts.push(entry.name);
|
||||
for (const path of children) {
|
||||
const exists = await IOUtils.exists(path);
|
||||
if (!exists) {
|
||||
continue;
|
||||
}
|
||||
});
|
||||
iterator.close();
|
||||
|
||||
const stats = await IOUtils.stat(path);
|
||||
if (
|
||||
stats.type === "directory" &&
|
||||
!SAFE_HOSTS_PREFIXES_REGEX.test(stats.path)
|
||||
) {
|
||||
const basename = PathUtils.filename(path);
|
||||
hosts.push(basename);
|
||||
}
|
||||
}
|
||||
|
||||
return this.backToChild("getInternalHosts", hosts);
|
||||
},
|
||||
@ -3034,10 +3042,10 @@ var indexedDBHelpers = {
|
||||
*/
|
||||
async getDBNamesForHost(host, principal) {
|
||||
const sanitizedHost = this.getSanitizedHost(host) + principal.originSuffix;
|
||||
const profileDir = OS.Constants.Path.profileDir;
|
||||
const profileDir = PathUtils.profileDir;
|
||||
const storagePath = PathUtils.join(profileDir, "storage");
|
||||
const files = [];
|
||||
const names = [];
|
||||
const storagePath = OS.Path.join(profileDir, "storage");
|
||||
|
||||
// We expect sqlite DB paths to look something like this:
|
||||
// - PathToProfileDir/storage/default/http+++www.example.com/
|
||||
@ -3057,7 +3065,7 @@ var indexedDBHelpers = {
|
||||
);
|
||||
|
||||
for (const file of sqliteFiles) {
|
||||
const splitPath = OS.Path.split(file).components;
|
||||
const splitPath = PathUtils.split(file);
|
||||
const idbIndex = splitPath.indexOf("idb");
|
||||
const storage = splitPath[idbIndex - 2];
|
||||
const relative = file.substr(profileDir.length + 1);
|
||||
@ -3091,13 +3099,19 @@ var indexedDBHelpers = {
|
||||
const sqlitePaths = [];
|
||||
const idbPaths = await this.findIDBPathsForHost(storagePath, sanitizedHost);
|
||||
for (const idbPath of idbPaths) {
|
||||
const iterator = new OS.File.DirectoryIterator(idbPath);
|
||||
await iterator.forEach(entry => {
|
||||
if (!entry.isDir && entry.path.endsWith(".sqlite")) {
|
||||
sqlitePaths.push(entry.path);
|
||||
const children = await IOUtils.getChildren(idbPath);
|
||||
|
||||
for (const path of children) {
|
||||
const exists = await IOUtils.exists(path);
|
||||
if (!exists) {
|
||||
continue;
|
||||
}
|
||||
});
|
||||
iterator.close();
|
||||
|
||||
const stats = await IOUtils.stat(path);
|
||||
if (stats.type !== "directory" && stats.path.endsWith(".sqlite")) {
|
||||
sqlitePaths.push(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sqlitePaths;
|
||||
},
|
||||
@ -3110,8 +3124,8 @@ var indexedDBHelpers = {
|
||||
const idbPaths = [];
|
||||
const typePaths = await this.findStorageTypePaths(storagePath);
|
||||
for (const typePath of typePaths) {
|
||||
const idbPath = OS.Path.join(typePath, sanitizedHost, "idb");
|
||||
if (await OS.File.exists(idbPath)) {
|
||||
const idbPath = PathUtils.join(typePath, sanitizedHost, "idb");
|
||||
if (await IOUtils.exists(idbPath)) {
|
||||
idbPaths.push(idbPath);
|
||||
}
|
||||
}
|
||||
@ -3124,14 +3138,21 @@ var indexedDBHelpers = {
|
||||
* types that currently exist in the profile.
|
||||
*/
|
||||
async findStorageTypePaths(storagePath) {
|
||||
const iterator = new OS.File.DirectoryIterator(storagePath);
|
||||
const children = await IOUtils.getChildren(storagePath);
|
||||
const typePaths = [];
|
||||
await iterator.forEach(entry => {
|
||||
if (entry.isDir) {
|
||||
typePaths.push(entry.path);
|
||||
|
||||
for (const path of children) {
|
||||
const exists = await IOUtils.exists(path);
|
||||
if (!exists) {
|
||||
continue;
|
||||
}
|
||||
});
|
||||
iterator.close();
|
||||
|
||||
const stats = await IOUtils.stat(path);
|
||||
if (stats.type === "directory") {
|
||||
typePaths.push(path);
|
||||
}
|
||||
}
|
||||
|
||||
return typePaths;
|
||||
},
|
||||
|
||||
|
@ -6,14 +6,12 @@
|
||||
// Test that we can tell the memory actor to take a heap snapshot over the RDP
|
||||
// and then create a HeapSnapshot instance from the resulting file.
|
||||
|
||||
const { OS } = require("resource://gre/modules/osfile.jsm");
|
||||
|
||||
add_task(async () => {
|
||||
const { memoryFront } = await createTabMemoryFront();
|
||||
|
||||
const snapshotFilePath = await memoryFront.saveHeapSnapshot();
|
||||
ok(
|
||||
!!(await OS.File.stat(snapshotFilePath)),
|
||||
!!(await IOUtils.stat(snapshotFilePath)),
|
||||
"Should have the heap snapshot file"
|
||||
);
|
||||
const snapshot = ChromeUtils.readHeapSnapshot(snapshotFilePath);
|
||||
|
@ -6,8 +6,6 @@
|
||||
// Test that we can properly stream heap snapshot files over the RDP as bulk
|
||||
// data.
|
||||
|
||||
const { OS } = require("resource://gre/modules/osfile.jsm");
|
||||
|
||||
add_task(async () => {
|
||||
const { memoryFront } = await createTabMemoryFront();
|
||||
|
||||
@ -15,7 +13,7 @@ add_task(async () => {
|
||||
forceCopy: true,
|
||||
});
|
||||
ok(
|
||||
!!(await OS.File.stat(snapshotFilePath)),
|
||||
!!(await IOUtils.stat(snapshotFilePath)),
|
||||
"Should have the heap snapshot file"
|
||||
);
|
||||
const snapshot = ChromeUtils.readHeapSnapshot(snapshotFilePath);
|
||||
|
@ -6,14 +6,12 @@
|
||||
// Test that we can save full runtime heap snapshots when attached to the
|
||||
// ParentProcessTargetActor or a ContentProcessTargetActor.
|
||||
|
||||
const { OS } = require("resource://gre/modules/osfile.jsm");
|
||||
|
||||
add_task(async () => {
|
||||
const { memoryFront } = await createMainProcessMemoryFront();
|
||||
|
||||
const snapshotFilePath = await memoryFront.saveHeapSnapshot();
|
||||
ok(
|
||||
!!(await OS.File.stat(snapshotFilePath)),
|
||||
!!(await IOUtils.stat(snapshotFilePath)),
|
||||
"Should have the heap snapshot file"
|
||||
);
|
||||
const snapshot = ChromeUtils.readHeapSnapshot(snapshotFilePath);
|
||||
|
@ -493,10 +493,6 @@ DevToolsUtils.defineLazyGetter(this, "NetUtil", () => {
|
||||
return require("resource://gre/modules/NetUtil.jsm").NetUtil;
|
||||
});
|
||||
|
||||
DevToolsUtils.defineLazyGetter(this, "OS", () => {
|
||||
return require("resource://gre/modules/osfile.jsm").OS;
|
||||
});
|
||||
|
||||
DevToolsUtils.defineLazyGetter(this, "NetworkHelper", () => {
|
||||
return require("devtools/shared/webconsole/network-helper");
|
||||
});
|
||||
@ -669,12 +665,12 @@ function mainThreadFetch(
|
||||
ex.name === "NS_BASE_STREAM_CLOSED" &&
|
||||
uri instanceof Ci.nsIFileURL
|
||||
) {
|
||||
// Empty files cause NS_BASE_STREAM_CLOSED exception. Use OS.File to
|
||||
// Empty files cause NS_BASE_STREAM_CLOSED exception. Use IOUtils to
|
||||
// differentiate between empty files and other errors (bug 1170864).
|
||||
// This can be removed when bug 982654 is fixed.
|
||||
|
||||
uri.QueryInterface(Ci.nsIFileURL);
|
||||
const result = OS.File.read(uri.file.path).then(bytes => {
|
||||
const result = IOUtils.read(uri.file.path).then(bytes => {
|
||||
// Convert the bytearray to a String.
|
||||
const decoder = new TextDecoder();
|
||||
const content = decoder.decode(bytes);
|
||||
@ -846,7 +842,7 @@ exports.saveAs = async function(
|
||||
return;
|
||||
}
|
||||
|
||||
await OS.File.writeAtomic(returnFile.path, dataArray, {
|
||||
await IOUtils.write(returnFile.path, dataArray, {
|
||||
tmpPath: returnFile.path + ".tmp",
|
||||
});
|
||||
};
|
||||
|
@ -29,10 +29,9 @@ loader.lazyRequireGetter(
|
||||
"resource://gre/modules/FileUtils.jsm",
|
||||
true
|
||||
);
|
||||
loader.lazyRequireGetter(this, "OS", "resource://gre/modules/osfile.jsm", true);
|
||||
|
||||
function getHeapSnapshotFileTemplate() {
|
||||
return OS.Path.join(OS.Constants.Path.tmpDir, `${Date.now()}.fxsnapshot`);
|
||||
return PathUtils.join(PathUtils.osTempDir, `${Date.now()}.fxsnapshot`);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,7 +66,7 @@ exports.getHeapSnapshotTempFilePath = function(snapshotId) {
|
||||
if (!isValidSnapshotFileId(snapshotId)) {
|
||||
return null;
|
||||
}
|
||||
return OS.Path.join(OS.Constants.Path.tmpDir, snapshotId + ".fxsnapshot");
|
||||
return PathUtils.join(PathUtils.osTempDir, snapshotId + ".fxsnapshot");
|
||||
};
|
||||
|
||||
/**
|
||||
@ -82,7 +81,7 @@ exports.haveHeapSnapshotTempFile = function(snapshotId) {
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
|
||||
return OS.File.stat(path).then(
|
||||
return IOUtils.stat(path).then(
|
||||
() => true,
|
||||
() => false
|
||||
);
|
||||
|
@ -32,10 +32,12 @@ const {
|
||||
DOMQuad,
|
||||
DOMRect,
|
||||
HeapSnapshot,
|
||||
IOUtils,
|
||||
L10nRegistry,
|
||||
Localization,
|
||||
NamedNodeMap,
|
||||
NodeFilter,
|
||||
PathUtils,
|
||||
StructuredCloneHolder,
|
||||
TelemetryStopwatch,
|
||||
} = Cu.getGlobalForObject(jsmScope);
|
||||
@ -275,6 +277,7 @@ exports.globals = {
|
||||
Element,
|
||||
FileReader,
|
||||
FormData,
|
||||
IOUtils,
|
||||
isWorker: false,
|
||||
L10nRegistry,
|
||||
loader: {
|
||||
@ -287,6 +290,7 @@ exports.globals = {
|
||||
},
|
||||
Localization,
|
||||
Node,
|
||||
PathUtils,
|
||||
reportError: Cu.reportError,
|
||||
StructuredCloneHolder,
|
||||
TextDecoder,
|
||||
|
@ -7,7 +7,6 @@
|
||||
const { FileUtils } = ChromeUtils.import(
|
||||
"resource://gre/modules/FileUtils.jsm"
|
||||
);
|
||||
const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
|
||||
|
||||
const TEST_CONTENT = "aéd";
|
||||
|
||||
@ -26,7 +25,7 @@ add_task(async function test_arrow_urls() {
|
||||
const { path } = createTemporaryFile(".js");
|
||||
const url = "resource://gre/modules/XPIProvider.jsm -> file://" + path;
|
||||
|
||||
await OS.File.writeAtomic(path, TEST_CONTENT, { encoding: "utf-8" });
|
||||
await IOUtils.writeUTF8(path, TEST_CONTENT);
|
||||
const { content } = await DevToolsUtils.fetch(url);
|
||||
|
||||
deepEqual(content, TEST_CONTENT, "The file contents were correctly read.");
|
||||
@ -46,7 +45,7 @@ add_task(async function test_empty() {
|
||||
*/
|
||||
add_task(async function test_encoding_utf8() {
|
||||
const { path } = createTemporaryFile();
|
||||
await OS.File.writeAtomic(path, UTF8_TEST_BUFFER);
|
||||
await IOUtils.write(path, UTF8_TEST_BUFFER);
|
||||
|
||||
const { content } = await DevToolsUtils.fetch(path);
|
||||
deepEqual(
|
||||
@ -61,7 +60,7 @@ add_task(async function test_encoding_utf8() {
|
||||
*/
|
||||
add_task(async function test_encoding_iso_8859_1() {
|
||||
const { path } = createTemporaryFile();
|
||||
await OS.File.writeAtomic(path, ISO_8859_1_BUFFER);
|
||||
await IOUtils.write(path, ISO_8859_1_BUFFER);
|
||||
|
||||
const { content } = await DevToolsUtils.fetch(path);
|
||||
deepEqual(
|
||||
@ -92,7 +91,7 @@ add_task(async function test_missing() {
|
||||
add_task(async function test_schemeless_files() {
|
||||
const { path } = createTemporaryFile();
|
||||
|
||||
await OS.File.writeAtomic(path, TEST_CONTENT, { encoding: "utf-8" });
|
||||
await IOUtils.writeUTF8(path, TEST_CONTENT);
|
||||
|
||||
const { content } = await DevToolsUtils.fetch(path);
|
||||
deepEqual(content, TEST_CONTENT, "The content was correct.");
|
||||
|
@ -12,7 +12,6 @@ const {
|
||||
testSetup,
|
||||
testTeardown,
|
||||
} = require("damp-test/tests/head");
|
||||
const { OS } = require("resource://gre/modules/osfile.jsm");
|
||||
const { Downloads } = require("resource://gre/modules/Downloads.jsm");
|
||||
const Services = require("Services");
|
||||
|
||||
@ -32,8 +31,8 @@ module.exports = async function() {
|
||||
const filePath = await onScreenshotDownloaded;
|
||||
test.done();
|
||||
|
||||
//Remove the downloaded screenshot file
|
||||
await OS.File.remove(filePath);
|
||||
// Remove the downloaded screenshot file
|
||||
await IOUtils.remove(filePath);
|
||||
|
||||
// ⚠️ Even after removing the file, the test could still manage to reuse files from the
|
||||
// previous test run if they have the same name. Since the screenshot file name is based
|
||||
|
Loading…
x
Reference in New Issue
Block a user