Bug 1199077 - Activity Stream changes for new bookmark change sources. r=ursula
MozReview-Commit-ID: 4nrBB3UwVWi
--- a/browser/extensions/activity-stream/lib/PlacesFeed.jsm
+++ b/browser/extensions/activity-stream/lib/PlacesFeed.jsm
@@ -108,17 +108,17 @@ class BookmarksObserver extends Observer
* @param {str} parent guid
* @param {int} source Used to distinguish bookmarks made by different
* actions: sync, bookmarks import, other.
*/
onItemAdded(id, folderId, index, type, uri, bookmarkTitle, dateAdded, bookmarkGuid, parentGuid, source) { // eslint-disable-line max-params
// Skips items that are not bookmarks (like folders), about:* pages or
// default bookmarks, added when the profile is created.
if (type !== PlacesUtils.bookmarks.TYPE_BOOKMARK ||
- source === PlacesUtils.bookmarks.SOURCES.IMPORT_REPLACE ||
+ source === PlacesUtils.bookmarks.SOURCES.RESTORE_ON_STARTUP ||
(uri.scheme !== "http" && uri.scheme !== "https")) {
return;
}
this.dispatch({
type: at.PLACES_BOOKMARK_ADDED,
data: {
bookmarkGuid,
bookmarkTitle,
--- a/browser/extensions/activity-stream/test/unit/lib/PlacesFeed.test.js
+++ b/browser/extensions/activity-stream/test/unit/lib/PlacesFeed.test.js
@@ -2,17 +2,17 @@ import {actionTypes as at} from "common/
import {GlobalOverrider} from "test/unit/utils";
import {PlacesFeed} from "lib/PlacesFeed.jsm";
const {HistoryObserver, BookmarksObserver} = PlacesFeed;
const FAKE_BOOKMARK = {bookmarkGuid: "xi31", bookmarkTitle: "Foo", dateAdded: 123214232, url: "foo.com"};
const TYPE_BOOKMARK = 0; // This is fake, for testing
const SOURCES = {
DEFAULT: 0,
- IMPORT_REPLACE: 3
+ RESTORE_ON_STARTUP: 6
};
const BLOCKED_EVENT = "newtab-linkBlocked"; // The event dispatched in NewTabUtils when a link is blocked;
describe("PlacesFeed", () => {
let globals;
let sandbox;
let feed;
@@ -349,21 +349,21 @@ describe("PlacesFeed", () => {
// Yes, onItemAdded has at least 8 arguments. See function definition for docs.
const args = [null, null, null, TYPE_BOOKMARK,
{spec: FAKE_BOOKMARK.url, scheme: "places"}, FAKE_BOOKMARK.bookmarkTitle,
FAKE_BOOKMARK.dateAdded, FAKE_BOOKMARK.bookmarkGuid, "", SOURCES.DEFAULT];
await observer.onItemAdded(...args);
assert.notCalled(dispatch);
});
- it("should not dispatch a PLACES_BOOKMARK_ADDED action - has IMPORT_REPLACE source", async () => {
+ it("should not dispatch a PLACES_BOOKMARK_ADDED action - has IMPORT_RESTORE_ON_STARTUP source", async () => {
// Yes, onItemAdded has at least 8 arguments. See function definition for docs.
const args = [null, null, null, TYPE_BOOKMARK,
{spec: FAKE_BOOKMARK.url, scheme: "http"}, FAKE_BOOKMARK.bookmarkTitle,
- FAKE_BOOKMARK.dateAdded, FAKE_BOOKMARK.bookmarkGuid, "", SOURCES.IMPORT_REPLACE];
+ FAKE_BOOKMARK.dateAdded, FAKE_BOOKMARK.bookmarkGuid, "", SOURCES.RESTORE_ON_STARTUP];
await observer.onItemAdded(...args);
assert.notCalled(dispatch);
});
it("should ignore events that are not of TYPE_BOOKMARK", async () => {
const args = [null, null, null, "nottypebookmark"];
await observer.onItemAdded(...args);
assert.notCalled(dispatch);