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 | /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | const Cc = Components.classes; |
michael@0 | 7 | const Ci = Components.interfaces; |
michael@0 | 8 | |
michael@0 | 9 | function run_test() |
michael@0 | 10 | { |
michael@0 | 11 | // Create the base directory. |
michael@0 | 12 | let base = Cc['@mozilla.org/file/directory_service;1'] |
michael@0 | 13 | .getService(Ci.nsIProperties) |
michael@0 | 14 | .get('TmpD', Ci.nsILocalFile); |
michael@0 | 15 | base.append('renameTesting'); |
michael@0 | 16 | if (base.exists()) { |
michael@0 | 17 | base.remove(true); |
michael@0 | 18 | } |
michael@0 | 19 | base.create(Ci.nsIFile.DIRECTORY_TYPE, parseInt('0777', 8)); |
michael@0 | 20 | |
michael@0 | 21 | // Create a sub directory under the base. |
michael@0 | 22 | let subdir = base.clone(); |
michael@0 | 23 | subdir.append('subdir'); |
michael@0 | 24 | subdir.create(Ci.nsIFile.DIRECTORY_TYPE, parseInt('0777', 8)); |
michael@0 | 25 | |
michael@0 | 26 | // Create a file under the sub directory. |
michael@0 | 27 | let tempFile = subdir.clone(); |
michael@0 | 28 | tempFile.append('file0.txt'); |
michael@0 | 29 | tempFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, parseInt('0777', 8)); |
michael@0 | 30 | |
michael@0 | 31 | // Test renameTo in the base directory |
michael@0 | 32 | tempFile.renameTo(null, 'file1.txt'); |
michael@0 | 33 | do_check_true(exists(subdir, 'file1.txt')); |
michael@0 | 34 | |
michael@0 | 35 | // Test moving across directories |
michael@0 | 36 | tempFile = subdir.clone(); |
michael@0 | 37 | tempFile.append('file1.txt'); |
michael@0 | 38 | tempFile.renameTo(base, ''); |
michael@0 | 39 | do_check_true(exists(base, 'file1.txt')); |
michael@0 | 40 | |
michael@0 | 41 | // Test moving across directories and renaming at the same time |
michael@0 | 42 | tempFile = base.clone(); |
michael@0 | 43 | tempFile.append('file1.txt'); |
michael@0 | 44 | tempFile.renameTo(subdir, 'file2.txt'); |
michael@0 | 45 | do_check_true(exists(subdir, 'file2.txt')); |
michael@0 | 46 | |
michael@0 | 47 | // Test moving a directory |
michael@0 | 48 | subdir.renameTo(base, 'renamed'); |
michael@0 | 49 | do_check_true(exists(base, 'renamed')); |
michael@0 | 50 | let renamed = base.clone(); |
michael@0 | 51 | renamed.append('renamed'); |
michael@0 | 52 | do_check_true(exists(renamed, 'file2.txt')); |
michael@0 | 53 | |
michael@0 | 54 | base.remove(true); |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | function exists(parent, filename) { |
michael@0 | 58 | let file = parent.clone(); |
michael@0 | 59 | file.append(filename); |
michael@0 | 60 | return file.exists(); |
michael@0 | 61 | } |