|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /* |
|
5 * These tests ensure that all changes made to the new tab page in private |
|
6 * browsing mode are discarded after switching back to normal mode again. |
|
7 * The private browsing mode should start with the current grid shown in normal |
|
8 * mode. |
|
9 */ |
|
10 |
|
11 function runTests() { |
|
12 // prepare the grid |
|
13 yield testOnWindow(undefined); |
|
14 yield setLinks("0,1,2,3,4,5,6,7,8,9"); |
|
15 |
|
16 yield addNewTabPageTab(); |
|
17 pinCell(0); |
|
18 checkGrid("0p,1,2,3,4,5,6,7,8"); |
|
19 |
|
20 // open private window |
|
21 yield testOnWindow({private: true}); |
|
22 |
|
23 yield addNewTabPageTab(); |
|
24 checkGrid("0p,1,2,3,4,5,6,7,8"); |
|
25 |
|
26 // modify the grid while we're in pb mode |
|
27 yield blockCell(1); |
|
28 checkGrid("0p,2,3,4,5,6,7,8"); |
|
29 |
|
30 yield unpinCell(0); |
|
31 checkGrid("0,2,3,4,5,6,7,8"); |
|
32 |
|
33 // open normal window |
|
34 yield testOnWindow(undefined); |
|
35 |
|
36 // check that the grid is the same as before entering pb mode |
|
37 yield addNewTabPageTab(); |
|
38 checkGrid("0,2,3,4,5,6,7,8") |
|
39 } |
|
40 |
|
41 var windowsToClose = []; |
|
42 function testOnWindow(options) { |
|
43 var win = OpenBrowserWindow(options); |
|
44 win.addEventListener("load", function onLoad() { |
|
45 win.removeEventListener("load", onLoad, false); |
|
46 windowsToClose.push(win); |
|
47 gWindow = win; |
|
48 whenDelayedStartupFinished(win, TestRunner.next); |
|
49 }, false); |
|
50 } |
|
51 |
|
52 function whenDelayedStartupFinished(win, callback) { |
|
53 const topic = "browser-delayed-startup-finished"; |
|
54 Services.obs.addObserver(function onStartup(subject) { |
|
55 if (win == subject) { |
|
56 Services.obs.removeObserver(onStartup, topic); |
|
57 executeSoon(callback); |
|
58 } |
|
59 }, topic, false); |
|
60 } |
|
61 |
|
62 registerCleanupFunction(function () { |
|
63 gWindow = window; |
|
64 windowsToClose.forEach(function(win) { |
|
65 win.close(); |
|
66 }); |
|
67 }); |
|
68 |