Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'android'
- Manifest: toolkit/components/places/tests/bookmarks/xpcshell.toml
/* Any copyright is dedicated to the Public Domain.
/* This test checks that bookmarks service is correctly forwarding async
* events like visit or favicon additions. */
let gBookmarkGuids = [];
add_task(async function setup() {
// Add multiple bookmarks to the same uri.
gBookmarkGuids.push(
(
await PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
})
).guid
);
gBookmarkGuids.push(
(
await PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
})
).guid
);
Assert.equal(gBookmarkGuids.length, 2);
});
add_task(async function test_add_icon() {
// Add a visit to the bookmark and wait for the observer.
let guids = new Set(gBookmarkGuids);
Assert.equal(guids.size, 2);
let promiseNotifications = PlacesTestUtils.waitForNotification(
"favicon-changed",
events =>
events.some(
event =>
event.faviconUrl.startsWith("data:image/png;base64")
)
);
PlacesUtils.favicons.setFaviconForPage(
SMALLPNG_DATA_URI,
SMALLPNG_DATA_URI
);
await promiseNotifications;
});
add_task(async function test_remove_page() {
// Add a visit to the bookmark and wait for the observer.
let guids = new Set(gBookmarkGuids);
Assert.equal(guids.size, 2);
let promiseNotifications = PlacesTestUtils.waitForNotification(
"page-removed",
events =>
events.some(
event =>
!event.isRemovedFromStore &&
!event.isPartialVisistsRemoval
)
);
await promiseNotifications;
});