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 | /* 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 | var gIOS = Cc["@mozilla.org/network/io-service;1"] |
michael@0 | 7 | .getService(Ci.nsIIOService); |
michael@0 | 8 | |
michael@0 | 9 | function test_uri(obj) |
michael@0 | 10 | { |
michael@0 | 11 | var uri = null; |
michael@0 | 12 | var failed = false; |
michael@0 | 13 | var message = ""; |
michael@0 | 14 | try { |
michael@0 | 15 | uri = gIOS.newURI(obj.uri, null, null); |
michael@0 | 16 | if (!obj.result) { |
michael@0 | 17 | failed = true; |
michael@0 | 18 | message = obj.uri + " should not be accepted as a valid URI"; |
michael@0 | 19 | } |
michael@0 | 20 | } |
michael@0 | 21 | catch (ex) { |
michael@0 | 22 | if (obj.result) { |
michael@0 | 23 | failed = true; |
michael@0 | 24 | message = obj.uri + " should be accepted as a valid URI"; |
michael@0 | 25 | } |
michael@0 | 26 | } |
michael@0 | 27 | if (failed) |
michael@0 | 28 | do_throw(message); |
michael@0 | 29 | if (obj.result) { |
michael@0 | 30 | do_check_true(uri != null); |
michael@0 | 31 | do_check_eq(uri.spec, obj.uri); |
michael@0 | 32 | } |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | function run_test() |
michael@0 | 36 | { |
michael@0 | 37 | var tests = [ |
michael@0 | 38 | {uri: "chrome://blah/content/blah.xul", result: true}, |
michael@0 | 39 | {uri: "chrome://blah/content/:/blah/blah.xul", result: false}, |
michael@0 | 40 | {uri: "chrome://blah/content/%252e./blah/blah.xul", result: false}, |
michael@0 | 41 | {uri: "chrome://blah/content/%252e%252e/blah/blah.xul", result: false}, |
michael@0 | 42 | {uri: "chrome://blah/content/blah.xul?param=%252e./blah/", result: true}, |
michael@0 | 43 | {uri: "chrome://blah/content/blah.xul?param=:/blah/", result: true}, |
michael@0 | 44 | {uri: "chrome://blah/content/blah.xul?param=%252e%252e/blah/", result: true}, |
michael@0 | 45 | ]; |
michael@0 | 46 | for (var i = 0; i < tests.length; ++ i) |
michael@0 | 47 | test_uri(tests[i]); |
michael@0 | 48 | } |