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

Commit

Permalink
Update the correct frame's text on nav aborted
Browse files Browse the repository at this point in the history
Auditors: @bsclifton

Fix #8251

If a background tab event came in it would cause the active frame's input text to change.  This could have caused some intermittent strangeness in urlbar previously as well

The fix is to pass the frame path to update to updateNavBarInput so it
doesn't use the active frame.
  • Loading branch information
bbondy committed Apr 12, 2017
1 parent 4c30321 commit b770407
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
5 changes: 3 additions & 2 deletions app/renderer/reducers/urlBarReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ const navigationAborted = (state, action) => {
if (frame) {
let location = action.location || frame.get('provisionalLocation')
if (location) {
const frameStatePath = frameStatePathForFrame(state, frame)
location = getLocation(location)
state = updateNavBarInput(state, location)
state = state.mergeIn(frameStatePathForFrame(state, frame), {
state = updateNavBarInput(state, location, frameStatePath)
state = state.mergeIn(frameStatePath, {
location
})
}
Expand Down
33 changes: 30 additions & 3 deletions test/unit/app/renderer/reducers/urlBarReducerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,28 @@ require('../../../braveUnit')
const windowState = Immutable.fromJS({
activeFrameKey: 2,
frames: [{
key: 1
key: 1,
tabId: 1,
navbar: {
urlbar: {
location: 'https://www.twitter.com'
}
}
}, {
key: 2,
tabId: 2,
title: 'test',
adblock: {blocked: []},
audioPlaybackActive: true,
computedThemeColor: '#ff0000',
httpsEverywhere: {a: '1'},
icon: 'https://www.brave.com/favicon.ico',
location: 'https://www.brave.com/2',
navbar: {
urlbar: {
location: 'https://www.brave.com/2'
}
},
noScript: {blocked: []},
themeColor: '#ffffff',
trackingProtection: {blocked: []},
Expand All @@ -41,7 +53,6 @@ describe('urlBarReducer', function () {
mockery.registerMock('electron', fakeElectron)
urlBarReducer = require('../../../../../app/renderer/reducers/urlBarReducer')
})

after(function () {
mockery.disable()
})
Expand All @@ -57,7 +68,7 @@ describe('urlBarReducer', function () {
})

it('Does not change url bar state of non active frame key', function () {
assert.equal(this.newState.getIn(['frames', 0, 'navbar', 'urlbar', 'location']), undefined)
assert.equal(this.newState.getIn(['frames', 0, 'navbar', 'urlbar', 'location']), 'https://www.twitter.com')
})
})

Expand Down Expand Up @@ -113,4 +124,20 @@ describe('urlBarReducer', function () {
})
})
})

describe('WINDOW_SET_NAVIGATION_ABORTED', function () {
before(function () {
})
it('sets the correct frame\'s text', function () {
// Active frame key is 2 but let's update tabId 1 (frameKey 1 too)
const action = {
actionType: windowConstants.WINDOW_SET_NAVIGATION_ABORTED,
tabId: 1,
location: 'https://facebook.com/'
}
this.newState = urlBarReducer(windowState, action)
assert.equal(this.newState.getIn(['frames', 0, 'navbar', 'urlbar', 'location']), action.location)
assert.equal(this.newState.getIn(['frames', 0, 'location']), action.location)
})
})
})

0 comments on commit b770407

Please sign in to comment.