browser_bug581253.js (1950B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ 3 */ 4 5 var testURL = "data:text/plain,nothing but plain text"; 6 var testTag = "581253_tag"; 7 8 add_task(async function test_remove_bookmark_with_tag_via_edit_bookmark() { 9 waitForExplicitFinish(); 10 11 let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser); 12 13 registerCleanupFunction(async function () { 14 await PlacesUtils.bookmarks.eraseEverything(); 15 BrowserTestUtils.removeTab(tab); 16 await PlacesUtils.history.clear(); 17 }); 18 19 await PlacesUtils.bookmarks.insert({ 20 parentGuid: PlacesUtils.bookmarks.unfiledGuid, 21 title: "", 22 url: testURL, 23 }); 24 25 Assert.ok( 26 await PlacesUtils.bookmarks.fetch({ url: testURL }), 27 "the test url is bookmarked" 28 ); 29 30 BrowserTestUtils.startLoadingURIString(gBrowser, testURL); 31 32 await TestUtils.waitForCondition( 33 () => BookmarkingUI.status == BookmarkingUI.STATUS_STARRED, 34 "star button indicates that the page is bookmarked" 35 ); 36 37 PlacesUtils.tagging.tagURI(makeURI(testURL), [testTag]); 38 39 let popupShownPromise = BrowserTestUtils.waitForEvent( 40 StarUI.panel, 41 "popupshown" 42 ); 43 44 BookmarkingUI.star.click(); 45 46 await popupShownPromise; 47 48 let tagsField = document.getElementById("editBMPanel_tagsField"); 49 Assert.equal(tagsField.value, testTag, "tags field value was set"); 50 tagsField.focus(); 51 52 let popupHiddenPromise = BrowserTestUtils.waitForEvent( 53 StarUI.panel, 54 "popuphidden" 55 ); 56 57 let removeNotification = PlacesTestUtils.waitForNotification( 58 "bookmark-removed", 59 events => events.some(event => unescape(event.url) == testURL) 60 ); 61 62 let removeButton = document.getElementById("editBookmarkPanelRemoveButton"); 63 removeButton.click(); 64 65 await popupHiddenPromise; 66 67 await removeNotification; 68 69 is( 70 BookmarkingUI.status, 71 BookmarkingUI.STATUS_UNSTARRED, 72 "star button indicates that the bookmark has been removed" 73 ); 74 });