Sat, 03 Jan 2015 20:18:00 +0100
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.
michael@0 | 1 | // -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | Components.utils.import("resource://gre/modules/Services.jsm"); |
michael@0 | 8 | |
michael@0 | 9 | var gConsole, gConsoleBundle, gTextBoxEval, gEvaluator, gCodeToEvaluate; |
michael@0 | 10 | var gFilter; |
michael@0 | 11 | |
michael@0 | 12 | /* :::::::: Console Initialization ::::::::::::::: */ |
michael@0 | 13 | |
michael@0 | 14 | window.onload = function() |
michael@0 | 15 | { |
michael@0 | 16 | gConsole = document.getElementById("ConsoleBox"); |
michael@0 | 17 | gConsoleBundle = document.getElementById("ConsoleBundle"); |
michael@0 | 18 | gTextBoxEval = document.getElementById("TextboxEval"); |
michael@0 | 19 | gEvaluator = document.getElementById("Evaluator"); |
michael@0 | 20 | gFilter = document.getElementById("Filter"); |
michael@0 | 21 | |
michael@0 | 22 | updateSortCommand(gConsole.sortOrder); |
michael@0 | 23 | updateModeCommand(gConsole.mode); |
michael@0 | 24 | |
michael@0 | 25 | gEvaluator.addEventListener("load", loadOrDisplayResult, true); |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | /* :::::::: Console UI Functions ::::::::::::::: */ |
michael@0 | 29 | |
michael@0 | 30 | function changeFilter() |
michael@0 | 31 | { |
michael@0 | 32 | gConsole.filter = gFilter.value; |
michael@0 | 33 | |
michael@0 | 34 | document.persist("ConsoleBox", "filter"); |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | function changeMode(aMode) |
michael@0 | 38 | { |
michael@0 | 39 | switch (aMode) { |
michael@0 | 40 | case "Errors": |
michael@0 | 41 | case "Warnings": |
michael@0 | 42 | case "Messages": |
michael@0 | 43 | gConsole.mode = aMode; |
michael@0 | 44 | break; |
michael@0 | 45 | case "All": |
michael@0 | 46 | gConsole.mode = null; |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | document.persist("ConsoleBox", "mode"); |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | function clearConsole() |
michael@0 | 53 | { |
michael@0 | 54 | gConsole.clear(); |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | function changeSortOrder(aOrder) |
michael@0 | 58 | { |
michael@0 | 59 | updateSortCommand(gConsole.sortOrder = aOrder); |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | function updateSortCommand(aOrder) |
michael@0 | 63 | { |
michael@0 | 64 | var orderString = aOrder == 'reverse' ? "Descend" : "Ascend"; |
michael@0 | 65 | var bc = document.getElementById("Console:sort"+orderString); |
michael@0 | 66 | bc.setAttribute("checked", true); |
michael@0 | 67 | |
michael@0 | 68 | orderString = aOrder == 'reverse' ? "Ascend" : "Descend"; |
michael@0 | 69 | bc = document.getElementById("Console:sort"+orderString); |
michael@0 | 70 | bc.setAttribute("checked", false); |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | function updateModeCommand(aMode) |
michael@0 | 74 | { |
michael@0 | 75 | /* aMode can end up invalid if it set by an extension that replaces */ |
michael@0 | 76 | /* mode and then it is uninstalled or disabled */ |
michael@0 | 77 | var bc = document.getElementById("Console:mode" + aMode) || |
michael@0 | 78 | document.getElementById("Console:modeAll"); |
michael@0 | 79 | bc.setAttribute("checked", true); |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | function onEvalKeyPress(aEvent) |
michael@0 | 83 | { |
michael@0 | 84 | if (aEvent.keyCode == 13) |
michael@0 | 85 | evaluateTypein(); |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | function evaluateTypein() |
michael@0 | 89 | { |
michael@0 | 90 | gCodeToEvaluate = gTextBoxEval.value; |
michael@0 | 91 | // reset the iframe first; the code will be evaluated in loadOrDisplayResult |
michael@0 | 92 | // below, once about:blank has completed loading (see bug 385092) |
michael@0 | 93 | gEvaluator.contentWindow.location = "about:blank"; |
michael@0 | 94 | } |
michael@0 | 95 | |
michael@0 | 96 | function loadOrDisplayResult() |
michael@0 | 97 | { |
michael@0 | 98 | if (gCodeToEvaluate) { |
michael@0 | 99 | gEvaluator.contentWindow.location = "javascript: " + |
michael@0 | 100 | gCodeToEvaluate.replace(/%/g, "%25"); |
michael@0 | 101 | gCodeToEvaluate = ""; |
michael@0 | 102 | return; |
michael@0 | 103 | } |
michael@0 | 104 | |
michael@0 | 105 | var resultRange = gEvaluator.contentDocument.createRange(); |
michael@0 | 106 | resultRange.selectNode(gEvaluator.contentDocument.documentElement); |
michael@0 | 107 | var result = resultRange.toString(); |
michael@0 | 108 | if (result) |
michael@0 | 109 | Services.console.logStringMessage(result); |
michael@0 | 110 | // or could use appendMessage which doesn't persist |
michael@0 | 111 | } |