diff options
Diffstat (limited to 'browser/components/places/tests/chrome/test_editBookmarkOverlay_tags_liveUpdate.xul')
-rw-r--r-- | browser/components/places/tests/chrome/test_editBookmarkOverlay_tags_liveUpdate.xul | 204 |
1 files changed, 0 insertions, 204 deletions
diff --git a/browser/components/places/tests/chrome/test_editBookmarkOverlay_tags_liveUpdate.xul b/browser/components/places/tests/chrome/test_editBookmarkOverlay_tags_liveUpdate.xul deleted file mode 100644 index 1b1cc6473..000000000 --- a/browser/components/places/tests/chrome/test_editBookmarkOverlay_tags_liveUpdate.xul +++ /dev/null @@ -1,204 +0,0 @@ -<?xml version="1.0"?> - -<!-- Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ --> - -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> - -<?xml-stylesheet href="chrome://browser/skin/places/editBookmarkOverlay.css"?> -<?xml-stylesheet href="chrome://browser/content/places/places.css"?> -<?xml-stylesheet href="chrome://browser/skin/places/places.css"?> - -<?xul-overlay href="chrome://browser/content/places/placesOverlay.xul"?> -<?xul-overlay href="chrome://browser/content/places/editBookmarkOverlay.xul"?> - -<!DOCTYPE window [ - <!ENTITY % editBookmarkOverlayDTD SYSTEM "chrome://browser/locale/places/editBookmarkOverlay.dtd"> - %editBookmarkOverlayDTD; -]> - -<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" - title="485100: Exchanging a letter of a tag name with its big/small equivalent removes tag from bookmark" - onload="runTest();"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - <script type="application/javascript" - src="chrome://browser/content/places/editBookmarkOverlay.js"/> - - <body xmlns="http://www.w3.org/1999/xhtml" /> - - <vbox id="editBookmarkPanelContent"/> - - <script type="application/javascript"> - <![CDATA[ - function checkTagsSelector(aAvailableTags, aCheckedTags) { - is(PlacesUtils.tagging.allTags.length, aAvailableTags.length, - "tagging service is in sync."); - let tagsSelector = document.getElementById("editBMPanel_tagsSelector"); - let children = tagsSelector.childNodes; - is(children.length, aAvailableTags.length, - "Found expected number of tags in the tags selector"); - - Array.prototype.forEach.call(children, function (aChild) { - let tag = aChild.getAttribute("label"); - ok(true, "Found tag '" + tag + "' in the selector"); - ok(aAvailableTags.includes(tag), "Found expected tag"); - let checked = aChild.getAttribute("checked") == "true"; - is(checked, aCheckedTags.includes(tag), - "Tag is correctly marked"); - }); - } - - function runTest() { - SimpleTest.waitForExplicitFinish(); - - Task.spawn(function* () { - const TEST_URI = Services.io.newURI("http://www.test.me/", null, null); - const TEST_URI2 = Services.io.newURI("http://www.test.again.me/", null, null); - const TEST_TAG = "test-tag"; - - ok(gEditItemOverlay, "Sanity check: gEditItemOverlay is in context"); - - // Open the tags selector. - document.getElementById("editBMPanel_tagsSelectorRow").collapsed = false; - - // Add a bookmark. - let bm = yield PlacesUtils.bookmarks.insert({ - parentGuid: PlacesUtils.bookmarks.unfiledGuid, - index: PlacesUtils.bookmarks.DEFAULT_INDEX, - type: PlacesUtils.bookmarks.TYPE_BOOKMARK, - url: TEST_URI.spec, - title: "test.me" - }); - - // Init panel. - let node = yield PlacesUIUtils.promiseNodeLikeFromFetchInfo(bm); - gEditItemOverlay.initPanel({ node }); - - // Add a tag. - PlacesUtils.tagging.tagURI(TEST_URI, [TEST_TAG]); - - is(PlacesUtils.tagging.getTagsForURI(TEST_URI)[0], TEST_TAG, - "Correctly added tag to a single bookmark"); - is(document.getElementById("editBMPanel_tagsField").value, TEST_TAG, - "Editing a single bookmark shows the added tag"); - checkTagsSelector([TEST_TAG], [TEST_TAG]); - - // Remove tag. - PlacesUtils.tagging.untagURI(TEST_URI, [TEST_TAG]); - is(PlacesUtils.tagging.getTagsForURI(TEST_URI)[0], undefined, - "The tag has been removed"); - is(document.getElementById("editBMPanel_tagsField").value, "", - "Editing a single bookmark should not show any tag"); - checkTagsSelector([], []); - - // Add a second bookmark. - let bm2 = yield PlacesUtils.bookmarks.insert({ - parentGuid: PlacesUtils.bookmarks.unfiledGuid, - index: PlacesUtils.bookmarks.DEFAULT_INDEX, - type: PlacesUtils.bookmarks.TYPE_BOOKMARK, - title: "test.again.me", - url: TEST_URI2.spec - }); - - // Init panel with multiple uris. - gEditItemOverlay.initPanel({ uris: [TEST_URI, TEST_URI2] }); - - // Add a tag to the first uri. - PlacesUtils.tagging.tagURI(TEST_URI, [TEST_TAG]); - is(PlacesUtils.tagging.getTagsForURI(TEST_URI)[0], TEST_TAG, - "Correctly added a tag to the first bookmark."); - is(document.getElementById("editBMPanel_tagsField").value, "", - "Editing multiple bookmarks without matching tags should not show any tag."); - checkTagsSelector([TEST_TAG], []); - - // Add a tag to the second uri. - PlacesUtils.tagging.tagURI(TEST_URI2, [TEST_TAG]); - is(PlacesUtils.tagging.getTagsForURI(TEST_URI2)[0], TEST_TAG, - "Correctly added a tag to the second bookmark."); - is(document.getElementById("editBMPanel_tagsField").value, TEST_TAG, - "Editing multiple bookmarks should show matching tags."); - checkTagsSelector([TEST_TAG], [TEST_TAG]); - - // Remove tag from the first bookmark. - PlacesUtils.tagging.untagURI(TEST_URI, [TEST_TAG]); - is(PlacesUtils.tagging.getTagsForURI(TEST_URI)[0], undefined, - "Correctly removed tag from the first bookmark."); - is(document.getElementById("editBMPanel_tagsField").value, "", - "Editing multiple bookmarks without matching tags should not show any tag."); - checkTagsSelector([TEST_TAG], []); - - // Remove tag from the second bookmark. - PlacesUtils.tagging.untagURI(TEST_URI2, [TEST_TAG]); - is(PlacesUtils.tagging.getTagsForURI(TEST_URI2)[0], undefined, - "Correctly removed tag from the second bookmark."); - is(document.getElementById("editBMPanel_tagsField").value, "", - "Editing multiple bookmarks without matching tags should not show any tag."); - checkTagsSelector([], []); - - // Init panel with a nsIURI entry. - gEditItemOverlay.initPanel({ uris: [TEST_URI] }); - - // Add a tag. - PlacesUtils.tagging.tagURI(TEST_URI, [TEST_TAG]); - is(PlacesUtils.tagging.getTagsForURI(TEST_URI)[0], TEST_TAG, - "Correctly added tag to the first entry."); - is(document.getElementById("editBMPanel_tagsField").value, TEST_TAG, - "Editing a single nsIURI entry shows the added tag"); - checkTagsSelector([TEST_TAG], [TEST_TAG]); - - // Remove tag. - PlacesUtils.tagging.untagURI(TEST_URI, [TEST_TAG]); - is(PlacesUtils.tagging.getTagsForURI(TEST_URI)[0], undefined, - "Correctly removed tag from the nsIURI entry."); - is(document.getElementById("editBMPanel_tagsField").value, "", - "Editing a single nsIURI entry should not show any tag"); - checkTagsSelector([], []); - - // Init panel with multiple nsIURI entries. - gEditItemOverlay.initPanel({ uris: [TEST_URI, TEST_URI2] }); - - // Add a tag to the first entry. - PlacesUtils.tagging.tagURI(TEST_URI, [TEST_TAG]); - is(PlacesUtils.tagging.getTagsForURI(TEST_URI)[0], TEST_TAG, - "Tag correctly added."); - is(document.getElementById("editBMPanel_tagsField").value, "", - "Editing multiple nsIURIs without matching tags should not show any tag."); - checkTagsSelector([TEST_TAG], []); - - // Add a tag to the second entry. - PlacesUtils.tagging.tagURI(TEST_URI2, [TEST_TAG]); - is(PlacesUtils.tagging.getTagsForURI(TEST_URI2)[0], TEST_TAG, - "Tag correctly added."); - is(document.getElementById("editBMPanel_tagsField").value, TEST_TAG, - "Editing multiple nsIURIs should show matching tags"); - checkTagsSelector([TEST_TAG], [TEST_TAG]); - - // Remove tag from the first entry. - PlacesUtils.tagging.untagURI(TEST_URI, [TEST_TAG]); - is(PlacesUtils.tagging.getTagsForURI(TEST_URI)[0], undefined, - "Correctly removed tag from the first entry."); - is(document.getElementById("editBMPanel_tagsField").value, "", - "Editing multiple nsIURIs without matching tags should not show any tag."); - checkTagsSelector([TEST_TAG], []); - - // Remove tag from the second entry. - PlacesUtils.tagging.untagURI(TEST_URI2, [TEST_TAG]); - is(PlacesUtils.tagging.getTagsForURI(TEST_URI2)[0], undefined, - "Correctly removed tag from the second entry."); - is(document.getElementById("editBMPanel_tagsField").value, "", - "Editing multiple nsIURIs without matching tags should not show any tag."); - checkTagsSelector([], []); - - // Cleanup. - yield PlacesUtils.bookmarks.remove(bm.guid); - yield PlacesUtils.bookmarks.remove(bm2.guid); - }).then(SimpleTest.finish); - } - ]]> - </script> - -</window> |