Skip to content
This repository has been archived by the owner on Feb 29, 2020. It is now read-only.

Commit

Permalink
Merge pull request #4204 from sarracini/bug_1458658
Browse files Browse the repository at this point in the history
Bug 1458658 - Unblock sites that are added if they were previously blocked
  • Loading branch information
sarracini committed Jun 22, 2018
2 parents eca5e98 + c035e51 commit 688aaed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/TopSitesFeed.jsm
Expand Up @@ -309,6 +309,13 @@ this.TopSitesFeed = class TopSitesFeed {
await this._pinSiteAt(site, index);
this._broadcastPinnedSitesUpdated();
} else {
// Bug 1458658. If the top site is being pinned from an 'Add a Top Site' option,
// then we want to make sure to unblock that link if it has previously been
// blocked. We know if the site has been added because the index will be -1.
if (index === -1) {
NewTabUtils.blockedLinks.unblock({url: site.url});
this.frecentCache.expire();
}
this.insert(action);
}
}
Expand Down
11 changes: 10 additions & 1 deletion test/unit/lib/TopSitesFeed.test.js
Expand Up @@ -41,7 +41,8 @@ describe("Top Sites Feed", () => {
fakeNewTabUtils = {
blockedLinks: {
links: [],
isBlocked: () => false
isBlocked: () => false,
unblock: sandbox.spy()
},
activityStreamLinks: {getTopSites: sandbox.spy(() => Promise.resolve(links))},
activityStreamProvider: {
Expand Down Expand Up @@ -729,6 +730,14 @@ describe("Top Sites Feed", () => {

assert.calledOnce(feed.refresh);
});
it("should unblock a previously blocked top site if we are now adding it manually via 'Add a Top Site' option", async () => {
const pinAction = {
type: at.TOP_SITES_PIN,
data: {site: {url: "foo.com"}, index: -1}
};
feed.onAction(pinAction);
assert.calledWith(fakeNewTabUtils.blockedLinks.unblock, {url: pinAction.data.site.url});
});
it("should call insert on TOP_SITES_INSERT", async () => {
sinon.stub(feed, "insert");
const addAction = {type: at.TOP_SITES_INSERT, data: {site: {url: "foo.com"}}};
Expand Down

0 comments on commit 688aaed

Please sign in to comment.