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