tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_macOS_showSecurityPreferences.js (1270B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * https://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 /**
      5 * Test the macOS ShowSecurityPreferences shell service method.
      6 */
      7 
      8 "use strict";
      9 
     10 // eslint-disable-next-line mozilla/no-redeclare-with-import-autofix
     11 const { AppConstants } = ChromeUtils.importESModule(
     12  "resource://gre/modules/AppConstants.sys.mjs"
     13 );
     14 
     15 function killSystemPreferences() {
     16  let killallFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
     17  killallFile.initWithPath("/usr/bin/killall");
     18  let sysPrefsArg = ["System Preferences"];
     19  if (AppConstants.isPlatformAndVersionAtLeast("macosx", 22)) {
     20    sysPrefsArg = ["System Settings"];
     21  }
     22  let process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
     23  process.init(killallFile);
     24  process.run(true, sysPrefsArg, 1);
     25  return process.exitValue;
     26 }
     27 
     28 add_setup(async function () {
     29  info("Ensure System Preferences isn't already running");
     30  killSystemPreferences();
     31 });
     32 
     33 add_task(async function test_prefsOpen() {
     34  let shellSvc = Cc["@mozilla.org/browser/shell-service;1"].getService(
     35    Ci.nsIMacShellService
     36  );
     37  shellSvc.showSecurityPreferences("Privacy_AllFiles");
     38 
     39  equal(killSystemPreferences(), 0, "Ensure System Preferences was started");
     40 });