summaryrefslogtreecommitdiffstats
path: root/toolkit/components/places/tests/bookmarks/test_818584-discard-duplicate-backups.js
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-02-25 15:07:00 -0500
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-04-14 12:55:19 +0200
commiteb70e6e3d0bff11c25f14b1196025791bf2308fb (patch)
tree5ef4ce17db83c74d7b05ec12c8f59e095a6dd5bd /toolkit/components/places/tests/bookmarks/test_818584-discard-duplicate-backups.js
parent32ead795290b3399d56b4708fc75b77d296f6a1a (diff)
downloadUXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.gz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.lz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.xz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.zip
Issue #439 - Remove tests from toolkit/
Diffstat (limited to 'toolkit/components/places/tests/bookmarks/test_818584-discard-duplicate-backups.js')
-rw-r--r--toolkit/components/places/tests/bookmarks/test_818584-discard-duplicate-backups.js59
1 files changed, 0 insertions, 59 deletions
diff --git a/toolkit/components/places/tests/bookmarks/test_818584-discard-duplicate-backups.js b/toolkit/components/places/tests/bookmarks/test_818584-discard-duplicate-backups.js
deleted file mode 100644
index c88323478..000000000
--- a/toolkit/components/places/tests/bookmarks/test_818584-discard-duplicate-backups.js
+++ /dev/null
@@ -1,59 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Checks that automatically created bookmark backups are discarded if they are
- * duplicate of an existing ones.
- */
-function run_test() {
- run_next_test();
-}
-
-add_task(function*() {
- // Create a backup for yesterday in the backups folder.
- let backupFolder = yield PlacesBackups.getBackupFolder();
- let dateObj = new Date();
- dateObj.setDate(dateObj.getDate() - 1);
- let oldBackupName = PlacesBackups.getFilenameForDate(dateObj);
- let oldBackup = OS.Path.join(backupFolder, oldBackupName);
- let {count: count, hash: hash} = yield BookmarkJSONUtils.exportToFile(oldBackup);
- do_check_true(count > 0);
- do_check_eq(hash.length, 24);
- oldBackupName = oldBackupName.replace(/\.json/, "_" + count + "_" + hash + ".json");
- yield OS.File.move(oldBackup, OS.Path.join(backupFolder, oldBackupName));
-
- // Create a backup.
- // This should just rename the existing backup, so in the end there should be
- // only one backup with today's date.
- yield PlacesBackups.create();
-
- // Get the hash of the generated backup
- let backupFiles = yield PlacesBackups.getBackupFiles();
- do_check_eq(backupFiles.length, 1);
-
- let matches = OS.Path.basename(backupFiles[0]).match(PlacesBackups.filenamesRegex);
- do_check_eq(matches[1], PlacesBackups.toISODateString(new Date()));
- do_check_eq(matches[2], count);
- do_check_eq(matches[3], hash);
-
- // Add a bookmark and create another backup.
- let bookmarkId = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.bookmarks.bookmarksMenuFolder,
- uri("http://foo.com"),
- PlacesUtils.bookmarks.DEFAULT_INDEX,
- "foo");
- // We must enforce a backup since one for today already exists. The forced
- // backup will replace the existing one.
- yield PlacesBackups.create(undefined, true);
- do_check_eq(backupFiles.length, 1);
- recentBackup = yield PlacesBackups.getMostRecentBackup();
- do_check_neq(recentBackup, OS.Path.join(backupFolder, oldBackupName));
- matches = OS.Path.basename(recentBackup).match(PlacesBackups.filenamesRegex);
- do_check_eq(matches[1], PlacesBackups.toISODateString(new Date()));
- do_check_eq(matches[2], count + 1);
- do_check_neq(matches[3], hash);
-
- // Clean up
- PlacesUtils.bookmarks.removeItem(bookmarkId);
- yield PlacesBackups.create(0);
-});