Skip to content

Commit

Permalink
Allow about pages to reload and clone
Browse files Browse the repository at this point in the history
fix brave#2826

Auditors: @bridiver, @bbondy

Test Plan:
1. Generate any error pages(connection error, cert error, ...)
2. Clone/Reload should work properly (reload the original URL)

1. Go to any about pages
2. Clone/Reload should work properly (reload the original URL)
  • Loading branch information
darkdh committed Oct 18, 2016
1 parent a720a94 commit 61994b5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
19 changes: 8 additions & 11 deletions js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const debounce = require('../lib/debounce')
const getSetting = require('../settings').getSetting
const config = require('../constants/config')
const settings = require('../constants/settings')
const {aboutUrls, isSourceAboutUrl, isTargetAboutUrl, getTargetAboutUrl, getBaseUrl, isNavigatableAboutPage} = require('../lib/appUrlUtil')
const {aboutUrls, isSourceAboutUrl, isTargetAboutUrl, getTargetAboutUrl, getBaseUrl, isIntermediateAboutPage} = require('../lib/appUrlUtil')
const {isFrameError} = require('../../app/common/lib/httpUtil')
const locale = require('../l10n')
const appConfig = require('../constants/appConfig')
Expand Down Expand Up @@ -73,6 +73,10 @@ class Frame extends ImmutableComponent {
return aboutUrls.get(getBaseUrl(this.props.location))
}

isIntermediateAboutPage () {
return isIntermediateAboutPage(getBaseUrl(this.props.location))
}

updateAboutDetails () {
let location = getBaseUrl(this.props.location)
if (location === 'about:preferences') {
Expand Down Expand Up @@ -404,9 +408,6 @@ class Frame extends ImmutableComponent {
}

clone (args) {
if (!isNavigatableAboutPage(getBaseUrl(this.props.location))) {
return
}
const newGuest = this.webview.clone()
const newGuestInstanceId = newGuest.getWebPreferences().guestInstanceId
let cloneAction
Expand All @@ -427,23 +428,19 @@ class Frame extends ImmutableComponent {
this.webview.stop()
break
case 'reload':
if (this.isAboutPage()) {
break
}
// Ensure that the webview thinks we're on the same location as the browser does.
// This can happen for pages which don't load properly.
// Some examples are basic http auth and bookmarklets.
// In this case both the user display and the user think they're on this.props.location.
if (this.webview.getURL() !== this.props.location) {
if (this.webview.getURL() !== this.props.location && !this.isAboutPage()) {
this.webview.loadURL(this.props.location)
} else if (this.isIntermediateAboutPage()) {
this.webview.loadURL(this.props.aboutDetails.get('url'))
} else {
this.webview.reload()
}
break
case 'clean-reload':
if (this.isAboutPage()) {
break
}
this.webview.reloadIgnoringCache()
break
case 'clone':
Expand Down
2 changes: 1 addition & 1 deletion js/components/navigationBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class NavigationBar extends ImmutableComponent {
}
<div className='startButtons'>
{
isSourceAboutUrl(this.props.location) || this.titleMode
this.titleMode
? null
: this.loading
? <Button iconClass='fa-times'
Expand Down
1 change: 1 addition & 0 deletions js/state/frameStateUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ function cloneFrame (frameOpts, guestInstanceId) {
clone.location = 'about:blank'
clone.src = 'about:blank'
clone.parentFrameKey = frameOpts.key
clone.aboutDetails = frameOpts.aboutDetails
return clone
}

Expand Down

0 comments on commit 61994b5

Please sign in to comment.