| Left: | ||
| Right: |
| 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'; | |
| 8 | |
| 7 /** | 9 /** |
| 8 * @module main | 10 * @module main |
| 9 */ | 11 */ |
| 10 | 12 |
| 11 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); | 13 const {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {}); |
|
Wladimir Palant
2016/09/29 10:36:10
Why did you remove Services.jsm? It is being used
| |
| 12 Cu.import("resource://gre/modules/Services.jsm"); | |
| 13 Cu.import("resource://gre/modules/Promise.jsm"); | |
| 14 | 14 |
| 15 require("commandLine"); | 15 require("commandLine"); |
| 16 let {run} = require("crawler"); | 16 let {run} = require("crawler"); |
| 17 | 17 |
| 18 let baseURL = null; | 18 let baseURL = null; |
| 19 | 19 |
| 20 /** | 20 /** |
| 21 * Waits for the application to initialize. | 21 * Waits for the application to initialize. |
| 22 * @type {Promise} | 22 * @type {Promise} |
| 23 */ | 23 */ |
| 24 let applicationReady = (function() | 24 let applicationReady = (function() |
| 25 { | 25 { |
| 26 let deferred = Promise.defer(); | 26 let resolveWindowsRestored; |
| 27 | 27 |
| 28 let observer = { | 28 let observer = { |
| 29 observe: function(subject, topic, data) | 29 observe: function(subject, topic, data) |
| 30 { | 30 { |
| 31 Services.obs.removeObserver(this, "sessionstore-windows-restored"); | 31 Services.obs.removeObserver(this, "sessionstore-windows-restored"); |
| 32 deferred.resolve(); | 32 resolveWindowsRestored(); |
| 33 }, | 33 }, |
| 34 QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakRef erence]) | 34 QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakRef erence]) |
| 35 }; | 35 }; |
| 36 | 36 let windowsRestored = new Promise((resolve) => resolveWindowsRestored = resolv e); |
| 37 Services.obs.addObserver(observer, "sessionstore-windows-restored", true); | 37 Services.obs.addObserver(observer, "sessionstore-windows-restored", true); |
| 38 onShutdown.add(() => Services.obs.removeObserver(observer, "sessionstore-windo ws-restored")); | 38 onShutdown.add(() => Services.obs.removeObserver(observer, "sessionstore-windo ws-restored")); |
| 39 | 39 |
| 40 return deferred.promise; | 40 return windowsRestored; |
|
Wladimir Palant
2016/09/29 10:36:10
This is not how the code should be structured - yo
sergei
2016/09/29 12:46:16
Done in https://codereview.adblockplus.org/2935527
| |
| 41 })(); | 41 })(); |
| 42 | 42 |
| 43 /** | 43 /** |
| 44 * Startup function, called from command line handler. | 44 * Startup function, called from command line handler. |
| 45 * | 45 * |
| 46 * @param {int} port Port to communicate with | 46 * @param {int} port Port to communicate with |
| 47 */ | 47 */ |
| 48 function startup(port) | 48 function startup(port) |
| 49 { | 49 { |
| 50 baseURL = "http://localhost:" + port + "/"; | 50 baseURL = "http://localhost:" + port + "/"; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 | 83 |
| 84 /** | 84 /** |
| 85 * Called if requesting parameters failed. | 85 * Called if requesting parameters failed. |
| 86 * | 86 * |
| 87 * @param {Event} event | 87 * @param {Event} event |
| 88 */ | 88 */ |
| 89 function onParametersFailed(event) | 89 function onParametersFailed(event) |
| 90 { | 90 { |
| 91 Cu.reportError("Failed loading parameters"); | 91 Cu.reportError("Failed loading parameters"); |
| 92 } | 92 } |
| OLD | NEW |