mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 23:05:42 +00:00
Bug 1745352 - Remove osfile.jsm from browser/components/extensions r=mixedpuppy
Differential Revision: https://phabricator.services.mozilla.com/D133843
This commit is contained in:
parent
d23553fd77
commit
eb763b09e7
@ -7,7 +7,6 @@
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
ctypes: "resource://gre/modules/ctypes.jsm",
|
||||
NativeManifests: "resource://gre/modules/NativeManifests.jsm",
|
||||
OS: "resource://gre/modules/osfile.jsm",
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(
|
||||
@ -38,12 +37,12 @@ this.pkcs11 = class extends ExtensionAPI {
|
||||
);
|
||||
if (hostInfo) {
|
||||
if (AppConstants.platform === "win") {
|
||||
hostInfo.manifest.path = OS.Path.join(
|
||||
OS.Path.dirname(hostInfo.path),
|
||||
hostInfo.manifest.path = PathUtils.join(
|
||||
PathUtils.parent(hostInfo.path),
|
||||
hostInfo.manifest.path
|
||||
);
|
||||
}
|
||||
let manifestLib = OS.Path.basename(hostInfo.manifest.path);
|
||||
let manifestLib = PathUtils.filename(hostInfo.manifest.path);
|
||||
if (AppConstants.platform !== "linux") {
|
||||
manifestLib = manifestLib.toLowerCase(manifestLib);
|
||||
}
|
||||
|
@ -3,28 +3,39 @@
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
ctypes: "resource://gre/modules/ctypes.jsm",
|
||||
MockRegistry: "resource://testing-common/MockRegistry.jsm",
|
||||
OS: "resource://gre/modules/osfile.jsm",
|
||||
});
|
||||
|
||||
do_get_profile();
|
||||
let tmpDir = FileUtils.getDir("TmpD", ["PKCS11"]);
|
||||
|
||||
let tmpDir;
|
||||
let baseDir;
|
||||
let slug =
|
||||
AppConstants.platform === "linux" ? "pkcs11-modules" : "PKCS11Modules";
|
||||
tmpDir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
|
||||
let baseDir = OS.Path.join(tmpDir.path, slug);
|
||||
OS.File.makeDir(baseDir);
|
||||
|
||||
registerCleanupFunction(() => {
|
||||
tmpDir.remove(true);
|
||||
add_task(async function setup() {
|
||||
let tmpDir = await IOUtils.createUniqueDirectory(
|
||||
await PathUtils.getTempDir(),
|
||||
"PKCS11"
|
||||
);
|
||||
|
||||
baseDir = PathUtils.join(tmpDir, slug);
|
||||
await IOUtils.createDirectory(baseDir);
|
||||
});
|
||||
|
||||
function getPath(filename) {
|
||||
return OS.Path.join(baseDir, filename);
|
||||
}
|
||||
registerCleanupFunction(async () => {
|
||||
await IOUtils.remove(tmpDir, { recursive: true });
|
||||
});
|
||||
|
||||
const testmodule =
|
||||
"../../../../../security/manager/ssl/tests/unit/pkcs11testmodule/" +
|
||||
ctypes.libraryName("pkcs11testmodule");
|
||||
const testmodule = PathUtils.join(
|
||||
PathUtils.parent(Services.dirsvc.get("CurWorkD", Ci.nsIFile).path, 5),
|
||||
"security",
|
||||
"manager",
|
||||
"ssl",
|
||||
"tests",
|
||||
"unit",
|
||||
"pkcs11testmodule",
|
||||
ctypes.libraryName("pkcs11testModule")
|
||||
);
|
||||
|
||||
// This function was inspired by the native messaging test under
|
||||
// toolkit/components/extensions
|
||||
@ -39,8 +50,8 @@ async function setupManifests(modules) {
|
||||
allowed_extensions: [module.id],
|
||||
};
|
||||
|
||||
let manifestPath = getPath(`${module.name}.json`);
|
||||
await OS.File.writeAtomic(manifestPath, JSON.stringify(manifest));
|
||||
let manifestPath = PathUtils.join(baseDir, `${module.name}.json`);
|
||||
await IOUtils.writeJSON(manifestPath, manifest);
|
||||
|
||||
return manifestPath;
|
||||
}
|
||||
@ -78,10 +89,6 @@ async function setupManifests(modules) {
|
||||
});
|
||||
|
||||
for (let module of modules) {
|
||||
if (!OS.Path.winIsAbsolute(module.path)) {
|
||||
let cwd = await OS.File.getCurrentDirectory();
|
||||
module.path = OS.Path.join(cwd, module.path);
|
||||
}
|
||||
let manifestPath = await writeManifest(module);
|
||||
registry.setValue(
|
||||
Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
|
||||
@ -248,13 +255,16 @@ add_task(async function test_pkcs11() {
|
||||
{
|
||||
name: "internalmodule",
|
||||
description: "Builtin Roots Module",
|
||||
path: ctypes.libraryName("nssckbi"),
|
||||
path: PathUtils.join(
|
||||
Services.dirsvc.get("CurWorkD", Ci.nsIFile).path,
|
||||
ctypes.libraryName("nssckbi")
|
||||
),
|
||||
id: "pkcs11@tests.mozilla.org",
|
||||
},
|
||||
{
|
||||
name: "osclientcerts",
|
||||
description: "OS Client Cert Module",
|
||||
path: OS.Path.join(libDir.path, ctypes.libraryName("osclientcerts")),
|
||||
path: PathUtils.join(libDir.path, ctypes.libraryName("osclientcerts")),
|
||||
id: "pkcs11@tests.mozilla.org",
|
||||
},
|
||||
]);
|
||||
|
Loading…
Reference in New Issue
Block a user