browser/base/content/test/newtab/browser_newtab_bug752841.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_bug752841.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,53 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +const PREF_NEWTAB_ROWS = "browser.newtabpage.rows";
     1.8 +const PREF_NEWTAB_COLUMNS = "browser.newtabpage.columns";
     1.9 +
    1.10 +function runTests() {
    1.11 +  let testValues = [
    1.12 +    {row: 0, column: 0},
    1.13 +    {row: -1, column: -1},
    1.14 +    {row: -1, column: 0},
    1.15 +    {row: 0, column: -1},
    1.16 +    {row: 2, column: 4},
    1.17 +    {row: 2, column: 5},
    1.18 +  ];
    1.19 +
    1.20 +  // Expected length of grid
    1.21 +  let expectedValues = [1, 1, 1, 1, 8, 10];
    1.22 +
    1.23 +   // Values before setting new pref values (9 is the default value -> 3 x 3)
    1.24 +  let previousValues = [9, 1, 1, 1, 1, 8];
    1.25 +
    1.26 +  let existingTab, existingTabGridLength, newTab, newTabGridLength;
    1.27 +  yield addNewTabPageTab();
    1.28 +  existingTab = gBrowser.selectedTab;
    1.29 +
    1.30 +  for (let i = 0; i < expectedValues.length; i++) {
    1.31 +    gBrowser.selectedTab = existingTab;
    1.32 +    existingTabGridLength = getGrid().cells.length;
    1.33 +    is(existingTabGridLength, previousValues[i],
    1.34 +      "Grid length of existing page before update is correctly.");
    1.35 +
    1.36 +    Services.prefs.setIntPref(PREF_NEWTAB_ROWS, testValues[i].row);
    1.37 +    Services.prefs.setIntPref(PREF_NEWTAB_COLUMNS, testValues[i].column);
    1.38 +
    1.39 +    existingTabGridLength = getGrid().cells.length;
    1.40 +    is(existingTabGridLength, expectedValues[i],
    1.41 +      "Existing page grid is updated correctly.");
    1.42 +
    1.43 +    yield addNewTabPageTab();
    1.44 +    newTab = gBrowser.selectedTab;
    1.45 +    newTabGridLength = getGrid().cells.length;
    1.46 +    is(newTabGridLength, expectedValues[i],
    1.47 +      "New page grid is updated correctly.");
    1.48 +
    1.49 +    gBrowser.removeTab(newTab);
    1.50 +  }
    1.51 +
    1.52 +  gBrowser.removeTab(existingTab);
    1.53 +
    1.54 +  Services.prefs.clearUserPref(PREF_NEWTAB_ROWS);
    1.55 +  Services.prefs.clearUserPref(PREF_NEWTAB_COLUMNS);
    1.56 +}

mercurial