browser/components/privatebrowsing/test/browser/head.js

Thu, 15 Jan 2015 21:13:52 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:13:52 +0100
branch
TOR_BUG_9701
changeset 12
7540298fafa1
permissions
-rw-r--r--

Remove forgotten relic of ABI crash risk averse overloaded method change.

michael@0 1 function whenNewWindowLoaded(aOptions, aCallback) {
michael@0 2 let win = OpenBrowserWindow(aOptions);
michael@0 3 let gotLoad = false;
michael@0 4 let gotActivate = (Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager).activeWindow == win);
michael@0 5
michael@0 6 function maybeRunCallback() {
michael@0 7 if (gotLoad && gotActivate) {
michael@0 8 win.BrowserChromeTest.runWhenReady(function() {
michael@0 9 executeSoon(function() { aCallback(win); });
michael@0 10 });
michael@0 11 }
michael@0 12 }
michael@0 13
michael@0 14 if (!gotActivate) {
michael@0 15 win.addEventListener("activate", function onActivate() {
michael@0 16 info("Got activate.");
michael@0 17 win.removeEventListener("activate", onActivate, false);
michael@0 18 gotActivate = true;
michael@0 19 maybeRunCallback();
michael@0 20 }, false);
michael@0 21 } else {
michael@0 22 info("Was activated.");
michael@0 23 }
michael@0 24
michael@0 25 win.addEventListener("load", function onLoad() {
michael@0 26 info("Got load");
michael@0 27 win.removeEventListener("load", onLoad, false);
michael@0 28 gotLoad = true;
michael@0 29 maybeRunCallback();
michael@0 30 }, false);
michael@0 31 return win;
michael@0 32 }
michael@0 33
michael@0 34 function openWindow(aParent, aOptions, a3) {
michael@0 35 let { Promise: { defer } } = Components.utils.import("resource://gre/modules/Promise.jsm", {});
michael@0 36 let { promise, resolve } = defer();
michael@0 37
michael@0 38 let win = aParent.OpenBrowserWindow(aOptions);
michael@0 39
michael@0 40 win.addEventListener("load", function onLoad() {
michael@0 41 win.removeEventListener("load", onLoad, false);
michael@0 42 resolve(win);
michael@0 43 }, false);
michael@0 44
michael@0 45 return promise;
michael@0 46 }
michael@0 47
michael@0 48 function newDirectory() {
michael@0 49 let FileUtils =
michael@0 50 Cu.import("resource://gre/modules/FileUtils.jsm", {}).FileUtils;
michael@0 51 let tmpDir = FileUtils.getDir("TmpD", [], true);
michael@0 52 let dir = tmpDir.clone();
michael@0 53 dir.append("testdir");
michael@0 54 dir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
michael@0 55 return dir;
michael@0 56 }
michael@0 57
michael@0 58 function newFileInDirectory(aDir) {
michael@0 59 let FileUtils =
michael@0 60 Cu.import("resource://gre/modules/FileUtils.jsm", {}).FileUtils;
michael@0 61 let file = aDir.clone();
michael@0 62 file.append("testfile");
michael@0 63 file.createUnique(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_FILE);
michael@0 64 return file;
michael@0 65 }
michael@0 66
michael@0 67 function clearHistory() {
michael@0 68 // simulate clearing the private data
michael@0 69 Services.obs.notifyObservers(null, "browser:purge-session-history", "");
michael@0 70 }
michael@0 71
michael@0 72 function _initTest() {
michael@0 73 // Don't use about:home as the homepage for new windows
michael@0 74 Services.prefs.setIntPref("browser.startup.page", 0);
michael@0 75 registerCleanupFunction(function() Services.prefs.clearUserPref("browser.startup.page"));
michael@0 76 }
michael@0 77
michael@0 78 _initTest();

mercurial