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

fix data URL phishing warning appear on the wrong tab #10760

Merged
merged 1 commit into from
Sep 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion app/renderer/reducers/frameReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,18 @@ const frameReducer = (state, action, immutableAction) => {
// see bug #8429
const isNewTab = changeInfo.isEmpty()
const activeTabHasUpdated = changeInfo.get('active') != null
const hasBeenActivated = frame.get('hasBeenActivated')

if (!isNewTab && activeTabHasUpdated) {
state = frameStateUtil.updateTabPageIndex(state, tabId)
state = state.set('previewFrameKey', null)
// Show the phishing warning if we are showing a data: tab
// for the first time
state = state.setIn(['ui', 'siteInfo', 'isVisible'],
!hasBeenActivated && isPotentialPhishingUrl(tab.get('url')))
}
if (!frame.get('hasBeenActivated')) {
state = state.setIn(['frames', index, 'hasBeenActivated'], true)
}
}
}
Expand Down Expand Up @@ -183,7 +191,8 @@ const frameReducer = (state, action, immutableAction) => {
})
}
// For potential phishing pages, show a warning
state = state.setIn(['ui', 'siteInfo', 'isVisible'], isPotentialPhishingUrl(action.location))
Copy link
Contributor

Choose a reason for hiding this comment

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

nice find

state = state.setIn(['ui', 'siteInfo', 'isVisible'],
isPotentialPhishingUrl(action.location) && frameStateUtil.isFrameKeyActive(state, action.key))
break
case windowConstants.WINDOW_CLOSE_FRAMES:
let closedFrames = new Immutable.List()
Expand Down
1 change: 1 addition & 0 deletions docs/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ WindowStore
internalFindStatePresent: boolean // true if a find-first (ie findNext: false) call has been made
}
guestInstanceId: string, // not persisted
hasBeenActivated: boolean, // whether this frame has ever been the active frame
history: array, // navigation history
hrefPreview: string, // show hovered link preview
httpsEverywhere: Object<string, Array<string>>, // map of XML rulesets name to redirected resources
Expand Down
21 changes: 21 additions & 0 deletions test/navbar-components/siteInfoTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,26 @@ describe('siteInfo component tests', function () {
.waitForElementCount(siteInfoDialog, 1)
.waitForElementCount(siteInfoDialog, 0)
})

it('shows siteInfo once when switching to a new tab', function * () {
const page1 = 'data:,Hello%2C%20World!'
yield this.app.client
.tabByIndex(0)
.url('https://example.com')
.windowByUrl(Brave.browserWindowUrl)
.newTab({
active: false,
url: page1
})
.windowByUrl(Brave.browserWindowUrl)
.waitForElementCount(siteInfoDialog, 0)
.activateTabByIndex(1)
.waitForElementCount(siteInfoDialog, 1)
.activateTabByIndex(0)
.waitForElementCount(siteInfoDialog, 0)
.activateTabByIndex(1)
.waitForExist('[data-test-active-tab][data-frame-key="2"]')
.waitForElementCount(siteInfoDialog, 0)
})
})
})