security/manager/ssl/tests/mochitest/browser/browser_certViewer.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/manager/ssl/tests/mochitest/browser/browser_certViewer.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,40 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +let gBugWindow;
     1.9 +
    1.10 +function onLoad() {
    1.11 +  gBugWindow.removeEventListener("load", onLoad);
    1.12 +  gBugWindow.addEventListener("unload", onUnload);
    1.13 +  gBugWindow.close();
    1.14 +}
    1.15 +
    1.16 +function onUnload() {
    1.17 +  gBugWindow.removeEventListener("unload", onUnload);
    1.18 +  window.focus();
    1.19 +  finish();
    1.20 +}
    1.21 +
    1.22 +// This test opens and then closes the certificate viewer to test that it
    1.23 +// does not cause assertion failures.
    1.24 +function test() {
    1.25 +  waitForExplicitFinish();
    1.26 +  let certCache = Cc["@mozilla.org/security/nsscertcache;1"]
    1.27 +                    .getService(Ci.nsINSSCertCache);
    1.28 +  certCache.cacheAllCerts();
    1.29 +  let certList = certCache.getX509CachedCerts();
    1.30 +  let enumerator = certList.getEnumerator();
    1.31 +  ok(enumerator.hasMoreElements(), "we have at least one certificate");
    1.32 +  let cert = enumerator.getNext().QueryInterface(Ci.nsIX509Cert);
    1.33 +  ok(cert, "found a certificate to look at");
    1.34 +  info("looking at certificate with nickname " + cert.nickname);
    1.35 +  let arg = {
    1.36 +    QueryInterface: function() this,
    1.37 +    getISupportAtIndex: function() this.cert,
    1.38 +    cert: cert
    1.39 +  };
    1.40 +  gBugWindow = window.openDialog("chrome://pippki/content/certViewer.xul",
    1.41 +                                 "", "", arg);
    1.42 +  gBugWindow.addEventListener("load", onLoad);
    1.43 +}

mercurial