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

If directly-entered URL load fails, show the location of the displayed page #3857

Merged
merged 1 commit into from
Sep 12, 2016
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
3 changes: 0 additions & 3 deletions js/stores/windowStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,6 @@ const doAction = (action) => {
windowState = windowState.mergeIn(tabStatePath(action.key), {
location: action.location
})
// force a navbar update in case this was called from an app
// initiated navigation (bookmarks, etc...)
updateNavBarInput(action.location, frameStatePath(action.key))
}
break
case WindowConstants.WINDOW_SET_NAVIGATED:
Expand Down
48 changes: 48 additions & 0 deletions test/components/navigationBarTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,31 @@ describe('navigationBar', function () {
})
})

describe('document.write spoofing', function () {
Brave.beforeAll(this)

before(function * () {
var page1 = Brave.server.url('urlbarSpoof.html')
yield setup(this.app.client)
yield this.app.client
.tabByUrl(Brave.newTabUrl)
.url(page1)
.waitForUrl(page1)
.waitForExist('input')
.leftClick('input')
})

it('updates the location in the navbar to blank', function * () {
yield this.app.client
.windowByUrl(Brave.browserWindowUrl)
.waitUntil(function () {
return this.getValue(urlInput).then((val) => {
return val === ''
})
})
})
})

describe('page with a title', function () {
Brave.beforeAll(this)

Expand Down Expand Up @@ -559,6 +584,29 @@ describe('navigationBar', function () {
})

describe('submit', function () {
describe('page that does not load', function () {
Brave.beforeAll(this)

before(function * () {
var page1 = 'https://bayden.com/test/redir/goscript.aspx'
yield setup(this.app.client)
yield this.app.client.waitForExist(urlInput)
yield this.app.client.keys(page1)
// hit enter
yield this.app.client.keys('\uE007')
})

it('clears urlbar if page does not load', function * () {
yield this.app.client
.waitUntil(function () {
return this.getValue(urlInput).then((val) => {
console.log('value', val)
return val === ''
})
})
})
})

describe('with url input value', function () {
Brave.beforeAll(this)

Expand Down
10 changes: 10 additions & 0 deletions test/fixtures/urlbarSpoof.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<html>
<script>
function spoof() {
w = window.open('https:/www.google.com', 'target');
w.document.write('<h1 id="message">Here we could place a phishing login panel</h1>');
w.document.close();
}
</script>
<input type="submit" onclick="spoof()" value="PoC!">
</html>