michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /* michael@0: * These tests ensure that all changes made to the new tab page in private michael@0: * browsing mode are discarded after switching back to normal mode again. michael@0: * The private browsing mode should start with the current grid shown in normal michael@0: * mode. michael@0: */ michael@0: michael@0: function runTests() { michael@0: // prepare the grid michael@0: yield testOnWindow(undefined); michael@0: yield setLinks("0,1,2,3,4,5,6,7,8,9"); michael@0: michael@0: yield addNewTabPageTab(); michael@0: pinCell(0); michael@0: checkGrid("0p,1,2,3,4,5,6,7,8"); michael@0: michael@0: // open private window michael@0: yield testOnWindow({private: true}); michael@0: michael@0: yield addNewTabPageTab(); michael@0: checkGrid("0p,1,2,3,4,5,6,7,8"); michael@0: michael@0: // modify the grid while we're in pb mode michael@0: yield blockCell(1); michael@0: checkGrid("0p,2,3,4,5,6,7,8"); michael@0: michael@0: yield unpinCell(0); michael@0: checkGrid("0,2,3,4,5,6,7,8"); michael@0: michael@0: // open normal window michael@0: yield testOnWindow(undefined); michael@0: michael@0: // check that the grid is the same as before entering pb mode michael@0: yield addNewTabPageTab(); michael@0: checkGrid("0,2,3,4,5,6,7,8") michael@0: } michael@0: michael@0: var windowsToClose = []; michael@0: function testOnWindow(options) { michael@0: var win = OpenBrowserWindow(options); michael@0: win.addEventListener("load", function onLoad() { michael@0: win.removeEventListener("load", onLoad, false); michael@0: windowsToClose.push(win); michael@0: gWindow = win; michael@0: whenDelayedStartupFinished(win, TestRunner.next); michael@0: }, false); michael@0: } michael@0: michael@0: function whenDelayedStartupFinished(win, callback) { michael@0: const topic = "browser-delayed-startup-finished"; michael@0: Services.obs.addObserver(function onStartup(subject) { michael@0: if (win == subject) { michael@0: Services.obs.removeObserver(onStartup, topic); michael@0: executeSoon(callback); michael@0: } michael@0: }, topic, false); michael@0: } michael@0: michael@0: registerCleanupFunction(function () { michael@0: gWindow = window; michael@0: windowsToClose.forEach(function(win) { michael@0: win.close(); michael@0: }); michael@0: }); michael@0: