1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/base/content/test/newtab/browser_newtab_perwindow_private_browsing.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,68 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/* 1.8 + * These tests ensure that all changes made to the new tab page in private 1.9 + * browsing mode are discarded after switching back to normal mode again. 1.10 + * The private browsing mode should start with the current grid shown in normal 1.11 + * mode. 1.12 + */ 1.13 + 1.14 +function runTests() { 1.15 + // prepare the grid 1.16 + yield testOnWindow(undefined); 1.17 + yield setLinks("0,1,2,3,4,5,6,7,8,9"); 1.18 + 1.19 + yield addNewTabPageTab(); 1.20 + pinCell(0); 1.21 + checkGrid("0p,1,2,3,4,5,6,7,8"); 1.22 + 1.23 + // open private window 1.24 + yield testOnWindow({private: true}); 1.25 + 1.26 + yield addNewTabPageTab(); 1.27 + checkGrid("0p,1,2,3,4,5,6,7,8"); 1.28 + 1.29 + // modify the grid while we're in pb mode 1.30 + yield blockCell(1); 1.31 + checkGrid("0p,2,3,4,5,6,7,8"); 1.32 + 1.33 + yield unpinCell(0); 1.34 + checkGrid("0,2,3,4,5,6,7,8"); 1.35 + 1.36 + // open normal window 1.37 + yield testOnWindow(undefined); 1.38 + 1.39 + // check that the grid is the same as before entering pb mode 1.40 + yield addNewTabPageTab(); 1.41 + checkGrid("0,2,3,4,5,6,7,8") 1.42 +} 1.43 + 1.44 +var windowsToClose = []; 1.45 +function testOnWindow(options) { 1.46 + var win = OpenBrowserWindow(options); 1.47 + win.addEventListener("load", function onLoad() { 1.48 + win.removeEventListener("load", onLoad, false); 1.49 + windowsToClose.push(win); 1.50 + gWindow = win; 1.51 + whenDelayedStartupFinished(win, TestRunner.next); 1.52 + }, false); 1.53 +} 1.54 + 1.55 +function whenDelayedStartupFinished(win, callback) { 1.56 + const topic = "browser-delayed-startup-finished"; 1.57 + Services.obs.addObserver(function onStartup(subject) { 1.58 + if (win == subject) { 1.59 + Services.obs.removeObserver(onStartup, topic); 1.60 + executeSoon(callback); 1.61 + } 1.62 + }, topic, false); 1.63 +} 1.64 + 1.65 +registerCleanupFunction(function () { 1.66 + gWindow = window; 1.67 + windowsToClose.forEach(function(win) { 1.68 + win.close(); 1.69 + }); 1.70 +}); 1.71 +