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 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | Bug 943251 - Allow accessing about:config from app-manager |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <meta charset="utf-8"> |
michael@0 | 8 | <title>Test Preference Actor</title> |
michael@0 | 9 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"> |
michael@0 | 11 | </head> |
michael@0 | 12 | <body> |
michael@0 | 13 | <pre id="test"> |
michael@0 | 14 | <script> |
michael@0 | 15 | |
michael@0 | 16 | function runTests() { |
michael@0 | 17 | var Cu = Components.utils; |
michael@0 | 18 | var Cc = Components.classes; |
michael@0 | 19 | var Ci = Components.interfaces; |
michael@0 | 20 | |
michael@0 | 21 | Cu.import("resource://gre/modules/devtools/Loader.jsm"); |
michael@0 | 22 | Cu.import("resource://gre/modules/devtools/dbg-client.jsm"); |
michael@0 | 23 | Cu.import("resource://gre/modules/devtools/dbg-server.jsm"); |
michael@0 | 24 | Cu.import("resource://gre/modules/Services.jsm"); |
michael@0 | 25 | |
michael@0 | 26 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 27 | |
michael@0 | 28 | var {getPreferenceFront} = devtools.require("devtools/server/actors/preference"); |
michael@0 | 29 | |
michael@0 | 30 | DebuggerServer.init(function () { return true; }); |
michael@0 | 31 | DebuggerServer.addBrowserActors(); |
michael@0 | 32 | |
michael@0 | 33 | var client = new DebuggerClient(DebuggerServer.connectPipe()); |
michael@0 | 34 | client.connect(function onConnect() { |
michael@0 | 35 | client.listTabs(function onListTabs(aResponse) { |
michael@0 | 36 | var p = getPreferenceFront(client, aResponse); |
michael@0 | 37 | |
michael@0 | 38 | var prefs = {}; |
michael@0 | 39 | |
michael@0 | 40 | var localPref = { |
michael@0 | 41 | boolPref: true, |
michael@0 | 42 | intPref: 0x1234, |
michael@0 | 43 | charPref: "Hello World", |
michael@0 | 44 | }; |
michael@0 | 45 | |
michael@0 | 46 | |
michael@0 | 47 | function checkValues() { |
michael@0 | 48 | is(prefs.boolPref, localPref.boolPref, "read/write bool pref"); |
michael@0 | 49 | is(prefs.intPref, localPref.intPref, "read/write int pref"); |
michael@0 | 50 | is(prefs.charPref, localPref.charPref, "read/write string pref"); |
michael@0 | 51 | |
michael@0 | 52 | ["test.all.bool", "test.all.int", "test.all.string"].forEach(function(key) { |
michael@0 | 53 | var expectedValue; |
michael@0 | 54 | switch(Services.prefs.getPrefType(key)) { |
michael@0 | 55 | case Ci.nsIPrefBranch.PREF_STRING: |
michael@0 | 56 | expectedValue = Services.prefs.getCharPref(key); |
michael@0 | 57 | break; |
michael@0 | 58 | case Ci.nsIPrefBranch.PREF_INT: |
michael@0 | 59 | expectedValue = Services.prefs.getIntPref(key); |
michael@0 | 60 | break; |
michael@0 | 61 | case Ci.nsIPrefBranch.PREF_BOOL: |
michael@0 | 62 | expectedValue = Services.prefs.getBoolPref(key); |
michael@0 | 63 | break; |
michael@0 | 64 | default: |
michael@0 | 65 | ok(false, "unexpected pref type (" + key + ")"); |
michael@0 | 66 | break; |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | is(prefs.allPrefs[key].value, expectedValue, "valid preference value (" + key + ")"); |
michael@0 | 70 | is(prefs.allPrefs[key].hasUserValue, Services.prefs.prefHasUserValue(key), "valid hasUserValue (" + key + ")"); |
michael@0 | 71 | }); |
michael@0 | 72 | |
michael@0 | 73 | ["test.bool", "test.int", "test.string"].forEach(function(key) { |
michael@0 | 74 | ok(!prefs.allPrefs.hasOwnProperty(key), "expect no pref (" + key + ")"); |
michael@0 | 75 | is(Services.prefs.getPrefType(key), Ci.nsIPrefBranch.PREF_INVALID, "pref (" + key + ") is clear"); |
michael@0 | 76 | }); |
michael@0 | 77 | |
michael@0 | 78 | client.close(() => { |
michael@0 | 79 | DebuggerServer.destroy(); |
michael@0 | 80 | SimpleTest.finish() |
michael@0 | 81 | }); |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | |
michael@0 | 85 | p.getAllPrefs().then((json) => prefs["allPrefs"] = json) |
michael@0 | 86 | .then(() => p.setBoolPref("test.bool", localPref.boolPref)) |
michael@0 | 87 | .then(() => p.setIntPref("test.int", localPref.intPref)) |
michael@0 | 88 | .then(() => p.setCharPref("test.string", localPref.charPref)) |
michael@0 | 89 | .then(() => p.getBoolPref("test.bool")).then((value) => prefs["boolPref"] = value) |
michael@0 | 90 | .then(() => p.getIntPref("test.int")).then((value) => prefs["intPref"] = value) |
michael@0 | 91 | .then(() => p.getCharPref("test.string")).then((value) => prefs["charPref"] = value) |
michael@0 | 92 | .then(() => p.clearUserPref("test.bool")) |
michael@0 | 93 | .then(() => p.clearUserPref("test.int")) |
michael@0 | 94 | .then(() => p.clearUserPref("test.string")) |
michael@0 | 95 | .then(checkValues); |
michael@0 | 96 | |
michael@0 | 97 | }); |
michael@0 | 98 | }); |
michael@0 | 99 | |
michael@0 | 100 | } |
michael@0 | 101 | |
michael@0 | 102 | window.onload = function () { |
michael@0 | 103 | SpecialPowers.pushPrefEnv({ |
michael@0 | 104 | "set": [ |
michael@0 | 105 | ["devtools.debugger.forbid-certified-apps", false], |
michael@0 | 106 | ["test.all.bool", true], |
michael@0 | 107 | ["test.all.int", 0x4321], |
michael@0 | 108 | ["test.all.string", "allizom"], |
michael@0 | 109 | ] |
michael@0 | 110 | }, runTests); |
michael@0 | 111 | } |
michael@0 | 112 | </script> |
michael@0 | 113 | </pre> |
michael@0 | 114 | </body> |
michael@0 | 115 | </html> |