summaryrefslogtreecommitdiffstats
path: root/toolkit/components/places/tests/unit/test_419731.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /toolkit/components/places/tests/unit/test_419731.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-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/unit/test_419731.js')
-rw-r--r--toolkit/components/places/tests/unit/test_419731.js96
1 files changed, 96 insertions, 0 deletions
diff --git a/toolkit/components/places/tests/unit/test_419731.js b/toolkit/components/places/tests/unit/test_419731.js
new file mode 100644
index 000000000..b1a434e12
--- /dev/null
+++ b/toolkit/components/places/tests/unit/test_419731.js
@@ -0,0 +1,96 @@
+/* -*- 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/. */
+
+function run_test() {
+ let uri1 = NetUtil.newURI("http://foo.bar/");
+
+ // create 2 bookmarks
+ let bookmark1id = PlacesUtils.bookmarks
+ .insertBookmark(PlacesUtils.bookmarksMenuFolderId,
+ uri1,
+ PlacesUtils.bookmarks.DEFAULT_INDEX,
+ "title 1");
+ let bookmark2id = PlacesUtils.bookmarks
+ .insertBookmark(PlacesUtils.toolbarFolderId,
+ uri1,
+ PlacesUtils.bookmarks.DEFAULT_INDEX,
+ "title 2");
+ // add a new tag
+ PlacesUtils.tagging.tagURI(uri1, ["foo"]);
+
+ // get tag folder id
+ let options = PlacesUtils.history.getNewQueryOptions();
+ let query = PlacesUtils.history.getNewQuery();
+ query.setFolders([PlacesUtils.tagsFolderId], 1);
+ let result = PlacesUtils.history.executeQuery(query, options);
+ let tagRoot = result.root;
+ tagRoot.containerOpen = true;
+ let tagNode = tagRoot.getChild(0)
+ .QueryInterface(Ci.nsINavHistoryContainerResultNode);
+ let tagItemId = tagNode.itemId;
+ tagRoot.containerOpen = false;
+
+ // change bookmark 1 title
+ PlacesUtils.bookmarks.setItemTitle(bookmark1id, "new title 1");
+
+ // Workaround timers resolution and time skews.
+ let bookmark2LastMod = PlacesUtils.bookmarks.getItemLastModified(bookmark2id);
+ PlacesUtils.bookmarks.setItemLastModified(bookmark1id, bookmark2LastMod + 1000);
+
+ // Query the tag.
+ options = PlacesUtils.history.getNewQueryOptions();
+ options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS;
+ options.resultType = options.RESULTS_AS_TAG_QUERY;
+
+ query = PlacesUtils.history.getNewQuery();
+ result = PlacesUtils.history.executeQuery(query, options);
+ let root = result.root;
+ root.containerOpen = true;
+ do_check_eq(root.childCount, 1);
+
+ let theTag = root.getChild(0)
+ .QueryInterface(Ci.nsINavHistoryContainerResultNode);
+ // Bug 524219: Check that renaming the tag shows up in the result.
+ do_check_eq(theTag.title, "foo")
+ PlacesUtils.bookmarks.setItemTitle(tagItemId, "bar");
+
+ // Check that the item has been replaced
+ do_check_neq(theTag, root.getChild(0));
+ theTag = root.getChild(0)
+ .QueryInterface(Ci.nsINavHistoryContainerResultNode);
+ do_check_eq(theTag.title, "bar");
+
+ // Check that tag container contains new title
+ theTag.containerOpen = true;
+ do_check_eq(theTag.childCount, 1);
+ let node = theTag.getChild(0);
+ do_check_eq(node.title, "new title 1");
+ theTag.containerOpen = false;
+ root.containerOpen = false;
+
+ // Change bookmark 2 title.
+ PlacesUtils.bookmarks.setItemTitle(bookmark2id, "new title 2");
+
+ // Workaround timers resolution and time skews.
+ let bookmark1LastMod = PlacesUtils.bookmarks.getItemLastModified(bookmark1id);
+ PlacesUtils.bookmarks.setItemLastModified(bookmark2id, bookmark1LastMod + 1000);
+
+ // Check that tag container contains new title
+ options = PlacesUtils.history.getNewQueryOptions();
+ options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS;
+ options.resultType = options.RESULTS_AS_TAG_CONTENTS;
+
+ query = PlacesUtils.history.getNewQuery();
+ query.setFolders([tagItemId], 1);
+ result = PlacesUtils.history.executeQuery(query, options);
+ root = result.root;
+
+ root.containerOpen = true;
+ do_check_eq(root.childCount, 1);
+ node = root.getChild(0);
+ do_check_eq(node.title, "new title 2");
+ root.containerOpen = false;
+}