1/* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4"use strict"; 5 6/* This is a JavaScript module (JSM) to be imported via 7 Components.utils.import() and acts as a singleton. 8 Only the following listed symbols will exposed on import, and only when 9 and where imported. */ 10 11const EXPORTED_SYMBOLS = ["BrowserWindows"]; 12 13const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); 14 15var BrowserWindows = { 16 /** 17 * Add 18 * 19 * Opens a new window. Throws on error. 20 * 21 * @param aPrivate The private option. 22 * @return nothing 23 */ 24 Add(aPrivate, fn) { 25 return new Promise(resolve => { 26 let mainWindow = Services.wm.getMostRecentWindow("navigator:browser"); 27 let win = mainWindow.OpenBrowserWindow({ private: aPrivate }); 28 win.addEventListener( 29 "load", 30 function() { 31 resolve(win); 32 }, 33 { once: true } 34 ); 35 }); 36 }, 37}; 38