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.

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

mercurial