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

Commit

Permalink
workaround to fix about:safebrowsing redirect
Browse files Browse the repository at this point in the history
fix #8905

Test Plan:
1. safebrowsing test should pass
2. go to downloadme.org. it should redirect to the safebrowsing page and the page should not be blank or have missing text.
  • Loading branch information
diracdeltas authored and bsclifton committed May 18, 2017
1 parent 5706a55 commit 2186b3f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
4 changes: 3 additions & 1 deletion app/filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ function registerForBeforeRequest (session, partition) {
}))

if (parentResourceName === appConfig.resourceNames.SAFE_BROWSING) {
cb({ redirectURL: appUrlUtil.getTargetAboutUrl('about:safebrowsing#' + details.url) })
cb({ cancel: true })
appActions.loadURLRequested(details.tabId,
appUrlUtil.getTargetAboutUrl('about:safebrowsing#' + details.url))
} else if (details.resourceType === 'image') {
cb({ redirectURL: transparent1pxGif })
} else {
Expand Down
8 changes: 6 additions & 2 deletions js/about/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ const ipc = window.chrome.ipcRenderer
let element

ipc.on('language', (e, detail) => {
document.l10n.requestLanguages([detail.langCode])
document.getElementsByName('availableLanguages')[0].content = detail.languageCodes.join(', ')
if (document.l10n) {
document.l10n.requestLanguages([detail.langCode])
document.getElementsByName('availableLanguages')[0].content = detail.languageCodes.join(', ')
} else {
console.error('Missing document.l10n object.')
}
})
ipc.send('request-language')

Expand Down
37 changes: 37 additions & 0 deletions test/bravery-components/safebrowsingTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
/* global describe, it, before */

const Brave = require('../lib/brave')
const {urlInput} = require('../lib/selectors')

describe('safebrowsing interception', function () {
function * setup (client) {
yield client
.waitForBrowserWindow()
.waitForVisible(urlInput)
}

Brave.beforeAll(this)
before(function * () {
this.badUrl = 'http://downloadme.org'
this.safebrowsingUrl = `about:safebrowsing#${this.badUrl}`
yield setup(this.app.client)
})

it('redirects to safebrowsing URL', function * () {
yield this.app.client
.tabByIndex(0)
.url(this.badUrl)
.waitUntil(function () {
return this.getText('body').then((val) => {
return val.includes('For your safety, Brave has blocked this site')
})
})
.windowByUrl(Brave.browserWindowUrl)
.getAttribute(urlInput, 'value').then((value) => {
return value === this.safebrowsingUrl
})
})
})

0 comments on commit 2186b3f

Please sign in to comment.