| 322 | } |
| 323 | |
| 324 | function startLoading() { |
| 325 | // abort any pending loads first |
| 326 | if (win.webContents.isLoading()) { |
| 327 | parent.emit('log', 'aborting pending page load') |
| 328 | win.webContents.once('did-stop-loading', function() { |
| 329 | startLoading(true) |
| 330 | }) |
| 331 | return win.webContents.stop() |
| 332 | } |
| 333 | |
| 334 | win.webContents.on('did-fail-load', handleFailure) |
| 335 | win.webContents.on('did-fail-provisional-load', handleFailure) |
| 336 | win.webContents.on('did-get-response-details', handleDetails) |
| 337 | win.webContents.on('dom-ready', handleDomReady) |
| 338 | win.webContents.on('did-finish-load', handleFinish) |
| 339 | win.webContents.loadURL(url, loadUrlOptions) |
| 340 | |
| 341 | // javascript: URLs *may* trigger page loads; wait a bit to see |
| 342 | if (protocol === 'javascript:') { |
| 343 | setTimeout(function() { |
| 344 | if (!win.webContents.isLoadingMainFrame()) { |
| 345 | done(null, { |
| 346 | url: url, |
| 347 | code: 200, |
| 348 | method: 'GET', |
| 349 | referrer: win.webContents.getURL(), |
| 350 | headers: {} |
| 351 | }) |
| 352 | } |
| 353 | }, 10) |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | var protocol = urlFormat.parse(url).protocol |
| 358 | canLoadProtocol(protocol, function startLoad(canLoad) { |