dom/tests/mochitest/crypto/test_legacy.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/crypto/test_legacy.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,51 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <title>Test presence of legacy window.crypto features when
     1.8 +         MOZ_DISABLE_CRYPTOLEGACY is NOT set.</title>
     1.9 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
    1.10 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.11 +</head>
    1.12 +<body>
    1.13 +<script class="testbody" type="text/javascript">
    1.14 +
    1.15 +ok("crypto" in window, "crypto in window");
    1.16 +ok("version" in window.crypto, "version in window.crypto");
    1.17 +ok("enableSmartCardEvents" in window.crypto,
    1.18 +   "enableSmartCardEvents in window.crypto");
    1.19 +ok("generateCRMFRequest" in window.crypto,
    1.20 +   "generateCRMFRequest in window.crypto");
    1.21 +ok("importUserCertificates" in window.crypto,
    1.22 +   "importUserCertificates in window.crypto");
    1.23 +ok("signText" in window.crypto, "signText in window.crypto");
    1.24 +
    1.25 +function jsCallback () {
    1.26 +}
    1.27 +
    1.28 +try {
    1.29 +  window.crypto.generateCRMFRequest(null, null, null, null, jsCallback.toString());
    1.30 +  ok(false, "window.crypto.generateCRMFRequest failed, should throw error");
    1.31 +} catch (e) {
    1.32 +  ok(e.toString().search(/Failure/) > -1,
    1.33 +     "Expected error: ReqDN cannot be null");
    1.34 +}
    1.35 +
    1.36 +try {
    1.37 +  window.crypto.generateCRMFRequest(document.documentElement, null, null, null,
    1.38 +                                    null);
    1.39 +  ok(false, "window.crypto.generateCRMFRequest failed, should throw error");
    1.40 +} catch (e) {
    1.41 +  ok(e.toString().search(/Failure/) > -1,
    1.42 +     "Expected error: jsCallback cannot be null");
    1.43 +}
    1.44 +
    1.45 +try {
    1.46 +  window.crypto.generateCRMFRequest(document.documentElement, null, null, null,
    1.47 +                                    jsCallback.toString(), 1024);
    1.48 +  ok(false, "window.crypto.generateCRMFRequest failed, should throw error");
    1.49 +} catch (e) {
    1.50 +  ok(e.toString().search(/TypeError/) > -1,
    1.51 +     "Expected error: Not enough arguments");
    1.52 +}
    1.53 +</script>
    1.54 +</body></html>

mercurial