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.

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

mercurial