fune/browser/base/content/test/newtab/browser_newtab_drop_preview.js
2017-10-15 20:50:39 +01:00

41 lines
1.3 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/*
* These tests ensure that the drop preview correctly arranges sites when
* dragging them around.
*/
add_task(async function() {
await addNewTabPageTab();
// the first three sites are pinned - make sure they're re-arranged correctly
await setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks("0,1,2,,,5");
await addNewTabPageTab();
await checkGrid("0p,1p,2p,3,4,5p,6,7,8");
let foundSites = await ContentTask.spawn(gWindow.gBrowser.selectedBrowser, {}, async function() {
let cells = content.gGrid.cells;
content.gDrag._draggedSite = cells[0].site;
let sites = content.gDropPreview.rearrange(cells[4]);
content.gDrag._draggedSite = null;
sites = sites.slice(0, 9);
return sites.map(function(aSite) {
if (!aSite)
return "";
let pinned = aSite.isPinned();
if (pinned != aSite.node.hasAttribute("pinned")) {
Assert.ok(false, "invalid state (site.isPinned() != site[pinned])");
}
return aSite.url.replace(/^http:\/\/example(\d+)\.com\/$/, "$1") + (pinned ? "p" : "");
});
});
let expectedSites = "3,1p,2p,4,0p,5p,6,7,8";
is(foundSites, expectedSites, "grid status = " + expectedSites);
});