diff options
Diffstat (limited to '')
11 files changed, 76 insertions, 52 deletions
diff --git a/browser/components/places/PlacesUIUtils.sys.mjs b/browser/components/places/PlacesUIUtils.sys.mjs index b9e9efe70e..288877b55d 100644 --- a/browser/components/places/PlacesUIUtils.sys.mjs +++ b/browser/components/places/PlacesUIUtils.sys.mjs @@ -12,6 +12,7 @@ const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { CLIENT_NOT_CONFIGURED: "resource://services-sync/constants.sys.mjs", + BrowserUtils: "resource://gre/modules/BrowserUtils.sys.mjs", BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.sys.mjs", CustomizableUI: "resource:///modules/CustomizableUI.sys.mjs", MigrationUtils: "resource:///modules/MigrationUtils.sys.mjs", @@ -199,22 +200,25 @@ let InternalFaviconLoader = { win.addEventListener("unload", unloadHandler, true); } - // First we do the actual setAndFetch call: - let loadType = lazy.PrivateBrowsingUtils.isWindowPrivate(win) - ? lazy.PlacesUtils.favicons.FAVICON_LOAD_PRIVATE - : lazy.PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE; let callback = this._makeCompletionCallback(win, innerWindowID); - - if (iconURI && iconURI.schemeIs("data")) { - expiration = lazy.PlacesUtils.toPRTime(expiration); - lazy.PlacesUtils.favicons.replaceFaviconDataFromDataURL( + if (iconURI?.schemeIs("data")) { + lazy.PlacesUtils.favicons.setFaviconForPage( + pageURI, uri, - iconURI.spec, - expiration, - principal + iconURI, + lazy.PlacesUtils.toPRTime(expiration), + () => { + callback.onComplete(uri); + } ); + return; } + // First we do the actual setAndFetch call: + let loadType = lazy.PrivateBrowsingUtils.isWindowPrivate(win) + ? lazy.PlacesUtils.favicons.FAVICON_LOAD_PRIVATE + : lazy.PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE; + let request = lazy.PlacesUtils.favicons.setAndFetchFaviconForPage( pageURI, uri, @@ -464,7 +468,7 @@ class BookmarkState { }) ); break; - case "tags": + case "tags": { const newTags = value.filter( tag => !this._originalState.tags.includes(tag) ); @@ -488,6 +492,7 @@ class BookmarkState { ); } break; + } case "keyword": transactions.push( lazy.PlacesTransactions.EditKeyword({ @@ -982,7 +987,7 @@ export var PlacesUIUtils = { // whereToOpenLink doesn't return "window" when there's no browser window // open (Bug 630255). var where = browserWindow - ? browserWindow.whereToOpenLink(aEvent, false, true) + ? lazy.BrowserUtils.whereToOpenLink(aEvent, false, true) : "window"; if (where == "window") { // There is no browser window open, thus open a new one. @@ -1073,7 +1078,7 @@ export var PlacesUIUtils = { openNodeWithEvent: function PUIU_openNodeWithEvent(aNode, aEvent) { let window = aEvent.target.ownerGlobal; - let where = window.whereToOpenLink(aEvent, false, true); + let where = lazy.BrowserUtils.whereToOpenLink(aEvent, false, true); if (this.loadBookmarksInTabs && lazy.PlacesUtils.nodeIsBookmark(aNode)) { if (where == "current" && !aNode.uri.startsWith("javascript:")) { where = "tab"; @@ -1687,7 +1692,7 @@ export var PlacesUIUtils = { doCommand(command) { let window = this.triggerNode.ownerGlobal; switch (command) { - case "placesCmd_copy": + case "placesCmd_copy": { // This is a little hacky, but there is a lot of code in Places that handles // clipboard stuff, so it's easier to reuse. let node = {}; @@ -1732,6 +1737,7 @@ export var PlacesUIUtils = { Ci.nsIClipboard.kGlobalClipboard ); break; + } case "placesCmd_open:privatewindow": window.openTrustedLinkIn(this.triggerNode.link, "window", { private: true, diff --git a/browser/components/places/content/controller.js b/browser/components/places/content/controller.js index 6eaa129961..f46d696908 100644 --- a/browser/components/places/content/controller.js +++ b/browser/components/places/content/controller.js @@ -1436,7 +1436,7 @@ PlacesController.prototype = { let documentUrl = document.documentURI.toLowerCase(); if (documentUrl.endsWith("browser.xhtml")) { // We're in a menu or a panel. - window.SidebarUI._show("viewBookmarksSidebar").then(() => { + window.SidebarController._show("viewBookmarksSidebar").then(() => { let theSidebar = document.getElementById("sidebar"); theSidebar.contentDocument .getElementById("bookmarks-view") diff --git a/browser/components/places/tests/browser/browser_bookmark_context_menu_contents.js b/browser/components/places/tests/browser/browser_bookmark_context_menu_contents.js index 228fea654e..f2f47ff4b4 100644 --- a/browser/components/places/tests/browser/browser_bookmark_context_menu_contents.js +++ b/browser/components/places/tests/browser/browser_bookmark_context_menu_contents.js @@ -386,7 +386,9 @@ add_task(async function test_sidebar_folder_contextmenu_contents() { tree.selectItems([folder.guid]); let contextMenu = - SidebarUI.browser.contentDocument.getElementById("placesContext"); + SidebarController.browser.contentDocument.getElementById( + "placesContext" + ); let popupShownPromise = BrowserTestUtils.waitForEvent( contextMenu, "popupshown" @@ -396,7 +398,7 @@ add_task(async function test_sidebar_folder_contextmenu_contents() { return contextMenu; }, optionItems, - SidebarUI.browser.contentDocument + SidebarController.browser.contentDocument ); }); }); @@ -430,7 +432,9 @@ add_task(async function test_sidebar_multiple_folders_contextmenu_contents() { tree.selectItems([folder1.guid, folder2.guid]); let contextMenu = - SidebarUI.browser.contentDocument.getElementById("placesContext"); + SidebarController.browser.contentDocument.getElementById( + "placesContext" + ); let popupShownPromise = BrowserTestUtils.waitForEvent( contextMenu, "popupshown" @@ -440,7 +444,7 @@ add_task(async function test_sidebar_multiple_folders_contextmenu_contents() { return contextMenu; }, optionItems, - SidebarUI.browser.contentDocument + SidebarController.browser.contentDocument ); }); }); @@ -473,7 +477,9 @@ add_task(async function test_sidebar_bookmark_contextmenu_contents() { tree.selectItems([bookmark.guid]); let contextMenu = - SidebarUI.browser.contentDocument.getElementById("placesContext"); + SidebarController.browser.contentDocument.getElementById( + "placesContext" + ); let popupShownPromise = BrowserTestUtils.waitForEvent( contextMenu, "popupshown" @@ -483,7 +489,7 @@ add_task(async function test_sidebar_bookmark_contextmenu_contents() { return contextMenu; }, optionItems, - SidebarUI.browser.contentDocument + SidebarController.browser.contentDocument ); }); }); @@ -513,13 +519,17 @@ add_task(async function test_sidebar_bookmark_search_contextmenu_contents() { info("Checking bookmark sidebar menu contents in search context"); // Perform a search first let searchBox = - SidebarUI.browser.contentDocument.getElementById("search-box"); + SidebarController.browser.contentDocument.getElementById( + "search-box" + ); searchBox.value = SECOND_BOOKMARK_TITLE; searchBox.doCommand(); tree.selectItems([bookmark.guid]); let contextMenu = - SidebarUI.browser.contentDocument.getElementById("placesContext"); + SidebarController.browser.contentDocument.getElementById( + "placesContext" + ); let popupShownPromise = BrowserTestUtils.waitForEvent( contextMenu, "popupshown" @@ -529,7 +539,7 @@ add_task(async function test_sidebar_bookmark_search_contextmenu_contents() { return contextMenu; }, optionItems, - SidebarUI.browser.contentDocument + SidebarController.browser.contentDocument ); }); }); @@ -641,7 +651,9 @@ add_task(async function test_sidebar_mixedselection_contextmenu_contents() { tree.selectItems([bookmark.guid, folder.guid]); let contextMenu = - SidebarUI.browser.contentDocument.getElementById("placesContext"); + SidebarController.browser.contentDocument.getElementById( + "placesContext" + ); let popupShownPromise = BrowserTestUtils.waitForEvent( contextMenu, "popupshown" @@ -651,7 +663,7 @@ add_task(async function test_sidebar_mixedselection_contextmenu_contents() { return contextMenu; }, optionItems, - SidebarUI.browser.contentDocument + SidebarController.browser.contentDocument ); }); }); @@ -679,7 +691,9 @@ add_task(async function test_sidebar_multiple_bookmarks_contextmenu_contents() { tree.selectItems([bookmark.guid, bookmark2.guid]); let contextMenu = - SidebarUI.browser.contentDocument.getElementById("placesContext"); + SidebarController.browser.contentDocument.getElementById( + "placesContext" + ); let popupShownPromise = BrowserTestUtils.waitForEvent( contextMenu, "popupshown" @@ -689,7 +703,7 @@ add_task(async function test_sidebar_multiple_bookmarks_contextmenu_contents() { return contextMenu; }, optionItems, - SidebarUI.browser.contentDocument + SidebarController.browser.contentDocument ); }); }); @@ -714,7 +728,9 @@ add_task(async function test_sidebar_multiple_links_contextmenu_contents() { tree.selectAll(); let contextMenu = - SidebarUI.browser.contentDocument.getElementById("placesContext"); + SidebarController.browser.contentDocument.getElementById( + "placesContext" + ); let popupShownPromise = BrowserTestUtils.waitForEvent( contextMenu, "popupshown" @@ -724,7 +740,7 @@ add_task(async function test_sidebar_multiple_links_contextmenu_contents() { return contextMenu; }, optionItems, - SidebarUI.browser.contentDocument + SidebarController.browser.contentDocument ); }); }); @@ -750,7 +766,9 @@ add_task(async function test_sidebar_mixed_bookmarks_contextmenu_contents() { tree.selectItems([bookmark.guid, folder.guid]); let contextMenu = - SidebarUI.browser.contentDocument.getElementById("placesContext"); + SidebarController.browser.contentDocument.getElementById( + "placesContext" + ); let popupShownPromise = BrowserTestUtils.waitForEvent( contextMenu, "popupshown" @@ -760,7 +778,7 @@ add_task(async function test_sidebar_mixed_bookmarks_contextmenu_contents() { return contextMenu; }, optionItems, - SidebarUI.browser.contentDocument + SidebarController.browser.contentDocument ); }); }); diff --git a/browser/components/places/tests/browser/browser_bookmarksProperties.js b/browser/components/places/tests/browser/browser_bookmarksProperties.js index cfa9e6c581..b1147c3541 100644 --- a/browser/components/places/tests/browser/browser_bookmarksProperties.js +++ b/browser/components/places/tests/browser/browser_bookmarksProperties.js @@ -156,7 +156,7 @@ gTests.push({ }, finish() { - SidebarUI.hide(); + SidebarController.hide(); }, async cleanup() { @@ -282,7 +282,7 @@ gTests.push({ }, finish() { - SidebarUI.hide(); + SidebarController.hide(); }, async cleanup() { @@ -399,7 +399,7 @@ gTests.push({ }, finish() { - SidebarUI.hide(); + SidebarController.hide(); }, async cleanup() { @@ -450,7 +450,7 @@ function execute_test_in_sidebar(test) { }, { capture: true, once: true } ); - SidebarUI.show(test.sidebar); + SidebarController.show(test.sidebar); }); } diff --git a/browser/components/places/tests/browser/browser_check_correct_controllers.js b/browser/components/places/tests/browser/browser_check_correct_controllers.js index 80095823e1..d19939b98b 100644 --- a/browser/components/places/tests/browser/browser_check_correct_controllers.js +++ b/browser/components/places/tests/browser/browser_check_correct_controllers.js @@ -32,7 +32,7 @@ add_task(async function test() { let sidebar = await promiseLoadedSidebar("viewBookmarksSidebar"); registerCleanupFunction(() => { - SidebarUI.hide(); + SidebarController.hide(); }); // Focus the tree and check if its controller is returned. @@ -109,6 +109,6 @@ function promiseLoadedSidebar(cmd) { { capture: true, once: true } ); - SidebarUI.show(cmd); + SidebarController.show(cmd); }); } diff --git a/browser/components/places/tests/browser/browser_enable_toolbar_sidebar.js b/browser/components/places/tests/browser/browser_enable_toolbar_sidebar.js index 8d4d650984..47c53e6027 100644 --- a/browser/components/places/tests/browser/browser_enable_toolbar_sidebar.js +++ b/browser/components/places/tests/browser/browser_enable_toolbar_sidebar.js @@ -11,7 +11,7 @@ registerCleanupFunction(async () => { CustomizableUI.setToolbarVisibility("PersonalToolbar", false); CustomizableUI.removeWidgetFromArea("library-button"); - SidebarUI.hide(); + SidebarController.hide(); }); async function selectAppMenuView(buttonId, viewId) { diff --git a/browser/components/places/tests/browser/browser_sidebar_on_customization.js b/browser/components/places/tests/browser/browser_sidebar_on_customization.js index 6e97f81dd3..e5704e9d04 100644 --- a/browser/components/places/tests/browser/browser_sidebar_on_customization.js +++ b/browser/components/places/tests/browser/browser_sidebar_on_customization.js @@ -30,9 +30,9 @@ add_setup(async function () { add_task(async function test_open_sidebar_and_customize() { await withSidebarTree("bookmarks", async tree => { async function checkTreeIsFunctional() { - Assert.ok(SidebarUI.isOpen, "Sidebar is open"); + Assert.ok(SidebarController.isOpen, "Sidebar is open"); Assert.ok( - BrowserTestUtils.isVisible(SidebarUI.browser), + BrowserTestUtils.isVisible(SidebarController.browser), "sidebar browser is visible" ); Assert.ok(tree.view.result, "View result is defined"); @@ -49,7 +49,7 @@ add_task(async function test_open_sidebar_and_customize() { await promiseCustomizeStart(); Assert.ok( - !BrowserTestUtils.isVisible(SidebarUI.browser), + !BrowserTestUtils.isVisible(SidebarController.browser), "sidebar browser is hidden" ); Assert.ok(tree.view.result, "View result is defined"); diff --git a/browser/components/places/tests/browser/browser_sidebarpanels_click.js b/browser/components/places/tests/browser/browser_sidebarpanels_click.js index 9a1b039e78..f107eb76d5 100644 --- a/browser/components/places/tests/browser/browser_sidebarpanels_click.js +++ b/browser/components/places/tests/browser/browser_sidebarpanels_click.js @@ -31,7 +31,7 @@ add_task(async function test_sidebarpanels_click() { false, "Unexpected sidebar found - a previous test failed to cleanup correctly" ); - SidebarUI.hide(); + SidebarController.hide(); } // Ensure history is clean before starting the test. @@ -137,7 +137,7 @@ async function testPlacesPanel(testInfo) { await promiseAlert; executeSoon(async function () { - SidebarUI.hide(); + SidebarController.hide(); await testInfo.cleanup(); resolve(); }); @@ -147,7 +147,7 @@ async function testPlacesPanel(testInfo) { ); }); - SidebarUI.show(testInfo.sidebarName); + SidebarController.show(testInfo.sidebarName); return promise; } diff --git a/browser/components/places/tests/browser/browser_toolbarbutton_menu_show_in_folder.js b/browser/components/places/tests/browser/browser_toolbarbutton_menu_show_in_folder.js index 02720cfa2e..c4f6912044 100644 --- a/browser/components/places/tests/browser/browser_toolbarbutton_menu_show_in_folder.js +++ b/browser/components/places/tests/browser/browser_toolbarbutton_menu_show_in_folder.js @@ -11,7 +11,7 @@ const TEST_TITLE = "Test Bookmark"; let appMenuButton = document.getElementById("PanelUI-menu-button"); let bookmarksAppMenu = document.getElementById("PanelUI-bookmarks"); -let sidebarWasAlreadyOpen = SidebarUI.isOpen; +let sidebarWasAlreadyOpen = SidebarController.isOpen; const { CustomizableUITestUtils } = ChromeUtils.importESModule( "resource://testing-common/CustomizableUITestUtils.sys.mjs" @@ -86,7 +86,7 @@ add_task(async function toolbarBookmarkShowInFolder() { // Cleanup await PlacesUtils.bookmarks.eraseEverything(); if (!sidebarWasAlreadyOpen) { - SidebarUI.hide(); + SidebarController.hide(); } await gCUITestUtils.hideMainMenu(); }); diff --git a/browser/components/places/tests/browser/browser_views_iconsupdate.js b/browser/components/places/tests/browser/browser_views_iconsupdate.js index 1799a9665b..d1e5ea83ea 100644 --- a/browser/components/places/tests/browser/browser_views_iconsupdate.js +++ b/browser/components/places/tests/browser/browser_views_iconsupdate.js @@ -28,9 +28,9 @@ add_task(async function () { let promiseSidebarLoaded = new Promise(resolve => { sidebar.addEventListener("load", resolve, { capture: true, once: true }); }); - SidebarUI.show("viewBookmarksSidebar"); + SidebarController.show("viewBookmarksSidebar"); registerCleanupFunction(() => { - SidebarUI.hide(); + SidebarController.hide(); }); await promiseSidebarLoaded; diff --git a/browser/components/places/tests/browser/head.js b/browser/components/places/tests/browser/head.js index 5459e6f924..2decd11da9 100644 --- a/browser/components/places/tests/browser/head.js +++ b/browser/components/places/tests/browser/head.js @@ -395,7 +395,7 @@ var withSidebarTree = async function (type, taskFn) { }); let sidebarId = type == "bookmarks" ? "viewBookmarksSidebar" : "viewHistorySidebar"; - SidebarUI.show(sidebarId); + SidebarController.show(sidebarId); await sidebarLoadedPromise; let treeId = type == "bookmarks" ? "bookmarks-view" : "historyTree"; @@ -406,7 +406,7 @@ var withSidebarTree = async function (type, taskFn) { try { await taskFn(tree); } finally { - SidebarUI.hide(); + SidebarController.hide(); } }; |