Wed, 31 Dec 2014 06:09:35 +0100
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 /*
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 */
11 function runTests() {
12 // prepare the grid
13 yield testOnWindow(undefined);
14 yield setLinks("0,1,2,3,4,5,6,7,8,9");
16 yield addNewTabPageTab();
17 pinCell(0);
18 checkGrid("0p,1,2,3,4,5,6,7,8");
20 // open private window
21 yield testOnWindow({private: true});
23 yield addNewTabPageTab();
24 checkGrid("0p,1,2,3,4,5,6,7,8");
26 // modify the grid while we're in pb mode
27 yield blockCell(1);
28 checkGrid("0p,2,3,4,5,6,7,8");
30 yield unpinCell(0);
31 checkGrid("0,2,3,4,5,6,7,8");
33 // open normal window
34 yield testOnWindow(undefined);
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 }
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 }
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 }
62 registerCleanupFunction(function () {
63 gWindow = window;
64 windowsToClose.forEach(function(win) {
65 win.close();
66 });
67 });