| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This Source Code is subject to the terms of the Mozilla Public License | 2 * This Source Code is subject to the terms of the Mozilla Public License |
| 3 * version 2.0 (the "License"). You can obtain a copy of the License at | 3 * version 2.0 (the "License"). You can obtain a copy of the License at |
| 4 * http://mozilla.org/MPL/2.0/. | 4 * http://mozilla.org/MPL/2.0/. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 "use strict"; | 7 "use strict"; |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * @module main | 10 * @module main |
| 11 */ | 11 */ |
| 12 | 12 |
| 13 const {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); | 13 const {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); |
| 14 const {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {}); | 14 const {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {}); |
| 15 const {Promise} = Cu.import("resource://gre/modules/Promise.jsm", {}); | |
| 16 | 15 |
| 17 require("commandLine"); | 16 require("commandLine"); |
| 18 let {run} = require("crawler"); | 17 let {run} = require("crawler"); |
| 19 | 18 |
| 20 let baseURL = null; | 19 let baseURL = null; |
| 21 | 20 |
| 22 /** | 21 /** |
| 23 * Waits for the application to initialize. | 22 * Waits for the application to initialize. |
| 24 * @type {Promise} | 23 * @type {Promise} |
| 25 */ | 24 */ |
| 26 let applicationReady = (function() | 25 let applicationReady = new Promise((resolve, reject) => |
| 27 { | 26 { |
| 28 let deferred = Promise.defer(); | |
| 29 | |
| 30 let observer = { | 27 let observer = { |
| 31 observe: function(subject, topic, data) | 28 observe: function(subject, topic, data) |
| 32 { | 29 { |
| 33 Services.obs.removeObserver(this, "sessionstore-windows-restored"); | 30 Services.obs.removeObserver(this, "sessionstore-windows-restored"); |
| 34 deferred.resolve(); | 31 resolve(); |
| 35 }, | 32 }, |
| 36 QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakRef
erence]) | 33 QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakRef
erence]) |
| 37 }; | 34 }; |
| 38 | |
| 39 Services.obs.addObserver(observer, "sessionstore-windows-restored", true); | 35 Services.obs.addObserver(observer, "sessionstore-windows-restored", true); |
| 40 onShutdown.add(() => Services.obs.removeObserver(observer, "sessionstore-windo
ws-restored")); | 36 onShutdown.add(() => Services.obs.removeObserver(observer, "sessionstore-windo
ws-restored")); |
| 41 | 37 }); |
| 42 return deferred.promise; | |
| 43 })(); | |
| 44 | 38 |
| 45 /** | 39 /** |
| 46 * Startup function, called from command line handler. | 40 * Startup function, called from command line handler. |
| 47 * | 41 * |
| 48 * @param {int} port Port to communicate with | 42 * @param {int} port Port to communicate with |
| 49 */ | 43 */ |
| 50 function startup(port) | 44 function startup(port) |
| 51 { | 45 { |
| 52 baseURL = "http://localhost:" + port + "/"; | 46 baseURL = "http://localhost:" + port + "/"; |
| 53 | 47 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 79 |
| 86 /** | 80 /** |
| 87 * Called if requesting parameters failed. | 81 * Called if requesting parameters failed. |
| 88 * | 82 * |
| 89 * @param {Event} event | 83 * @param {Event} event |
| 90 */ | 84 */ |
| 91 function onParametersFailed(event) | 85 function onParametersFailed(event) |
| 92 { | 86 { |
| 93 Cu.reportError("Failed loading parameters"); | 87 Cu.reportError("Failed loading parameters"); |
| 94 } | 88 } |
| OLD | NEW |