Bug 735987 - [New Tab Page] Dropping blocked links onto the grid again should unblock them; r=dietrich

This commit is contained in:
Tim Taubert 2012-03-16 09:00:18 +01:00
parent 596c9d1a03
commit 6dc6c177cc
4 changed files with 37 additions and 1 deletions

View File

@ -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);
}
},

View File

@ -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)

View File

@ -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");
}

View File

@ -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.