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

Commit

Permalink
Follow-up fixes to #3857
Browse files Browse the repository at this point in the history
Fix #3928
Fix #3927

Auditors: @bridiver

Test Plan:
Same as #3857 but also
make sure that entering a URL like nytimes.com in the URL bar does not
show a blank location before the page is done loading.
  • Loading branch information
diracdeltas committed Sep 13, 2016
1 parent 58dbabc commit 3ff17ae
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
19 changes: 14 additions & 5 deletions js/actions/windowActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,23 @@ const windowActions = {
location
}, true)
} else {
dispatch({
actionType: WindowConstants.WINDOW_SET_URL,
location,
key: frame.get('key')
})
this.setUrl(location, frame.get('key'))
}
},

/**
* Dispatches a message to the store to set the new URL.
* @param {string} location
* @param {number} key
*/
setUrl: function (location, key) {

This comment has been minimized.

Copy link
@bridiver

bridiver Sep 13, 2016

Collaborator

long-term we want to move away from setter actions to descriptor actions setUrl -> loadFailed, but since the rest of this code uses setter actions this seems fine

dispatch({
actionType: WindowConstants.WINDOW_SET_URL,
location,
key
})
},

/**
* Dispatches a message to the store to let it know a page has been navigated.
*
Expand Down
8 changes: 7 additions & 1 deletion js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const debounce = require('../lib/debounce.js')
const getSetting = require('../settings').getSetting
const config = require('../constants/config')
const settings = require('../constants/settings')
const { aboutUrls, isSourceAboutUrl, isTargetAboutUrl, getTargetAboutUrl, getBaseUrl, isNavigatableAboutPage } = require('../lib/appUrlUtil')
const { aboutUrls, isSourceAboutUrl, isTargetAboutUrl, getSourceAboutUrl, getTargetAboutUrl, getBaseUrl, isNavigatableAboutPage } = require('../lib/appUrlUtil')
const { isFrameError } = require('../lib/errorUtil')
const locale = require('../l10n')
const appConfig = require('../constants/appConfig')
Expand Down Expand Up @@ -852,6 +852,12 @@ class Frame extends ImmutableComponent {
})
windowActions.loadUrl(this.frame, 'about:error')
appActions.removeSite(siteUtil.getDetailFromFrame(this.frame))
} else {
const currentLocation = this.webview.getURL()
if (currentLocation !== e.validatedURL) {
windowActions.setUrl(isTargetAboutUrl(currentLocation)

This comment has been minimized.

Copy link
@bridiver

bridiver Sep 14, 2016

Collaborator

I think the issue is that setting the url is reloading the previous page and I think we just want to change the location. The issue might also be related to regular load failures vs provision load failures

This comment has been minimized.

Copy link
@diracdeltas

diracdeltas Sep 14, 2016

Author Member

that could definitely be causing problems. reloading the entire page isn't ideal but it was the easiest way to update all the location-related UI (urlbar input value, the domain in titlemode, security state, etc.). FWIW this only needs to be called on provisional load failure AFAICT

? getSourceAboutUrl(currentLocation) : currentLocation, this.props.frameKey)
}
}
}
this.webview.addEventListener('load-commit', (e) => {
Expand Down
3 changes: 3 additions & 0 deletions js/stores/windowStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ const doAction = (action) => {
windowState = windowState.mergeIn(tabStatePath(action.key), {
location: action.location
})
// Show the location for directly-entered URLs before the page finishes
// loading
updateNavBarInput(action.location, frameStatePath(action.key))
}
break
case WindowConstants.WINDOW_SET_NAVIGATED:
Expand Down
12 changes: 10 additions & 2 deletions test/components/navigationBarTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,12 +596,20 @@ describe('navigationBar', function () {
yield this.app.client.keys('\uE007')
})

it('sets location to new URL immediately', function * () {

This comment has been minimized.

Copy link
@bridiver

bridiver Sep 13, 2016

Collaborator

Looks like the default timeout for waitUntil is 500ms, but I think for now we should drop the "immediately" because 500ms is kind of long. Initially I was going to suggest a shorter timeout, but I think it would be better to have a separate set of performance tests for individual actions

yield this.app.client
.waitUntil(function () {
return this.getValue(urlInput).then((val) => {
return val === 'https://bayden.com/test/redir/goscript.aspx'
})
})
})

it('clears urlbar if page does not load', function * () {

This comment has been minimized.

Copy link
@bridiver

bridiver Sep 13, 2016

Collaborator

I don't think this test title is correct anymore. It should revert to the previous url, correct?

This comment has been minimized.

Copy link
@diracdeltas

diracdeltas Sep 13, 2016

Author Member

yup i should fix that. also this test is failing in travis but passes locally somehow: https://travis-ci.org/brave/browser-laptop/builds/159697369.

This comment has been minimized.

Copy link
@bridiver

bridiver Sep 13, 2016

Collaborator

I think a lot of the tests fail on travis because of timeouts. Was just discussing something I noticed here with @bbondy http://webdriver.io/api/utility/waitUntil.html
timeout === interval === 500ms
So we're wasting time with a long interval and timing out too early for slow machines

yield this.app.client
.waitUntil(function () {
return this.getValue(urlInput).then((val) => {
console.log('value', val)
return val === ''
return val.endsWith('/about-newtab.html')
})
})
})
Expand Down

1 comment on commit 3ff17ae

@bridiver
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is causing problems for onepassword4-extension://activate/Chrome. If onepassword mini is closed, https://agilebits.com/browsers/welcome.html opens up and reloads endlessly

Please sign in to comment.