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 /browser/components/places/tests/unit/test_421483.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 'browser/components/places/tests/unit/test_421483.js')
-rw-r--r-- | browser/components/places/tests/unit/test_421483.js | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/browser/components/places/tests/unit/test_421483.js b/browser/components/places/tests/unit/test_421483.js new file mode 100644 index 000000000..a0d138372 --- /dev/null +++ b/browser/components/places/tests/unit/test_421483.js @@ -0,0 +1,103 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et: */ +/* 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/. */ + + +const SMART_BOOKMARKS_PREF = "browser.places.smartBookmarksVersion"; + +var gluesvc = Cc["@mozilla.org/browser/browserglue;1"]. + getService(Ci.nsIObserver); +// Avoid default bookmarks import. +gluesvc.observe(null, "initial-migration-will-import-default-bookmarks", ""); + +function run_test() { + run_next_test(); +} + +add_task(function* smart_bookmarks_disabled() { + Services.prefs.setIntPref("browser.places.smartBookmarksVersion", -1); + yield rebuildSmartBookmarks(); + + let smartBookmarkItemIds = + PlacesUtils.annotations.getItemsWithAnnotation(SMART_BOOKMARKS_ANNO); + Assert.equal(smartBookmarkItemIds.length, 0); + + do_print("check that pref has not been bumped up"); + Assert.equal(Services.prefs.getIntPref("browser.places.smartBookmarksVersion"), -1); +}); + +add_task(function* create_smart_bookmarks() { + Services.prefs.setIntPref("browser.places.smartBookmarksVersion", 0); + yield rebuildSmartBookmarks(); + + let smartBookmarkItemIds = + PlacesUtils.annotations.getItemsWithAnnotation(SMART_BOOKMARKS_ANNO); + Assert.notEqual(smartBookmarkItemIds.length, 0); + + do_print("check that pref has been bumped up"); + Assert.ok(Services.prefs.getIntPref("browser.places.smartBookmarksVersion") > 0); +}); + +add_task(function* remove_smart_bookmark_and_restore() { + let smartBookmarkItemIds = + PlacesUtils.annotations.getItemsWithAnnotation(SMART_BOOKMARKS_ANNO); + let smartBookmarksCount = smartBookmarkItemIds.length; + do_print("remove one smart bookmark and restore"); + + let guid = yield PlacesUtils.promiseItemGuid(smartBookmarkItemIds[0]); + yield PlacesUtils.bookmarks.remove(guid); + Services.prefs.setIntPref("browser.places.smartBookmarksVersion", 0); + + yield rebuildSmartBookmarks(); + smartBookmarkItemIds = + PlacesUtils.annotations.getItemsWithAnnotation(SMART_BOOKMARKS_ANNO); + Assert.equal(smartBookmarkItemIds.length, smartBookmarksCount); + + do_print("check that pref has been bumped up"); + Assert.ok(Services.prefs.getIntPref("browser.places.smartBookmarksVersion") > 0); +}); + +add_task(function* move_smart_bookmark_rename_and_restore() { + let smartBookmarkItemIds = + PlacesUtils.annotations.getItemsWithAnnotation(SMART_BOOKMARKS_ANNO); + let smartBookmarksCount = smartBookmarkItemIds.length; + do_print("smart bookmark should be restored in place"); + + let guid = yield PlacesUtils.promiseItemGuid(smartBookmarkItemIds[0]); + let bm = yield PlacesUtils.bookmarks.fetch(guid); + let oldTitle = bm.title; + + // create a subfolder and move inside it + let subfolder = yield PlacesUtils.bookmarks.insert({ + parentGuid: bm.parentGuid, + title: "test", + index: PlacesUtils.bookmarks.DEFAULT_INDEX, + type: PlacesUtils.bookmarks.TYPE_FOLDER + }); + + // change title and move into new subfolder + yield PlacesUtils.bookmarks.update({ + guid: guid, + parentGuid: subfolder.guid, + index: PlacesUtils.bookmarks.DEFAULT_INDEX, + title: "new title" + }); + + // restore + Services.prefs.setIntPref("browser.places.smartBookmarksVersion", 0); + yield rebuildSmartBookmarks(); + + smartBookmarkItemIds = + PlacesUtils.annotations.getItemsWithAnnotation(SMART_BOOKMARKS_ANNO); + Assert.equal(smartBookmarkItemIds.length, smartBookmarksCount); + + guid = yield PlacesUtils.promiseItemGuid(smartBookmarkItemIds[0]); + bm = yield PlacesUtils.bookmarks.fetch(guid); + Assert.equal(bm.parentGuid, subfolder.guid); + Assert.equal(bm.title, oldTitle); + + do_print("check that pref has been bumped up"); + Assert.ok(Services.prefs.getIntPref("browser.places.smartBookmarksVersion") > 0); +}); |