summaryrefslogtreecommitdiffstats
path: root/browser/components/shell/test/unit/test_macOS_showSecurityPreferences.js
blob: 8550f0331a0a0dcd1cfd4a2689ea15a3497ff275 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* Any copyright is dedicated to the Public Domain.
 * https://creativecommons.org/publicdomain/zero/1.0/ */

/**
 * Test the macOS ShowSecurityPreferences shell service method.
 */

function killSystemPreferences() {
  let killallFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
  killallFile.initWithPath("/usr/bin/killall");
  let sysPrefsArg = ["System Preferences"];
  let process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
  process.init(killallFile);
  process.run(true, sysPrefsArg, 1);
  return process.exitValue;
}

add_setup(async function() {
  info("Ensure System Preferences isn't already running");
  killSystemPreferences();
});

add_task(async function test_prefsOpen() {
  let shellSvc = Cc["@mozilla.org/browser/shell-service;1"].getService(
    Ci.nsIMacShellService
  );
  shellSvc.showSecurityPreferences("Privacy_AllFiles");

  equal(killSystemPreferences(), 0, "Ensure System Preferences was started");
});