Commit 4af8625f authored by Michael Kaply's avatar Michael Kaply
Browse files

Bug 1586453 - Don't try to wait for favicons in policy r=Standard8

Differential Revision: https://phabricator.services.mozilla.com/D48240

--HG--
extra : moz-landing-system : lando
parent 1136fcdc
...@@ -206,13 +206,11 @@ async function insertBookmark(bookmark) { ...@@ -206,13 +206,11 @@ async function insertBookmark(bookmark) {
}); });
if (bookmark.Favicon) { if (bookmark.Favicon) {
await setFaviconForBookmark(bookmark).catch(() => setFaviconForBookmark(bookmark);
log.error(`Error setting favicon for ${bookmark.Title}`)
);
} }
} }
async function setFaviconForBookmark(bookmark) { function setFaviconForBookmark(bookmark) {
let faviconURI; let faviconURI;
let nullPrincipal = Services.scriptSecurityManager.createNullPrincipal({}); let nullPrincipal = Services.scriptSecurityManager.createNullPrincipal({});
...@@ -238,19 +236,17 @@ async function setFaviconForBookmark(bookmark) { ...@@ -238,19 +236,17 @@ async function setFaviconForBookmark(bookmark) {
default: default:
log.error(`Bad URL given for favicon on bookmark "${bookmark.Title}"`); log.error(`Bad URL given for favicon on bookmark "${bookmark.Title}"`);
return Promise.resolve(); return;
} }
return new Promise(resolve => { PlacesUtils.favicons.setAndFetchFaviconForPage(
PlacesUtils.favicons.setAndFetchFaviconForPage( Services.io.newURI(bookmark.URL.href),
Services.io.newURI(bookmark.URL.href), faviconURI,
faviconURI, false /* forceReload */,
false /* forceReload */, PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE,
PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE, null,
resolve, nullPrincipal
nullPrincipal );
);
});
} }
// Cache of folder names to guids to be used by the getParentGuid // Cache of folder names to guids to be used by the getParentGuid
......
function handleRequest(request, response) {
response.setStatusLine(request.httpVersion, 404, "Not Found");
}
...@@ -10,6 +10,7 @@ support-files = ...@@ -10,6 +10,7 @@ support-files =
../../../../../toolkit/components/antitracking/test/browser/page.html ../../../../../toolkit/components/antitracking/test/browser/page.html
../../../../../toolkit/components/antitracking/test/browser/subResources.sjs ../../../../../toolkit/components/antitracking/test/browser/subResources.sjs
extensionsettings.html extensionsettings.html
404.sjs
[browser_policies_getActivePolicies.js] [browser_policies_getActivePolicies.js]
skip-if = os != 'mac' skip-if = os != 'mac'
......
...@@ -16,6 +16,11 @@ const { BookmarksPolicies } = ChromeUtils.import( ...@@ -16,6 +16,11 @@ const { BookmarksPolicies } = ChromeUtils.import(
let CURRENT_POLICY; let CURRENT_POLICY;
const basePath = getRootDirectory(gTestPath).replace(
"chrome://mochitests/content",
"http://mochi.test:8888"
);
const BASE_POLICY = { const BASE_POLICY = {
policies: { policies: {
DisplayBookmarksToolbar: true, DisplayBookmarksToolbar: true,
...@@ -28,21 +33,26 @@ const BASE_POLICY = { ...@@ -28,21 +33,26 @@ const BASE_POLICY = {
{ {
Title: "Bookmark 2", Title: "Bookmark 2",
URL: "https://bookmark2.example.com/", URL: "https://bookmark2.example.com/",
Folder: "Folder 1", Favicon: `${basePath}/404.sjs`,
}, },
{ {
Title: "Bookmark 3", Title: "Bookmark 3",
URL: "https://bookmark3.example.com/", URL: "https://bookmark3.example.com/",
Placement: "menu", Folder: "Folder 1",
}, },
{ {
Title: "Bookmark 4", Title: "Bookmark 4",
URL: "https://bookmark4.example.com/", URL: "https://bookmark4.example.com/",
Folder: "Folder 1", Placement: "menu",
}, },
{ {
Title: "Bookmark 5", Title: "Bookmark 5",
URL: "https://bookmark5.example.com/", URL: "https://bookmark5.example.com/",
Folder: "Folder 1",
},
{
Title: "Bookmark 6",
URL: "https://bookmark6.example.com/",
Placement: "menu", Placement: "menu",
Folder: "Folder 2", Folder: "Folder 2",
}, },
...@@ -199,7 +209,7 @@ add_task(async function test_initial_bookmarks() { ...@@ -199,7 +209,7 @@ add_task(async function test_initial_bookmarks() {
await Promise.all([ await Promise.all([
promiseAllChangesMade({ promiseAllChangesMade({
itemsToAdd: 7, // 5 bookmarks + 2 folders itemsToAdd: 8, // 6 bookmarks + 2 folders
itemsToRemove: 0, itemsToRemove: 0,
}), }),
setupPolicyEngineWithJson(CURRENT_POLICY), setupPolicyEngineWithJson(CURRENT_POLICY),
...@@ -240,7 +250,7 @@ add_task(async function test_remove_Bookmark_2() { ...@@ -240,7 +250,7 @@ add_task(async function test_remove_Bookmark_2() {
// //
// Remove the 2nd bookmark. It is inside "Folder 1", but that // Remove the 2nd bookmark. It is inside "Folder 1", but that
// folder won't be empty, so it must not be removed. // folder won't be empty, so it must not be removed.
CURRENT_POLICY.policies.Bookmarks.splice(2, 1); CURRENT_POLICY.policies.Bookmarks.splice(3, 1);
await Promise.all([ await Promise.all([
promiseAllChangesMade({ promiseAllChangesMade({
...@@ -298,7 +308,7 @@ add_task(async function test_empty_all_bookmarks() { ...@@ -298,7 +308,7 @@ add_task(async function test_empty_all_bookmarks() {
await Promise.all([ await Promise.all([
promiseAllChangesMade({ promiseAllChangesMade({
itemsToAdd: 0, itemsToAdd: 0,
itemsToRemove: 7, // 5 bookmarks and 2 folders itemsToRemove: 8, // 6 bookmarks and 2 folders
}), }),
setupPolicyEngineWithJson(CURRENT_POLICY), setupPolicyEngineWithJson(CURRENT_POLICY),
]); ]);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment