| Left: | ||
| Right: |
| 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 253 * @param {String} url | 253 * @param {String} url |
| 254 * @param {TabAllocator} tabAllocator | 254 * @param {TabAllocator} tabAllocator |
| 255 * @param {loadListener} loadListener | 255 * @param {loadListener} loadListener |
| 256 * @result {Object} | 256 * @result {Object} |
| 257 * Crawling result | 257 * Crawling result |
| 258 */ | 258 */ |
| 259 function* crawl_url(url, tabAllocator, loadListener) | 259 function* crawl_url(url, tabAllocator, loadListener) |
| 260 { | 260 { |
| 261 let tab = yield tabAllocator.getTab(); | 261 let tab = yield tabAllocator.getTab(); |
| 262 let result = {url, requests: []}; | 262 let result = {url, requests: []}; |
| 263 | 263 let requestNotifier; |
| 264 try | 264 try |
| 265 { | 265 { |
| 266 result.startTime = Date.now(); | 266 result.startTime = Date.now(); |
| 267 let requestNotifier = new RequestNotifier(tab.linkedBrowser.outerWindowID, f unction({type, location, filter}, scanComplete) | 267 requestNotifier = new RequestNotifier(tab.linkedBrowser.outerWindowID, |
|
Wladimir Palant
2016/03/14 19:50:43
When the scan is completed the listener is called
sergei
2016/03/15 10:59:56
Fixed, is the indentation correct now?
sergei
2016/03/15 10:59:56
Fixed.
However, I guess, it should be documented
Wladimir Palant
2016/03/15 11:05:44
Yes, it should be documented. As to reproducing -
| |
| 268 { | 268 function(entry, scanComplete) |
| 269 result.requests.push({location, contentType: type, filter}); | 269 { |
| 270 if (!entry) | |
| 271 return; | |
| 272 let {type: contentType, location, filter} = entry; | |
| 273 result.requests.push({location, contentType, filter}); | |
| 270 }); | 274 }); |
|
Wladimir Palant
2016/03/14 19:50:43
You need to shut down this notifier when you are d
sergei
2016/03/15 10:59:56
Done. Thanks, overlooked it.
| |
| 271 | 275 |
| 272 tab.linkedBrowser.loadURI(url, null, null); | 276 tab.linkedBrowser.loadURI(url, null, null); |
| 273 [result.channelStatus, result.headers] = yield loadListener.waitForLoad(tab) ; | 277 [result.channelStatus, result.headers] = yield loadListener.waitForLoad(tab) ; |
| 274 result.endTime = Date.now(); | 278 result.endTime = Date.now(); |
| 275 result.finalUrl = tab.linkedBrowser.currentURI.spec; | 279 result.finalUrl = tab.linkedBrowser.currentURI.spec; |
| 276 | 280 |
| 277 let document = tab.linkedBrowser.contentDocument; | 281 let document = tab.linkedBrowser.contentDocument; |
| 278 if (document.documentElement) | 282 if (document.documentElement) |
| 279 { | 283 { |
| 280 try | 284 try |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 293 result.error = "Capturing screenshot failed: " + e; | 297 result.error = "Capturing screenshot failed: " + e; |
| 294 } | 298 } |
| 295 | 299 |
| 296 // TODO: Capture frames as well? | 300 // TODO: Capture frames as well? |
| 297 let serializer = new tab.ownerDocument.defaultView.XMLSerializer(); | 301 let serializer = new tab.ownerDocument.defaultView.XMLSerializer(); |
| 298 result.source = serializer.serializeToString(document.documentElement); | 302 result.source = serializer.serializeToString(document.documentElement); |
| 299 } | 303 } |
| 300 } | 304 } |
| 301 finally | 305 finally |
| 302 { | 306 { |
| 307 if (requestNotifier) | |
| 308 requestNotifier.shutdown(); | |
| 303 tabAllocator.releaseTab(tab); | 309 tabAllocator.releaseTab(tab); |
| 304 } | 310 } |
| 305 return result; | 311 return result; |
| 306 } | 312 } |
| 307 | 313 |
| 308 function reportException(e) | 314 function reportException(e) |
| 309 { | 315 { |
| 310 let stack = ""; | 316 let stack = ""; |
| 311 if (e && typeof e == "object" && "stack" in e) | 317 if (e && typeof e == "object" && "stack" in e) |
| 312 stack = e.stack + "\n"; | 318 stack = e.stack + "\n"; |
| 313 | 319 |
| 314 Cu.reportError(e); | 320 Cu.reportError(e); |
| 315 dump(e + "\n" + stack + "\n"); | 321 dump(e + "\n" + stack + "\n"); |
| 316 } | 322 } |
| LEFT | RIGHT |