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