| 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 /** | 7 /** |
| 8 * @module crawler | 8 * @module crawler |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 * Maximum number of tabs to be opened | 204 * Maximum number of tabs to be opened |
| 205 * @param {String} targetURL | 205 * @param {String} targetURL |
| 206 * URL that should receive the results | 206 * URL that should receive the results |
| 207 * @param {Function} onDone | 207 * @param {Function} onDone |
| 208 * The callback which is called after finishing of crawling of all URLs. | 208 * The callback which is called after finishing of crawling of all URLs. |
| 209 */ | 209 */ |
| 210 function run(window, urls, timeout, maxtabs, targetURL, onDone) | 210 function run(window, urls, timeout, maxtabs, targetURL, onDone) |
| 211 { | 211 { |
| 212 new Promise((resolve, reject) => | 212 new Promise((resolve, reject) => |
| 213 { | 213 { |
| 214 if (FilterStorage.subscriptions.length > 0 && !FilterStorage._loading) | 214 if (FilterStorage.subscriptions.length > 0) |
| 215 { | 215 { |
| 216 resolve(); | 216 resolve(); |
| 217 return; | 217 return; |
| 218 } | 218 } |
| 219 FilterNotifier.addListener((action, item, newValue, oldValue) => | 219 let onFiltersLoaded = (action, item, newValue, oldValue) => |
| 220 { | 220 { |
| 221 if (action == "load") | 221 if (action == "load") |
| 222 { | 222 { |
| 223 FilterNotifier.removeListener(onFiltersLoaded); |
| 223 resolve(); | 224 resolve(); |
| 224 } | 225 } |
| 225 }); | 226 }; |
| 226 }).then(() => crawl_urls(window, urls, timeout, maxtabs, targetURL, onDone)).c
atch(reportException); | 227 FilterNotifier.addListener(onFiltersLoaded); |
| 228 }).then(() => crawl_urls(window, urls, timeout, maxtabs, targetURL, onDone)) |
| 229 .catch(reportException); |
| 227 } | 230 } |
| 228 exports.run = run; | 231 exports.run = run; |
| 229 | 232 |
| 230 /** | 233 /** |
| 231 * Spawns a {Task} task to crawl each url from `urls` argument and calls | 234 * Spawns a {Task} task to crawl each url from `urls` argument and calls |
| 232 * `onDone` when all tasks are finished. | 235 * `onDone` when all tasks are finished. |
| 233 * @param {Window} window | 236 * @param {Window} window |
| 234 * The browser window we're operating in | 237 * The browser window we're operating in |
| 235 * @param {String[]} urls | 238 * @param {String[]} urls |
| 236 * URLs to be crawled | 239 * URLs to be crawled |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 | 356 |
| 354 function reportException(e) | 357 function reportException(e) |
| 355 { | 358 { |
| 356 let stack = ""; | 359 let stack = ""; |
| 357 if (e && typeof e == "object" && "stack" in e) | 360 if (e && typeof e == "object" && "stack" in e) |
| 358 stack = e.stack + "\n"; | 361 stack = e.stack + "\n"; |
| 359 | 362 |
| 360 Cu.reportError(e); | 363 Cu.reportError(e); |
| 361 dump(e + "\n" + stack + "\n"); | 364 dump(e + "\n" + stack + "\n"); |
| 362 } | 365 } |
| LEFT | RIGHT |