dom/browser-element/mochitest/browserElement_ErrorSecurity.js

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     1 /* Any copyright is dedicated to the public domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 // Bug 764718 - Test that mozbrowsererror works for a security error.
     6 "use strict";
     8 SimpleTest.waitForExplicitFinish();
     9 browserElementTestHelpers.setEnabledPref(true);
    10 browserElementTestHelpers.addPermission();
    12 var iframe = null;
    13 function runTest() {
    14   iframe = document.createElement('iframe');
    15   SpecialPowers.wrap(iframe).mozbrowser = true;
    16   document.body.appendChild(iframe);
    18   checkForGenericError();
    19 }
    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 + "'.");
    27     checkForExpiredCertificateError();
    28   });
    30   iframe.src = "http://this_is_not_a_domain.example.com";
    31 }
    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 + "'.");
    39     checkForNoCertificateError();
    40   });
    42   iframe.src = "https://expired.example.com";
    43 }
    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 + "'.");
    52     SimpleTest.finish();
    53   });
    55   iframe.src = "https://nocert.example.com";
    56 }
    58 addEventListener('testready', runTest);

mercurial