xpcom/tests/TestWinReg.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
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 /*
     6  * This script is intended to be run using xpcshell
     7  */
     9 const nsIWindowsRegKey = Components.interfaces.nsIWindowsRegKey;
    10 const BASE_PATH = "SOFTWARE\\Mozilla\\Firefox";
    12 function idump(indent, str)
    13 {
    14   for (var j = 0; j < indent; ++j)
    15     dump(" ");
    16   dump(str);
    17 }
    19 function list_values(indent, key) {
    20   idump(indent, "{\n");
    21   var count = key.valueCount;
    22   for (var i = 0; i < count; ++i) {
    23     var vn = key.getValueName(i);
    24     var val = "";
    25     if (key.getValueType(vn) == nsIWindowsRegKey.TYPE_STRING) {
    26       val = key.readStringValue(vn);
    27     }
    28     if (vn == "") 
    29       idump(indent + 1, "(Default): \"" + val + "\"\n");
    30     else
    31       idump(indent + 1, vn + ": \"" + val + "\"\n");
    32   } 
    33   idump(indent, "}\n");
    34 }
    36 function list_children(indent, key) {
    37   list_values(indent, key);
    39   var count = key.childCount;
    40   for (var i = 0; i < count; ++i) {
    41     var cn = key.getChildName(i);
    42     idump(indent, "[" + cn + "]\n");
    43     list_children(indent + 1, key.openChild(cn, nsIWindowsRegKey.ACCESS_READ));
    44   }
    45 }
    47 // enumerate everything under BASE_PATH
    48 var key = Components.classes["@mozilla.org/windows-registry-key;1"].
    49     createInstance(nsIWindowsRegKey);
    50 key.open(nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE, BASE_PATH,
    51          nsIWindowsRegKey.ACCESS_READ);
    52 list_children(1, key);
    54 key.close();
    55 key.open(nsIWindowsRegKey.ROOT_KEY_CURRENT_USER, BASE_PATH,
    56          nsIWindowsRegKey.ACCESS_READ);
    57 list_children(1, key);

mercurial