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

Commit

Permalink
Merge pull request #3857 from brave/fix/3851
Browse files Browse the repository at this point in the history
If directly-entered URL load fails, show the location of the displayed page
  • Loading branch information
bbondy committed Sep 12, 2016
2 parents bf710ce + 670b4d4 commit b8f54c8
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 3 deletions.
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>

0 comments on commit b8f54c8

Please sign in to comment.