LEFT | RIGHT |
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 crawler | 10 * @module crawler |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 else | 153 else |
154 window.close(); | 154 window.close(); |
155 }, false); | 155 }, false); |
156 }, | 156 }, |
157 | 157 |
158 QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakRefer
ence]) | 158 QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakRefer
ence]) |
159 }; | 159 }; |
160 | 160 |
161 function configureFrameScript() | 161 function configureFrameScript() |
162 { | 162 { |
163 const frameScriptPath = info.addonRoot + "/lib/child/frameScript.js"; | 163 const info = require("info"); |
| 164 let frameScriptPath = info.addonRoot + "/lib/child/frameScript.js"; |
164 Services.mm.loadFrameScript(frameScriptPath, true); | 165 Services.mm.loadFrameScript(frameScriptPath, true); |
165 | 166 |
166 onShutdown.add(() => | 167 onShutdown.add(() => |
167 { | 168 { |
168 Services.mm.removeDelayedFrameScript(frameScriptPath); | 169 Services.mm.removeDelayedFrameScript(frameScriptPath); |
169 }); | 170 }); |
170 } | 171 } |
171 | 172 |
172 /** | 173 /** |
173 * Starts the crawling session. The crawler opens each URL in a tab and stores | 174 * Starts the crawling session. The crawler opens each URL in a tab and stores |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 * @param tab | 277 * @param tab |
277 * Tab in which we are interested in | 278 * Tab in which we are interested in |
278 * @param {int} timeout | 279 * @param {int} timeout |
279 * Timeout in milliseconds | 280 * Timeout in milliseconds |
280 * @return {Promise} promise which will be resolved with the received page info | 281 * @return {Promise} promise which will be resolved with the received page info |
281 */ | 282 */ |
282 function getPageInfo(tab, timeout) | 283 function getPageInfo(tab, timeout) |
283 { | 284 { |
284 return new Promise((resolve, result) => | 285 return new Promise((resolve, result) => |
285 { | 286 { |
286 const mm = tab.linkedBrowser.messageManager; | 287 let mm = tab.linkedBrowser.messageManager; |
287 let timerID; | 288 let timerID; |
288 let onDone = (msg) => | 289 let onDone = (msg) => |
289 { | 290 { |
290 mm.removeMessageListener("abpcrawler:pageInfoGathered", onDone); | 291 mm.removeMessageListener("abpcrawler:pageInfoGathered", onDone); |
291 clearTimeout(timerID); | 292 clearTimeout(timerID); |
292 resolve(msg.data); | 293 resolve(msg.data); |
293 } | 294 } |
294 mm.addMessageListener("abpcrawler:pageInfoGathered", onDone); | 295 mm.addMessageListener("abpcrawler:pageInfoGathered", onDone); |
295 timerID = setTimeout(() => onDone({data: {error: "timeout"}}), timeout); | 296 timerID = setTimeout(() => onDone({data: {error: "timeout"}}), timeout); |
296 }); | 297 }); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 | 341 |
341 function reportException(e) | 342 function reportException(e) |
342 { | 343 { |
343 let stack = ""; | 344 let stack = ""; |
344 if (e && typeof e == "object" && "stack" in e) | 345 if (e && typeof e == "object" && "stack" in e) |
345 stack = e.stack + "\n"; | 346 stack = e.stack + "\n"; |
346 | 347 |
347 Cu.reportError(e); | 348 Cu.reportError(e); |
348 dump(e + "\n" + stack + "\n"); | 349 dump(e + "\n" + stack + "\n"); |
349 } | 350 } |
LEFT | RIGHT |