From f537cc32a361bcaadf1f5a6b2ec03d22482b3c85 Mon Sep 17 00:00:00 2001 From: yan Date: Tue, 16 May 2017 01:17:09 +0000 Subject: [PATCH] fix 'about:blank' being displayed permanently on new tabs fix https://github.com/brave/browser-laptop/issues/8850 Test Plan: 1. open several new tabs. they should all show blank in the urlbar instead of about:blank after a short lag. 2. 'new tab button' and 'new tab signal' tests should pass. --- app/renderer/components/navigation/urlBar.js | 7 ++++-- test/tab-components/tabTest.js | 25 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/app/renderer/components/navigation/urlBar.js b/app/renderer/components/navigation/urlBar.js index 3541c8fa46..cc71a93072 100644 --- a/app/renderer/components/navigation/urlBar.js +++ b/app/renderer/components/navigation/urlBar.js @@ -357,10 +357,13 @@ class UrlBar extends React.Component { componentDidUpdate (prevProps) { // this.urlInput is not initialized in titleMode if (this.urlInput) { + const pdfjsEnabled = getSetting(settings.PDFJS_ENABLED) if (this.props.activeFrameKey !== prevProps.activeFrameKey) { this.keyPressed = false // The user just changed tabs - this.setValue(this.props.locationValue) + this.setValue(this.props.locationValue !== 'about:blank' + ? this.props.locationValue + : UrlUtil.getDisplayLocation(this.props.location, pdfjsEnabled)) // Each tab has a focused state stored separately if (this.props.isFocused) { this.focus() @@ -369,7 +372,7 @@ class UrlBar extends React.Component { windowActions.setRenderUrlBarSuggestions(false) } else if (this.props.location !== prevProps.location) { // This is a url nav change - this.setValue(UrlUtil.getDisplayLocation(this.props.location, getSetting(settings.PDFJS_ENABLED))) + this.setValue(UrlUtil.getDisplayLocation(this.props.location, pdfjsEnabled)) } else if (this.props.hasLocationValueSuffix && this.props.isActive && this.props.locationValueSuffix !== this.lastSuffix) { diff --git a/test/tab-components/tabTest.js b/test/tab-components/tabTest.js index 343513d1f9..8e11d4f47e 100644 --- a/test/tab-components/tabTest.js +++ b/test/tab-components/tabTest.js @@ -5,6 +5,8 @@ const messages = require('../../js/constants/messages') const settings = require('../../js/constants/settings') const {urlInput, backButton, forwardButton, activeTab, activeTabTitle, activeTabFavicon, newFrameButton, notificationBar, contextMenu, pinnedTabsTabs, tabsTabs} = require('../lib/selectors') +const newTabUrl = 'chrome-extension://mnojpmjdmbbfmejpflffifhffcmidifd/about-newtab.html' + describe('tab tests', function () { function * setup (client) { yield client @@ -89,6 +91,18 @@ describe('tab tests', function () { .waitForExist('[data-test-id="tab"][data-frame-key="2"]') .waitForTextValue('[data-test-id="tab"][data-frame-key="2"]', 'New Tab') }) + + it('shows empty urlbar', function * () { + yield this.app.client + .newTab() + .waitForExist('webview[data-frame-key="4"]') + .waitUntil(function () { + return this.getAttribute('webview[data-frame-key="4"]', 'src').then((value) => value === newTabUrl) + }) + .waitUntil(function () { + return this.getAttribute(urlInput, 'value').then((value) => value === '') + }) + }) }) describe('new tab button', function () { @@ -102,6 +116,17 @@ describe('tab tests', function () { .click(newFrameButton) .waitForExist('[data-test-id="tab"][data-frame-key="2"]') }) + it('shows empty urlbar', function * () { + yield this.app.client + .click(newFrameButton) + .waitForExist('webview[data-frame-key="2"]') + .waitUntil(function () { + return this.getAttribute('webview[data-frame-key="2"]', 'src').then((value) => value === newTabUrl) + }) + .waitUntil(function () { + return this.getAttribute(urlInput, 'value').then((value) => value === '') + }) + }) it.skip('shows a context menu when long pressed (click and hold)', function * () { yield this.app.client .moveToObject(newFrameButton)