diff --git a/browser/base/content/newtab/drop.js b/browser/base/content/newtab/drop.js index 094b3acabca..f3d45db465f 100644 --- a/browser/base/content/newtab/drop.js +++ b/browser/base/content/newtab/drop.js @@ -94,7 +94,11 @@ let gDrop = { // A new link was dragged onto the grid. Create it by pinning its URL. let dt = aEvent.dataTransfer; let [url, title] = dt.getData("text/x-moz-url").split(/[\r\n]+/); - gPinnedLinks.pin({url: url, title: title}, index); + let link = {url: url, title: title}; + gPinnedLinks.pin(link, index); + + // Make sure the newly added link is not blocked. + gBlockedLinks.unblock(link); } }, diff --git a/browser/base/content/test/newtab/Makefile.in b/browser/base/content/test/newtab/Makefile.in index 8a81c95d119..668c839730e 100644 --- a/browser/base/content/test/newtab/Makefile.in +++ b/browser/base/content/test/newtab/Makefile.in @@ -25,6 +25,7 @@ _BROWSER_FILES = \ browser_newtab_bug723121.js \ browser_newtab_bug725996.js \ browser_newtab_bug734043.js \ + browser_newtab_bug735987.js \ head.js \ $(NULL) diff --git a/browser/base/content/test/newtab/browser_newtab_bug735987.js b/browser/base/content/test/newtab/browser_newtab_bug735987.js new file mode 100644 index 00000000000..4154d1da8fe --- /dev/null +++ b/browser/base/content/test/newtab/browser_newtab_bug735987.js @@ -0,0 +1,22 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +function runTests() { + setLinks("0,1,2,3,4,5,6,7,8"); + setPinnedLinks(""); + + yield addNewTabPageTab(); + checkGrid("0,1,2,3,4,5,6,7,8"); + + yield simulateDrop(cells[1]); + checkGrid("0,99p,1,2,3,4,5,6,7"); + + yield blockCell(cells[1]); + checkGrid("0,1,2,3,4,5,6,7,8"); + + yield simulateDrop(cells[1]); + checkGrid("0,99p,1,2,3,4,5,6,7"); + + yield blockCell(cells[1]); + checkGrid("0,1,2,3,4,5,6,7,8"); +} diff --git a/browser/modules/NewTabUtils.jsm b/browser/modules/NewTabUtils.jsm index e2fff6cd50e..12dd983f2b5 100644 --- a/browser/modules/NewTabUtils.jsm +++ b/browser/modules/NewTabUtils.jsm @@ -383,6 +383,15 @@ let BlockedLinks = { Storage.set("blockedLinks", this.links); }, + /** + * Unblocks a given link. + * @param aLink The link to unblock. + */ + unblock: function BlockedLinks_unblock(aLink) { + if (this.isBlocked(aLink)) + delete this.links[aLink.url]; + }, + /** * Returns whether a given link is blocked. * @param aLink The link to check.