b2g/chrome/content/ErrorPage.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial