michael@0: /* Any copyright is dedicated to the public domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // Bug 764718 - Test that mozbrowsererror works for a security error. michael@0: michael@0: "use strict"; michael@0: michael@0: SimpleTest.waitForExplicitFinish(); michael@0: browserElementTestHelpers.setEnabledPref(true); michael@0: browserElementTestHelpers.addPermission(); michael@0: michael@0: var iframe = null; michael@0: function runTest() { michael@0: iframe = document.createElement('iframe'); michael@0: SpecialPowers.wrap(iframe).mozbrowser = true; michael@0: document.body.appendChild(iframe); michael@0: michael@0: checkForGenericError(); michael@0: } michael@0: michael@0: function checkForGenericError() { michael@0: iframe.addEventListener("mozbrowsererror", function onGenericError(e) { michael@0: iframe.removeEventListener(e.type, onGenericError); michael@0: ok(true, "Got mozbrowsererror event."); michael@0: ok(e.detail.type == "other", "Event's detail has a |type| param with the value '" + e.detail.type + "'."); michael@0: michael@0: checkForExpiredCertificateError(); michael@0: }); michael@0: michael@0: iframe.src = "http://this_is_not_a_domain.example.com"; michael@0: } michael@0: michael@0: function checkForExpiredCertificateError() { michael@0: iframe.addEventListener("mozbrowsererror", function onCertError(e) { michael@0: iframe.removeEventListener(e.type, onCertError); michael@0: ok(true, "Got mozbrowsererror event."); michael@0: ok(e.detail.type == "certerror", "Event's detail has a |type| param with the value '" + e.detail.type + "'."); michael@0: michael@0: checkForNoCertificateError(); michael@0: }); michael@0: michael@0: iframe.src = "https://expired.example.com"; michael@0: } michael@0: michael@0: michael@0: function checkForNoCertificateError() { michael@0: iframe.addEventListener("mozbrowsererror", function onCertError(e) { michael@0: iframe.removeEventListener(e.type, onCertError); michael@0: ok(true, "Got mozbrowsererror event."); michael@0: ok(e.detail.type == "certerror", "Event's detail has a |type| param with the value '" + e.detail.type + "'."); michael@0: michael@0: SimpleTest.finish(); michael@0: }); michael@0: michael@0: iframe.src = "https://nocert.example.com"; michael@0: } michael@0: michael@0: addEventListener('testready', runTest);