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