diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /toolkit/components/places/tests/bookmarks/test_818593-store-backup-metadata.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'toolkit/components/places/tests/bookmarks/test_818593-store-backup-metadata.js')
-rw-r--r-- | toolkit/components/places/tests/bookmarks/test_818593-store-backup-metadata.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/toolkit/components/places/tests/bookmarks/test_818593-store-backup-metadata.js b/toolkit/components/places/tests/bookmarks/test_818593-store-backup-metadata.js new file mode 100644 index 000000000..4ea07fb39 --- /dev/null +++ b/toolkit/components/places/tests/bookmarks/test_818593-store-backup-metadata.js @@ -0,0 +1,57 @@ +/* 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/. */ + +/** + * To confirm that metadata i.e. bookmark count is set and retrieved for + * automatic backups. + */ +function run_test() { + run_next_test(); +} + +add_task(function* test_saveBookmarksToJSONFile_and_create() +{ + // Add a bookmark + let uri = NetUtil.newURI("http://getfirefox.com/"); + let bookmarkId = + PlacesUtils.bookmarks.insertBookmark( + PlacesUtils.unfiledBookmarksFolderId, uri, + PlacesUtils.bookmarks.DEFAULT_INDEX, "Get Firefox!"); + + // Test saveBookmarksToJSONFile() + let backupFile = FileUtils.getFile("TmpD", ["bookmarks.json"]); + backupFile.create(Ci.nsILocalFile.NORMAL_FILE_TYPE, parseInt("0600", 8)); + + let nodeCount = yield PlacesBackups.saveBookmarksToJSONFile(backupFile, true); + do_check_true(nodeCount > 0); + do_check_true(backupFile.exists()); + do_check_eq(backupFile.leafName, "bookmarks.json"); + + // Ensure the backup would be copied to our backups folder when the original + // backup is saved somewhere else. + let recentBackup = yield PlacesBackups.getMostRecentBackup(); + let matches = OS.Path.basename(recentBackup).match(PlacesBackups.filenamesRegex); + do_check_eq(matches[2], nodeCount); + do_check_eq(matches[3].length, 24); + + // Clear all backups in our backups folder. + yield PlacesBackups.create(0); + do_check_eq((yield PlacesBackups.getBackupFiles()).length, 0); + + // Test create() which saves bookmarks with metadata on the filename. + yield PlacesBackups.create(); + do_check_eq((yield PlacesBackups.getBackupFiles()).length, 1); + + mostRecentBackupFile = yield PlacesBackups.getMostRecentBackup(); + do_check_neq(mostRecentBackupFile, null); + matches = OS.Path.basename(recentBackup).match(PlacesBackups.filenamesRegex); + do_check_eq(matches[2], nodeCount); + do_check_eq(matches[3].length, 24); + + // Cleanup + backupFile.remove(false); + yield PlacesBackups.create(0); + PlacesUtils.bookmarks.removeItem(bookmarkId); +}); + |