security/manager/ssl/tests/mochitest/bugs/test_bug484111.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 <html>
     2 <head>
     3   <title>Test bug 484111</title>
     4   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
     5   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     6 </head>
     7 <body onload="onWindowLoad()">
     9 <script class="testbody" type="text/javascript">
    11 SimpleTest.waitForExplicitFinish();
    13 function badCertListener() 
    14 {
    15 }
    17 badCertListener.prototype = {
    18   badCertCaught: false,
    20   getInterface: function (aIID) {
    21     return this.QueryInterface(aIID);
    22   },
    24   QueryInterface: function(aIID) {
    25     if (aIID.equals(SpecialPowers.Ci.nsIBadCertListener2) ||
    26         aIID.equals(SpecialPowers.Ci.nsIInterfaceRequestor) ||
    27         aIID.equals(SpecialPowers.Ci.nsISupports))
    28       return this;
    30     throw SpecialPowers.Cr.NS_ERROR_NO_INTERFACE;
    31   },  
    33   notifyCertProblem: function(socketInfo, sslStatus, targetHost) {
    34     this.badCertCaught = true;
    35     return true;
    36   }
    37 }
    39 function onFrameLoad()
    40 {
    41   ok(false, "Attackers page failed to load");
    42 }
    44 function onWindowLoad()
    45 {
    46   var req = new XMLHttpRequest();
    47   var certListener = new badCertListener();
    48   certListener = SpecialPowers.wrapCallbackObject(certListener);
    49   try
    50   {
    51     req.open("GET", "https://www.bank2.com/", false);
    52     SpecialPowers.wrap(req).channel.notificationCallbacks = certListener;
    53     req.send(null);
    54   }
    55   catch(ex)
    56   {
    57     // ignore
    58   }
    60   ok(certListener.badCertCaught, "We Caught the invalid certificate");
    62   SimpleTest.finish();
    63 }
    65 </script>
    67 <iframe src="https://www.bank2.com/" onload="onFrameLoad()"></iframe>
    68 </body>
    69 </html>

mercurial