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 | const Ci = Components.interfaces; |
michael@0 | 6 | |
michael@0 | 7 | function run_test() { |
michael@0 | 8 | // throw if anything goes wrong |
michael@0 | 9 | |
michael@0 | 10 | // find the current directory path |
michael@0 | 11 | var file = Components.classes["@mozilla.org/file/directory_service;1"] |
michael@0 | 12 | .getService(Ci.nsIProperties) |
michael@0 | 13 | .get("CurWorkD", Ci.nsIFile); |
michael@0 | 14 | file.append("xpcshell.ini"); |
michael@0 | 15 | |
michael@0 | 16 | // should be able to construct a file |
michael@0 | 17 | var f1 = File(file.path); |
michael@0 | 18 | // with either constructor syntax |
michael@0 | 19 | var f2 = new File(file.path); |
michael@0 | 20 | // and with nsIFiles |
michael@0 | 21 | var f3 = File(file); |
michael@0 | 22 | var f4 = new File(file); |
michael@0 | 23 | |
michael@0 | 24 | // do some tests |
michael@0 | 25 | do_check_true(f1 instanceof Ci.nsIDOMFile, "Should be a DOM File"); |
michael@0 | 26 | do_check_true(f2 instanceof Ci.nsIDOMFile, "Should be a DOM File"); |
michael@0 | 27 | do_check_true(f3 instanceof Ci.nsIDOMFile, "Should be a DOM File"); |
michael@0 | 28 | do_check_true(f4 instanceof Ci.nsIDOMFile, "Should be a DOM File"); |
michael@0 | 29 | |
michael@0 | 30 | do_check_true(f1.name == "xpcshell.ini", "Should be the right file"); |
michael@0 | 31 | do_check_true(f2.name == "xpcshell.ini", "Should be the right file"); |
michael@0 | 32 | do_check_true(f3.name == "xpcshell.ini", "Should be the right file"); |
michael@0 | 33 | do_check_true(f4.name == "xpcshell.ini", "Should be the right file"); |
michael@0 | 34 | |
michael@0 | 35 | do_check_true(f1.type == "", "Should be the right type"); |
michael@0 | 36 | do_check_true(f2.type == "", "Should be the right type"); |
michael@0 | 37 | do_check_true(f3.type == "", "Should be the right type"); |
michael@0 | 38 | do_check_true(f4.type == "", "Should be the right type"); |
michael@0 | 39 | |
michael@0 | 40 | var threw = false; |
michael@0 | 41 | try { |
michael@0 | 42 | // Needs a ctor argument |
michael@0 | 43 | var f7 = File(); |
michael@0 | 44 | } catch (e) { |
michael@0 | 45 | threw = true; |
michael@0 | 46 | } |
michael@0 | 47 | do_check_true(threw, "No ctor arguments should throw"); |
michael@0 | 48 | |
michael@0 | 49 | var threw = false; |
michael@0 | 50 | try { |
michael@0 | 51 | // Needs a valid ctor argument |
michael@0 | 52 | var f7 = File(Date(132131532)); |
michael@0 | 53 | } catch (e) { |
michael@0 | 54 | threw = true; |
michael@0 | 55 | } |
michael@0 | 56 | do_check_true(threw, "Passing a random object should fail"); |
michael@0 | 57 | |
michael@0 | 58 | var threw = false |
michael@0 | 59 | try { |
michael@0 | 60 | // Directories fail |
michael@0 | 61 | var dir = Components.classes["@mozilla.org/file/directory_service;1"] |
michael@0 | 62 | .getService(Ci.nsIProperties) |
michael@0 | 63 | .get("CurWorkD", Ci.nsIFile); |
michael@0 | 64 | var f7 = File(dir) |
michael@0 | 65 | } catch (e) { |
michael@0 | 66 | threw = true; |
michael@0 | 67 | } |
michael@0 | 68 | do_check_true(threw, "Can't create a File object for a directory"); |
michael@0 | 69 | } |