diff --git a/js/components/urlBar.js b/js/components/urlBar.js index 1cac2c4aef8..4ab221e3488 100644 --- a/js/components/urlBar.js +++ b/js/components/urlBar.js @@ -250,9 +250,13 @@ class UrlBar extends ImmutableComponent { } onActiveFrameStop () { - this.restore() - windowActions.setUrlBarSelected(true) - windowActions.setUrlBarActive(false) + if (this.isFocused()) { + windowActions.setUrlBarActive(false) + if (!this.shouldRenderUrlBarSuggestions) { + this.restore() + windowActions.setUrlBarSelected(true) + } + } } componentWillMount () { diff --git a/test/components/navigationBarTest.js b/test/components/navigationBarTest.js index 81008fcc9a1..53a8982b1ba 100644 --- a/test/components/navigationBarTest.js +++ b/test/components/navigationBarTest.js @@ -445,14 +445,52 @@ describe('navigationBar', function () { }) }) - describe('escape', function * () { + describe('type escape once', function () { before(function * () { - yield this.app.client.ipcSend('shortcut-active-frame-stop') + this.page = Brave.server.url('page1.html') + return yield this.app.client + .tabByIndex(0) + .loadUrl(this.page) + .windowByUrl(Brave.browserWindowUrl) + .ipcSend('shortcut-focus-url') + .waitForElementFocus(urlInput) + .setValue(urlInput, 'blah') + // hit escape + .keys('\uE00C') + .waitForElementFocus(urlInput) + }) + + it('does not select the urlbar text', function * () { + yield selectsText(this.app.client, '') + }) + + it('does not revert the urlbar text', function * () { + yield this.app.client.getValue(urlInput).should.eventually.be.equal('blah') + }) + }) + + describe('type escape twice', function () { + before(function * () { + this.page = Brave.server.url('page1.html') + return yield this.app.client + .tabByIndex(0) + .loadUrl(this.page) + .windowByUrl(Brave.browserWindowUrl) + .ipcSend('shortcut-focus-url') + .waitForElementFocus(urlInput) + .setValue(urlInput, 'blah') + // hit escape + .keys('\uE00C') + .waitForElementFocus(urlInput) + .keys('\uE00C') }) - it('reverts typing on escape', function * () { - yield this.app.client.getValue(urlInput).should.eventually.be.equal(config.defaultUrl) - yield selectsText(this.app.client) + it('selects the urlbar text', function * () { + yield selectsText(this.app.client, this.page) + }) + + it('sets the urlbar text to the webview src', function * () { + yield this.app.client.getValue(urlInput).should.eventually.be.equal(this.page) }) }) @@ -643,12 +681,6 @@ describe('navigationBar', function () { }) }) - describe('escape', function () { - it('sets the urlbar text to the webview src') - - it('selects the urlbar text') - }) - describe('shortcut-focus-url', function () { Brave.beforeAll(this) diff --git a/test/components/urlBarSuggestionsTest.js b/test/components/urlBarSuggestionsTest.js index 397b651f186..fe94ba34a6c 100644 --- a/test/components/urlBarSuggestionsTest.js +++ b/test/components/urlBarSuggestionsTest.js @@ -30,6 +30,20 @@ describe('urlbarSuggestions', function () { .waitForElementFocus(urlInput) }) + it('deactivates suggestions on escape', function * () { + yield this.app.client.ipcSend('shortcut-focus-url') + .waitForElementFocus(urlInput) + .setValue(urlInput, 'Page 1') + .waitUntil(function () { + return this.getValue(urlInput).then((val) => val === 'Page 1') + }) + .waitForExist(urlBarSuggestions) + .keys('\uE00C') + .waitUntil(function () { + return this.isExisting(urlBarSuggestions).then((exists) => exists === false) + }) + }) + it('navigates to a suggestion when clicked', function * () { yield this.app.client.ipcSend('shortcut-focus-url') .waitForElementFocus(urlInput)