diff --git a/app/renderer/reducers/frameReducer.js b/app/renderer/reducers/frameReducer.js index b140925bea7..66f7cab1752 100644 --- a/app/renderer/reducers/frameReducer.js +++ b/app/renderer/reducers/frameReducer.js @@ -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) } } } @@ -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)) + 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() diff --git a/docs/state.md b/docs/state.md index 62c6ce2c21d..f00b5e921d4 100644 --- a/docs/state.md +++ b/docs/state.md @@ -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>, // map of XML rulesets name to redirected resources diff --git a/test/navbar-components/siteInfoTest.js b/test/navbar-components/siteInfoTest.js index 776f30065b5..7c04b303d91 100644 --- a/test/navbar-components/siteInfoTest.js +++ b/test/navbar-components/siteInfoTest.js @@ -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) + }) }) })