|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #include "nsCOMPtr.h" |
|
7 #include "nsIPrefService.h" |
|
8 #include "nsIX509CertDB.h" |
|
9 #include "nsServiceManagerUtils.h" |
|
10 |
|
11 int |
|
12 main(int argc, char* argv[]) |
|
13 { |
|
14 { |
|
15 NS_InitXPCOM2(nullptr, nullptr, nullptr); |
|
16 nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); |
|
17 if (!prefs) { |
|
18 return -1; |
|
19 } |
|
20 // When NSS initializes, it attempts to get some localized strings. |
|
21 // As a result, OS X and Windows flip out if this isn't set. |
|
22 // (This isn't done automatically since this test doesn't have a |
|
23 // lot of the other boilerplate components that would otherwise |
|
24 // keep the certificate db alive longer than we want it to.) |
|
25 nsresult rv = prefs->SetBoolPref("intl.locale.matchOS", true); |
|
26 if (NS_FAILED(rv)) { |
|
27 return -1; |
|
28 } |
|
29 nsCOMPtr<nsIX509CertDB> certdb(do_GetService(NS_X509CERTDB_CONTRACTID)); |
|
30 if (!certdb) { |
|
31 return -1; |
|
32 } |
|
33 } // this scopes the nsCOMPtrs |
|
34 // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM |
|
35 NS_ShutdownXPCOM(nullptr); |
|
36 return 0; |
|
37 } |