diff --git a/app/filtering.js b/app/filtering.js index d89e839f859..96c4448386b 100644 --- a/app/filtering.js +++ b/app/filtering.js @@ -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 { diff --git a/js/about/entry.js b/js/about/entry.js index bc931253f91..9c94bd6841a 100644 --- a/js/about/entry.js +++ b/js/about/entry.js @@ -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') diff --git a/test/bravery-components/safebrowsingTest.js b/test/bravery-components/safebrowsingTest.js new file mode 100644 index 00000000000..1ea1679c677 --- /dev/null +++ b/test/bravery-components/safebrowsingTest.js @@ -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 + }) + }) +})