|
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()"> |
|
8 |
|
9 <script class="testbody" type="text/javascript"> |
|
10 |
|
11 SimpleTest.waitForExplicitFinish(); |
|
12 |
|
13 function badCertListener() |
|
14 { |
|
15 } |
|
16 |
|
17 badCertListener.prototype = { |
|
18 badCertCaught: false, |
|
19 |
|
20 getInterface: function (aIID) { |
|
21 return this.QueryInterface(aIID); |
|
22 }, |
|
23 |
|
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; |
|
29 |
|
30 throw SpecialPowers.Cr.NS_ERROR_NO_INTERFACE; |
|
31 }, |
|
32 |
|
33 notifyCertProblem: function(socketInfo, sslStatus, targetHost) { |
|
34 this.badCertCaught = true; |
|
35 return true; |
|
36 } |
|
37 } |
|
38 |
|
39 function onFrameLoad() |
|
40 { |
|
41 ok(false, "Attackers page failed to load"); |
|
42 } |
|
43 |
|
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 } |
|
59 |
|
60 ok(certListener.badCertCaught, "We Caught the invalid certificate"); |
|
61 |
|
62 SimpleTest.finish(); |
|
63 } |
|
64 |
|
65 </script> |
|
66 |
|
67 <iframe src="https://www.bank2.com/" onload="onFrameLoad()"></iframe> |
|
68 </body> |
|
69 </html> |