b2g/chrome/content/ErrorPage.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 'use strict';
michael@0 6
michael@0 7 let Cu = Components.utils;
michael@0 8 let Cc = Components.classes;
michael@0 9 let Ci = Components.interfaces;
michael@0 10
michael@0 11 dump("############ ErrorPage.js\n");
michael@0 12
michael@0 13 let ErrorPageHandler = {
michael@0 14 _reload: function() {
michael@0 15 docShell.QueryInterface(Ci.nsIWebNavigation).reload(Ci.nsIWebNavigation.LOAD_FLAGS_NONE);
michael@0 16 },
michael@0 17
michael@0 18 _certErrorPageEventHandler: function(e) {
michael@0 19 let target = e.originalTarget;
michael@0 20 let errorDoc = target.ownerDocument;
michael@0 21
michael@0 22 // If the event came from an ssl error page, it is one of the "Add
michael@0 23 // Exception…" buttons.
michael@0 24 if (/^about:certerror\?e=nssBadCert/.test(errorDoc.documentURI)) {
michael@0 25 let permanent = errorDoc.getElementById("permanentExceptionButton");
michael@0 26 let temp = errorDoc.getElementById("temporaryExceptionButton");
michael@0 27 if (target == temp || target == permanent) {
michael@0 28 sendAsyncMessage("ErrorPage:AddCertException", {
michael@0 29 url: errorDoc.location.href,
michael@0 30 isPermanent: target == permanent
michael@0 31 });
michael@0 32 }
michael@0 33 }
michael@0 34 },
michael@0 35
michael@0 36 _bindPageEvent: function(target) {
michael@0 37 if (!target) {
michael@0 38 return;
michael@0 39 }
michael@0 40
michael@0 41 if (/^about:certerror/.test(target.documentURI)) {
michael@0 42 let errorPageEventHandler = this._certErrorPageEventHandler.bind(this);
michael@0 43 addEventListener("click", errorPageEventHandler, true, false);
michael@0 44 let listener = function() {
michael@0 45 removeEventListener("click", errorPageEventHandler, true);
michael@0 46 removeEventListener("pagehide", listener, true);
michael@0 47 }.bind(this);
michael@0 48
michael@0 49 addEventListener("pagehide", listener, true);
michael@0 50 }
michael@0 51 },
michael@0 52
michael@0 53 domContentLoadedHandler: function(e) {
michael@0 54 let target = e.originalTarget;
michael@0 55 let targetDocShell = target.defaultView
michael@0 56 .QueryInterface(Ci.nsIInterfaceRequestor)
michael@0 57 .getInterface(Ci.nsIWebNavigation);
michael@0 58 if (targetDocShell != docShell) {
michael@0 59 return;
michael@0 60 }
michael@0 61 this._bindPageEvent(target);
michael@0 62 },
michael@0 63
michael@0 64 init: function() {
michael@0 65 addMessageListener("ErrorPage:ReloadPage", this._reload.bind(this));
michael@0 66 addEventListener('DOMContentLoaded',
michael@0 67 this.domContentLoadedHandler.bind(this),
michael@0 68 true);
michael@0 69 this._bindPageEvent(content.document);
michael@0 70 }
michael@0 71 };
michael@0 72
michael@0 73 ErrorPageHandler.init();

mercurial