|
1 /* Any copyright is dedicated to the public domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 // Bug 764718 - Test that mozbrowsererror works for a security error. |
|
5 |
|
6 "use strict"; |
|
7 |
|
8 SimpleTest.waitForExplicitFinish(); |
|
9 browserElementTestHelpers.setEnabledPref(true); |
|
10 browserElementTestHelpers.addPermission(); |
|
11 |
|
12 var iframe = null; |
|
13 function runTest() { |
|
14 iframe = document.createElement('iframe'); |
|
15 SpecialPowers.wrap(iframe).mozbrowser = true; |
|
16 document.body.appendChild(iframe); |
|
17 |
|
18 checkForGenericError(); |
|
19 } |
|
20 |
|
21 function checkForGenericError() { |
|
22 iframe.addEventListener("mozbrowsererror", function onGenericError(e) { |
|
23 iframe.removeEventListener(e.type, onGenericError); |
|
24 ok(true, "Got mozbrowsererror event."); |
|
25 ok(e.detail.type == "other", "Event's detail has a |type| param with the value '" + e.detail.type + "'."); |
|
26 |
|
27 checkForExpiredCertificateError(); |
|
28 }); |
|
29 |
|
30 iframe.src = "http://this_is_not_a_domain.example.com"; |
|
31 } |
|
32 |
|
33 function checkForExpiredCertificateError() { |
|
34 iframe.addEventListener("mozbrowsererror", function onCertError(e) { |
|
35 iframe.removeEventListener(e.type, onCertError); |
|
36 ok(true, "Got mozbrowsererror event."); |
|
37 ok(e.detail.type == "certerror", "Event's detail has a |type| param with the value '" + e.detail.type + "'."); |
|
38 |
|
39 checkForNoCertificateError(); |
|
40 }); |
|
41 |
|
42 iframe.src = "https://expired.example.com"; |
|
43 } |
|
44 |
|
45 |
|
46 function checkForNoCertificateError() { |
|
47 iframe.addEventListener("mozbrowsererror", function onCertError(e) { |
|
48 iframe.removeEventListener(e.type, onCertError); |
|
49 ok(true, "Got mozbrowsererror event."); |
|
50 ok(e.detail.type == "certerror", "Event's detail has a |type| param with the value '" + e.detail.type + "'."); |
|
51 |
|
52 SimpleTest.finish(); |
|
53 }); |
|
54 |
|
55 iframe.src = "https://nocert.example.com"; |
|
56 } |
|
57 |
|
58 addEventListener('testready', runTest); |