diff options
Diffstat (limited to 'toolkit/components/extensions/test/mochitest/test_chrome_native_messaging_paths.html')
-rw-r--r-- | toolkit/components/extensions/test/mochitest/test_chrome_native_messaging_paths.html | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_native_messaging_paths.html b/toolkit/components/extensions/test/mochitest/test_chrome_native_messaging_paths.html new file mode 100644 index 0000000000..c29b6286d9 --- /dev/null +++ b/toolkit/components/extensions/test/mochitest/test_chrome_native_messaging_paths.html @@ -0,0 +1,58 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>WebExtension test</title> + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + <script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script> + <script type="text/javascript" src="head.js"></script> + <link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> +</head> +<body> + +<script type="text/javascript"> +"use strict"; + +// Test that the default paths searched for native host manifests +// are the ones we expect. +add_task(async function test_default_paths() { + let expectUser, expectGlobal; + switch (AppConstants.platform) { + case "macosx": { + expectUser = PathUtils.joinRelative( + Services.dirsvc.get("Home", Ci.nsIFile).path, + "Library/Application Support/Mozilla" + ); + expectGlobal = "/Library/Application Support/Mozilla"; + + break; + } + + case "linux": { + expectUser = PathUtils.join( + Services.dirsvc.get("Home", Ci.nsIFile).path, + ".mozilla" + ); + + const libdir = AppConstants.HAVE_USR_LIB64_DIR ? "lib64" : "lib"; + expectGlobal = PathUtils.join("/usr", libdir, "mozilla"); + break; + } + + default: + // Fixed filesystem paths are only defined for MacOS and Linux, + // there's nothing to test on other platforms. + ok(false, `This test does not apply on ${AppConstants.platform}`); + break; + } + + let userDir = Services.dirsvc.get("XREUserNativeManifests", Ci.nsIFile).path; + is(userDir, expectUser, "user-specific native messaging directory is correct"); + + let globalDir = Services.dirsvc.get("XRESysNativeManifests", Ci.nsIFile).path; + is(globalDir, expectGlobal, "system-wide native messaing directory is correct"); +}); + +</script> + +</body> +</html> |