browser/base/content/test/newtab/browser_newtab_block.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/base/content/test/newtab/browser_newtab_block.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,61 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +/*
     1.8 + * These tests make sure that blocking/removing sites from the grid works
     1.9 + * as expected. Pinned tabs should not be moved. Gaps will be re-filled
    1.10 + * if more sites are available.
    1.11 + */
    1.12 +function runTests() {
    1.13 +  // we remove sites and expect the gaps to be filled as long as there still
    1.14 +  // are some sites available
    1.15 +  yield setLinks("0,1,2,3,4,5,6,7,8,9");
    1.16 +  setPinnedLinks("");
    1.17 +
    1.18 +  yield addNewTabPageTab();
    1.19 +  checkGrid("0,1,2,3,4,5,6,7,8");
    1.20 +
    1.21 +  yield blockCell(4);
    1.22 +  checkGrid("0,1,2,3,5,6,7,8,9");
    1.23 +
    1.24 +  yield blockCell(4);
    1.25 +  checkGrid("0,1,2,3,6,7,8,9,");
    1.26 +
    1.27 +  yield blockCell(4);
    1.28 +  checkGrid("0,1,2,3,7,8,9,,");
    1.29 +
    1.30 +  // we removed a pinned site
    1.31 +  yield restore();
    1.32 +  yield setLinks("0,1,2,3,4,5,6,7,8");
    1.33 +  setPinnedLinks(",1");
    1.34 +
    1.35 +  yield addNewTabPageTab();
    1.36 +  checkGrid("0,1p,2,3,4,5,6,7,8");
    1.37 +
    1.38 +  yield blockCell(1);
    1.39 +  checkGrid("0,2,3,4,5,6,7,8,");
    1.40 +
    1.41 +  // we remove the last site on the grid (which is pinned) and expect the gap
    1.42 +  // to be re-filled and the new site to be unpinned
    1.43 +  yield restore();
    1.44 +  yield setLinks("0,1,2,3,4,5,6,7,8,9");
    1.45 +  setPinnedLinks(",,,,,,,,8");
    1.46 +
    1.47 +  yield addNewTabPageTab();
    1.48 +  checkGrid("0,1,2,3,4,5,6,7,8p");
    1.49 +
    1.50 +  yield blockCell(8);
    1.51 +  checkGrid("0,1,2,3,4,5,6,7,9");
    1.52 +
    1.53 +  // we remove the first site on the grid with the last one pinned. all cells
    1.54 +  // but the last one should shift to the left and a new site fades in
    1.55 +  yield restore();
    1.56 +  yield setLinks("0,1,2,3,4,5,6,7,8,9");
    1.57 +  setPinnedLinks(",,,,,,,,8");
    1.58 +
    1.59 +  yield addNewTabPageTab();
    1.60 +  checkGrid("0,1,2,3,4,5,6,7,8p");
    1.61 +
    1.62 +  yield blockCell(0);
    1.63 +  checkGrid("1,2,3,4,5,6,7,9,8p");
    1.64 +}

mercurial