Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
handle provisional load failures
Browse files Browse the repository at this point in the history
  • Loading branch information
bridiver committed May 27, 2016
1 parent 9290ee8 commit 1bbc469
Showing 1 changed file with 33 additions and 25 deletions.
58 changes: 33 additions & 25 deletions js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,33 @@ class Frame extends ImmutableComponent {
this.webview.executeJavaScript(hack.pageLoadEndScript)
}
}
const loadFail = (e) => {
if (isFrameError(e.errorCode)) {
// temporary workaround for https://github.com/brave/browser-laptop/issues/1817
if (e.validatedURL === aboutUrls.get('about:newtab') ||
e.validatedURL === aboutUrls.get('about:blank') ||
e.validatedURL === aboutUrls.get('about:certerror') ||
e.validatedURL === aboutUrls.get('about:error') ||
e.validatedURL === aboutUrls.get('about:safebrowsing')) {
// this will just display a blank page for errors
// but we don't want to take the user out of the private tab
return
} else if (isTargetAboutUrl(e.validatedURL)) {
// open a new tab for other about urls
// and send this tab back to wherever it came from
this.goBack()
windowActions.newFrame({location: e.validatedURL}, true)
return
}

windowActions.setFrameError(this.props.frame, {
event_type: 'did-fail-load',
errorCode: e.errorCode,
url: e.validatedURL
})
windowActions.loadUrl(this.props.frame, 'about:error')
}
}
this.webview.addEventListener('load-commit', (e) => {
loadStart(e)
})
Expand All @@ -466,34 +493,15 @@ class Frame extends ImmutableComponent {
windowActions.loadUrl(this.props.frame, 'about:error')
this.webview = false
})
this.webview.addEventListener('did-fail-provisional-load', (e) => {
if (e.isMainFrame) {
loadFail(e)
}
})
this.webview.addEventListener('did-fail-load', (e) => {
if (e.isMainFrame) {
loadEnd()
if (isFrameError(e.errorCode)) {
// temporary workaround for https://github.com/brave/browser-laptop/issues/1817
if (e.validatedURL === aboutUrls.get('about:newtab') ||
e.validatedURL === aboutUrls.get('about:blank') ||
e.validatedURL === aboutUrls.get('about:certerror') ||
e.validatedURL === aboutUrls.get('about:error') ||
e.validatedURL === aboutUrls.get('about:safebrowsing')) {
// this will just display a blank page for errors
// but we don't want to take the user out of the private tab
return
} else if (isTargetAboutUrl(e.validatedURL)) {
// open a new tab for other about urls
// and send this tab back to wherever it came from
this.goBack()
windowActions.newFrame({location: e.validatedURL}, true)
return
}

windowActions.setFrameError(this.props.frame, {
event_type: 'did-fail-load',
errorCode: e.errorCode,
url: e.validatedURL
})
windowActions.loadUrl(this.props.frame, 'about:error')
}
loadFail(e)
}
})
this.webview.addEventListener('did-finish-load', () => {
Expand Down

0 comments on commit 1bbc469

Please sign in to comment.