security/manager/ssl/tests/mochitest/bugs/test_bug480619.html

Wed, 31 Dec 2014 07:16:47 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:16:47 +0100
branch
TOR_BUG_9701
changeset 3
141e0f1194b1
permissions
-rw-r--r--

Revert simplistic fix pending revisit of Mozilla integration attempt.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <head>
     4   <title>Test bug 480619</title>
     5   <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>        
     6   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
     7 </head>
     8 <body>
    10 <script class="testbody" type="text/javascript">
    12 const Cc = Components.classes;
    13 const Ci = Components.interfaces;
    15 SimpleTest.waitForExplicitFinish();
    17 var currentThread = Cc["@mozilla.org/thread-manager;1"].
    18                     getService(Ci.nsIThreadManager).
    19                     currentThread;
    20 var socketTransportService = Cc["@mozilla.org/network/socket-transport-service;1"].
    21                              getService(Ci.nsISocketTransportService);
    23 var tearDown = false;
    25 var reader = {
    26   onInputStreamReady: function(stream) {
    27     try {
    28       stream.available();
    29       SimpleTest.ok(false, "Stream should be in an error state");
    30     }
    31     catch (e) {
    32       SimpleTest.is(e.result, Components.results.NS_ERROR_FAILURE,
    33                     "The stream should be inside an error state");
    34       SimpleTest.ok(tearDown, "The stream should be closed after a teardown of secure decoder ring");
    35     }
    36     SimpleTest.finish();
    37   }
    38 };
    40 var sink = {
    41   onTransportStatus: function(transport, status, progress, progressmax) {
    42     if (status == Ci.nsISocketTransport.STATUS_CONNECTED_TO) {
    43       // Try to logout and tear down the secure decoder ring.
    44       // This should close and stream and notify the reader.
    45       // The test will time out if this fails.
    46       tearDown = true;
    47       Cc["@mozilla.org/security/sdr;1"].
    48         getService(Ci.nsISecretDecoderRing).
    49         logoutAndTeardown();
    50     }
    51   }
    52 };
    54 var transport = socketTransportService.createTransport(["ssl"], 1, "127.0.0.1", 4443, null);
    56 transport.setEventSink(sink, currentThread);
    58 var inStream = transport.openInputStream(0, 0, 0)
    59                         .QueryInterface(Ci.nsIAsyncInputStream);
    61 inStream.asyncWait(reader, Ci.nsIAsyncInputStream.WAIT_CLOSURE_ONLY, 0, currentThread);
    63 </script>
    64 </body>
    65 </html>

mercurial