security/manager/ssl/tests/compiled/TestCertDB.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/manager/ssl/tests/compiled/TestCertDB.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,37 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "nsCOMPtr.h"
    1.10 +#include "nsIPrefService.h"
    1.11 +#include "nsIX509CertDB.h"
    1.12 +#include "nsServiceManagerUtils.h"
    1.13 +
    1.14 +int
    1.15 +main(int argc, char* argv[])
    1.16 +{
    1.17 +  {
    1.18 +    NS_InitXPCOM2(nullptr, nullptr, nullptr);
    1.19 +    nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
    1.20 +    if (!prefs) {
    1.21 +      return -1;
    1.22 +    }
    1.23 +    // When NSS initializes, it attempts to get some localized strings.
    1.24 +    // As a result, OS X and Windows flip out if this isn't set.
    1.25 +    // (This isn't done automatically since this test doesn't have a
    1.26 +    // lot of the other boilerplate components that would otherwise
    1.27 +    // keep the certificate db alive longer than we want it to.)
    1.28 +    nsresult rv = prefs->SetBoolPref("intl.locale.matchOS", true);
    1.29 +    if (NS_FAILED(rv)) {
    1.30 +      return -1;
    1.31 +    }
    1.32 +    nsCOMPtr<nsIX509CertDB> certdb(do_GetService(NS_X509CERTDB_CONTRACTID));
    1.33 +    if (!certdb) {
    1.34 +      return -1;
    1.35 +    }
    1.36 +  } // this scopes the nsCOMPtrs
    1.37 +  // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
    1.38 +  NS_ShutdownXPCOM(nullptr);
    1.39 +  return 0;
    1.40 +}

mercurial