/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; dump("######################## BrowserElementChildPreload.js loaded\n"); var BrowserElementIsReady = false; let { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/BrowserElementPromptService.jsm"); // Event whitelisted for bubbling. let whitelistedEvents = [ Ci.nsIDOMKeyEvent.DOM_VK_ESCAPE, // Back button. Ci.nsIDOMKeyEvent.DOM_VK_SLEEP, // Power button. Ci.nsIDOMKeyEvent.DOM_VK_CONTEXT_MENU, Ci.nsIDOMKeyEvent.DOM_VK_F5, // Search button. Ci.nsIDOMKeyEvent.DOM_VK_PAGE_UP, // Volume up. Ci.nsIDOMKeyEvent.DOM_VK_PAGE_DOWN // Volume down. ]; function debug(msg) { //dump("BrowserElementChildPreload - " + msg + "\n"); } function sendAsyncMsg(msg, data) { // Ensure that we don't send any messages before BrowserElementChild.js // finishes loading. if (!BrowserElementIsReady) return; if (!data) { data = { }; } data.msg_name = msg; sendAsyncMessage('browser-element-api:call', data); } function sendSyncMsg(msg, data) { // Ensure that we don't send any messages before BrowserElementChild.js // finishes loading. if (!BrowserElementIsReady) return; if (!data) { data = { }; } data.msg_name = msg; return sendSyncMessage('browser-element-api:call', data); } let CERTIFICATE_ERROR_PAGE_PREF = 'security.alternate_certificate_error_page'; let NS_ERROR_MODULE_BASE_OFFSET = 0x45; let NS_ERROR_MODULE_SECURITY= 21; function NS_ERROR_GET_MODULE(err) { return ((((err) >> 16) - NS_ERROR_MODULE_BASE_OFFSET) & 0x1fff); } function NS_ERROR_GET_CODE(err) { return ((err) & 0xffff); } let SEC_ERROR_BASE = Ci.nsINSSErrorsService.NSS_SEC_ERROR_BASE; let SEC_ERROR_UNKNOWN_ISSUER = (SEC_ERROR_BASE + 13); let SEC_ERROR_CA_CERT_INVALID = (SEC_ERROR_BASE + 36); let SEC_ERROR_UNTRUSTED_ISSUER = (SEC_ERROR_BASE + 20); let SEC_ERROR_EXPIRED_ISSUER_CERTIFICATE = (SEC_ERROR_BASE + 30); let SEC_ERROR_UNTRUSTED_CERT = (SEC_ERROR_BASE + 21); let SEC_ERROR_INADEQUATE_KEY_USAGE = (SEC_ERROR_BASE + 90); let SEC_ERROR_EXPIRED_CERTIFICATE = (SEC_ERROR_BASE + 11); let SEC_ERROR_CERT_SIGNATURE_ALGORITHM_DISABLED = (SEC_ERROR_BASE + 176); let SSL_ERROR_BASE = Ci.nsINSSErrorsService.NSS_SSL_ERROR_BASE; let SSL_ERROR_BAD_CERT_DOMAIN = (SSL_ERROR_BASE + 12); function getErrorClass(errorCode) { let NSPRCode = -1 * NS_ERROR_GET_CODE(errorCode); switch (NSPRCode) { case SEC_ERROR_UNKNOWN_ISSUER: case SEC_ERROR_CA_CERT_INVALID: case SEC_ERROR_UNTRUSTED_ISSUER: case SEC_ERROR_EXPIRED_ISSUER_CERTIFICATE: case SEC_ERROR_UNTRUSTED_CERT: case SEC_ERROR_INADEQUATE_KEY_USAGE: case SSL_ERROR_BAD_CERT_DOMAIN: case SEC_ERROR_EXPIRED_CERTIFICATE: case SEC_ERROR_CERT_SIGNATURE_ALGORITHM_DISABLED: return Ci.nsINSSErrorsService.ERROR_CLASS_BAD_CERT; default: return Ci.nsINSSErrorsService.ERROR_CLASS_SSL_PROTOCOL; } return null; } const OBSERVED_EVENTS = [ 'fullscreen-origin-change', 'ask-parent-to-exit-fullscreen', 'ask-parent-to-rollback-fullscreen', 'xpcom-shutdown', 'activity-done' ]; /** * The BrowserElementChild implements one half of