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

Commit

Permalink
Fix back-forward highlight state
Browse files Browse the repository at this point in the history
By updating the state on loadEnd and not loadStart

Auditors: @bsclifton

Fix #5735
  • Loading branch information
bbondy committed Nov 20, 2016
1 parent 689eb10 commit d791401
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
8 changes: 4 additions & 4 deletions js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -924,10 +924,6 @@ class Frame extends ImmutableComponent {
runInsecureContent: false
})
}
windowActions.updateBackForwardState(
this.frame,
this.webview.canGoBack(),
this.webview.canGoForward())
const hack = siteHacks[parsedUrl.hostname]
if (hack && hack.pageLoadStartScript) {
this.webview.executeJavaScript(hack.pageLoadStartScript)
Expand All @@ -940,6 +936,10 @@ class Frame extends ImmutableComponent {
windowActions.onWebviewLoadEnd(
this.frame,
this.webview.getURL())
windowActions.updateBackForwardState(
this.frame,
this.webview.canGoBack(),
this.webview.canGoForward())

const parsedUrl = urlParse(this.props.location)
if (!this.allowRunningWidevinePlugin()) {
Expand Down
25 changes: 25 additions & 0 deletions test/components/frameTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,31 @@ describe('frame tests', function () {
})
})

describe('back-forward state', function () {
Brave.beforeAll(this)
before(function * () {
this.url1 = Brave.server.url('page1.html')
yield setup(this.app.client)
yield this.app.client
.waitForExist('.navigationButtonContainer.disabled .backButton')
.tabByIndex(0)
// add some history
.loadUrl(this.url1)
.windowByUrl(Brave.browserWindowUrl)
})

it('enables back button on first nav', function * () {
yield this.app.client
.waitForExist('.navigationButtonContainer:not(.disabled) .backButton')
})

it('enables forward button after pressing back', function * () {
yield this.app.client
.click(backButton)
.waitForExist('.navigationButtonContainer:not(.disabled) .forwardButton')
})
})

describe('back clone', function () {
Brave.beforeAll(this)

Expand Down

1 comment on commit d791401

@bsclifton
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks for the test 😄

Please sign in to comment.