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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 const PREF_NEWTAB_ROWS = "browser.newtabpage.rows";
     5 const PREF_NEWTAB_COLUMNS = "browser.newtabpage.columns";
     7 function runTests() {
     8   let testValues = [
     9     {row: 0, column: 0},
    10     {row: -1, column: -1},
    11     {row: -1, column: 0},
    12     {row: 0, column: -1},
    13     {row: 2, column: 4},
    14     {row: 2, column: 5},
    15   ];
    17   // Expected length of grid
    18   let expectedValues = [1, 1, 1, 1, 8, 10];
    20    // Values before setting new pref values (9 is the default value -> 3 x 3)
    21   let previousValues = [9, 1, 1, 1, 1, 8];
    23   let existingTab, existingTabGridLength, newTab, newTabGridLength;
    24   yield addNewTabPageTab();
    25   existingTab = gBrowser.selectedTab;
    27   for (let i = 0; i < expectedValues.length; i++) {
    28     gBrowser.selectedTab = existingTab;
    29     existingTabGridLength = getGrid().cells.length;
    30     is(existingTabGridLength, previousValues[i],
    31       "Grid length of existing page before update is correctly.");
    33     Services.prefs.setIntPref(PREF_NEWTAB_ROWS, testValues[i].row);
    34     Services.prefs.setIntPref(PREF_NEWTAB_COLUMNS, testValues[i].column);
    36     existingTabGridLength = getGrid().cells.length;
    37     is(existingTabGridLength, expectedValues[i],
    38       "Existing page grid is updated correctly.");
    40     yield addNewTabPageTab();
    41     newTab = gBrowser.selectedTab;
    42     newTabGridLength = getGrid().cells.length;
    43     is(newTabGridLength, expectedValues[i],
    44       "New page grid is updated correctly.");
    46     gBrowser.removeTab(newTab);
    47   }
    49   gBrowser.removeTab(existingTab);
    51   Services.prefs.clearUserPref(PREF_NEWTAB_ROWS);
    52   Services.prefs.clearUserPref(PREF_NEWTAB_COLUMNS);
    53 }

mercurial