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 file, |
michael@0 | 3 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | /** |
michael@0 | 6 | * Checks that automatically created bookmark backups are discarded if they are |
michael@0 | 7 | * duplicate of an existing ones. |
michael@0 | 8 | */ |
michael@0 | 9 | function run_test() { |
michael@0 | 10 | run_next_test(); |
michael@0 | 11 | } |
michael@0 | 12 | |
michael@0 | 13 | add_task(function() { |
michael@0 | 14 | // Create a backup for yesterday in the backups folder. |
michael@0 | 15 | let backupFolder = yield PlacesBackups.getBackupFolder(); |
michael@0 | 16 | let dateObj = new Date(); |
michael@0 | 17 | dateObj.setDate(dateObj.getDate() - 1); |
michael@0 | 18 | let oldBackupName = PlacesBackups.getFilenameForDate(dateObj); |
michael@0 | 19 | let oldBackup = OS.Path.join(backupFolder, oldBackupName); |
michael@0 | 20 | let {count: count, hash: hash} = yield BookmarkJSONUtils.exportToFile(oldBackup); |
michael@0 | 21 | do_check_true(count > 0); |
michael@0 | 22 | do_check_eq(hash.length, 24); |
michael@0 | 23 | oldBackupName = oldBackupName.replace(/\.json/, "_" + count + "_" + hash + ".json"); |
michael@0 | 24 | yield OS.File.move(oldBackup, OS.Path.join(backupFolder, oldBackupName)); |
michael@0 | 25 | |
michael@0 | 26 | // Create a backup. |
michael@0 | 27 | // This should just rename the existing backup, so in the end there should be |
michael@0 | 28 | // only one backup with today's date. |
michael@0 | 29 | yield PlacesBackups.create(); |
michael@0 | 30 | |
michael@0 | 31 | // Get the hash of the generated backup |
michael@0 | 32 | let backupFiles = yield PlacesBackups.getBackupFiles(); |
michael@0 | 33 | do_check_eq(backupFiles.length, 1); |
michael@0 | 34 | |
michael@0 | 35 | let matches = OS.Path.basename(backupFiles[0]).match(PlacesBackups.filenamesRegex); |
michael@0 | 36 | do_check_eq(matches[1], new Date().toLocaleFormat("%Y-%m-%d")); |
michael@0 | 37 | do_check_eq(matches[2], count); |
michael@0 | 38 | do_check_eq(matches[3], hash); |
michael@0 | 39 | |
michael@0 | 40 | // Add a bookmark and create another backup. |
michael@0 | 41 | let bookmarkId = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.bookmarks.bookmarksMenuFolder, |
michael@0 | 42 | uri("http://foo.com"), |
michael@0 | 43 | PlacesUtils.bookmarks.DEFAULT_INDEX, |
michael@0 | 44 | "foo"); |
michael@0 | 45 | // We must enforce a backup since one for today already exists. The forced |
michael@0 | 46 | // backup will replace the existing one. |
michael@0 | 47 | yield PlacesBackups.create(undefined, true); |
michael@0 | 48 | do_check_eq(backupFiles.length, 1); |
michael@0 | 49 | recentBackup = yield PlacesBackups.getMostRecentBackup(); |
michael@0 | 50 | do_check_neq(recentBackup, OS.Path.join(backupFolder, oldBackupName)); |
michael@0 | 51 | matches = OS.Path.basename(recentBackup).match(PlacesBackups.filenamesRegex); |
michael@0 | 52 | do_check_eq(matches[1], new Date().toLocaleFormat("%Y-%m-%d")); |
michael@0 | 53 | do_check_eq(matches[2], count + 1); |
michael@0 | 54 | do_check_neq(matches[3], hash); |
michael@0 | 55 | |
michael@0 | 56 | // Clean up |
michael@0 | 57 | PlacesUtils.bookmarks.removeItem(bookmarkId); |
michael@0 | 58 | yield PlacesBackups.create(0); |
michael@0 | 59 | }); |