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.

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

mercurial