From 3d6ee2660d0667538cd2194e59718f1440f9538e Mon Sep 17 00:00:00 2001 From: yan Date: Tue, 26 Jan 2016 16:20:41 -0800 Subject: [PATCH 01/23] Add backspace and shift-backspace for back/forward This is somewhat flakey; pages can prevent us from triggering the backspace listener. --- app/content/webviewPreload.js | 21 +++++++++++++++++++++ app/index.js | 6 ++++++ js/components/main.js | 8 ++++++++ js/constants/keyCodes.js | 4 +++- js/constants/messages.js | 2 ++ 5 files changed, 40 insertions(+), 1 deletion(-) diff --git a/app/content/webviewPreload.js b/app/content/webviewPreload.js index 20a3a5857e1..677eec6188d 100644 --- a/app/content/webviewPreload.js +++ b/app/content/webviewPreload.js @@ -210,12 +210,33 @@ document.addEventListener('contextmenu', (e) => { e.preventDefault() }, false) +var shiftDown = false document.onkeydown = (e) => { switch (e.keyCode) { case KeyCodes.ESC: e.preventDefault() ipc.send(messages.STOP_LOAD) break + case KeyCodes.BACKSPACE: + const msg = shiftDown ? messages.GO_FORWARD : messages.GO_BACK + const elem = document.activeElement + if (elem.contentEditable !== 'true' && + elem.nodeName !== 'INPUT' && + elem.nodeName !== 'TEXTAREA') { + // TODO: find other node types where this shortcut should be disabled + ipc.send(msg) + } + break + case KeyCodes.SHIFT: + shiftDown = true + break + } +} +document.onkeyup = (e) => { + switch (e.keyCode) { + case KeyCodes.SHIFT: + shiftDown = false + break } } diff --git a/app/index.js b/app/index.js index e97d836ff8c..3d49a8c8cee 100644 --- a/app/index.js +++ b/app/index.js @@ -134,6 +134,12 @@ app.on('ready', function () { ipcMain.on(messages.STOP_LOAD, () => { BrowserWindow.getFocusedWindow().webContents.send(messages.STOP_LOAD) }) + ipcMain.on(messages.GO_BACK, () => { + BrowserWindow.getFocusedWindow().webContents.send(messages.GO_BACK) + }) + ipcMain.on(messages.GO_FORWARD, () => { + BrowserWindow.getFocusedWindow().webContents.send(messages.GO_FORWARD) + }) // Load HTTPS Everywhere browser "extension" HttpsEverywhere.init() diff --git a/js/components/main.js b/js/components/main.js index c29b8cc2139..bb4a9176d49 100644 --- a/js/components/main.js +++ b/js/components/main.js @@ -35,6 +35,14 @@ class Main extends ImmutableComponent { ipc.on(messages.STOP_LOAD, () => { electron.remote.getCurrentWebContents().send(messages.SHORTCUT_ACTIVE_FRAME_STOP) }) + ipc.on(messages.GO_BACK, () => { + console.log('going back') + electron.remote.getCurrentWebContents().send(messages.SHORTCUT_ACTIVE_FRAME_BACK) + }) + ipc.on(messages.GO_FORWARD, () => { + console.log('going forward') + electron.remote.getCurrentWebContents().send(messages.SHORTCUT_ACTIVE_FRAME_FORWARD) + }) ipc.on(messages.CONTEXT_MENU_OPENED, (e, nodeProps) => { contextMenus.onMainContextMenu(nodeProps) }) diff --git a/js/constants/keyCodes.js b/js/constants/keyCodes.js index 2a6146160e8..7ba94801b53 100644 --- a/js/constants/keyCodes.js +++ b/js/constants/keyCodes.js @@ -6,7 +6,9 @@ const KeyCodes = { ENTER: 13, ESC: 27, UP: 38, - DOWN: 40 + DOWN: 40, + SHIFT: 16, + BACKSPACE: 8 } module.exports = KeyCodes diff --git a/js/constants/messages.js b/js/constants/messages.js index 31175b0b794..21c6fd928b5 100644 --- a/js/constants/messages.js +++ b/js/constants/messages.js @@ -55,6 +55,8 @@ const messages = { APP_STATE_CHANGE: _, APP_ACTION: _, STOP_LOAD: _, + GO_FORWARD: _, + GO_BACK: _, // Session restore REQUEST_WINDOW_STATE: _, RESPONSE_WINDOW_STATE: _, From cb9a4365574c771c024f4082821d6cd6e92b1a41 Mon Sep 17 00:00:00 2001 From: Aubrey Keus Date: Fri, 29 Jan 2016 10:16:33 -0500 Subject: [PATCH 02/23] Send updater query parameters based on calendar date * Compare calendar dates when sending daily flag instead of 86400 seconds * Send first=true if first update request * Use moment.js for date handling --- app/dates.js | 5 ++++ app/updater.js | 56 +++++++++++++++++-------------------------- js/stores/appStore.js | 3 +++ package.json | 1 + 4 files changed, 31 insertions(+), 34 deletions(-) create mode 100644 app/dates.js diff --git a/app/dates.js b/app/dates.js new file mode 100644 index 00000000000..cde74a97715 --- /dev/null +++ b/app/dates.js @@ -0,0 +1,5 @@ +const moment = require('moment') + +exports.todayYMD = () => { + return moment().format('YYYY-MM-DD') +} diff --git a/app/updater.js b/app/updater.js index 673914e0481..2ce2df4bb62 100644 --- a/app/updater.js +++ b/app/updater.js @@ -14,6 +14,7 @@ const querystring = require('querystring') const AppStore = require('../js/stores/appStore') const AppActions = require('../js/actions/appActions') const Immutable = require('immutable') +const dates = require('./dates') const fs = require('fs') const path = require('path') @@ -86,47 +87,34 @@ exports.init = (platform, ver) => { } } -const secondsPerDay = 24 * 60 * 60 -const secondsPerWeek = secondsPerDay * 7 -const secondsPerMonth = secondsPerDay * 30 - // Build a set of three params providing flags determining when the last update occurred // This is a privacy preserving policy. Instead of passing personally identifying // information, the browser will pass the three boolean values indicating when the last // update check occurred. -var paramsFromLastCheckDelta = (seconds) => { +var paramsFromLastCheckDelta = (lastCheckYMD, firstCheckMade) => { // Default params var params = { daily: false, weekly: false, - monthly: false + monthly: false, + first: false } - // First ever check - if (seconds === 0) { + // If the first flag has NOT been set then we will send it + // with the update params to help with daily new users + if (!firstCheckMade || !lastCheckYMD) { + params.first = true params.daily = true return params } - // More than one today - if (seconds < secondsPerDay) { - return params - } - - // If we have not checked today, but we have since last week (first check as well) - if (seconds === 0 || (seconds > secondsPerDay && seconds < secondsPerWeek)) { + // If we have not checked today + if (dates.todayYMD() > lastCheckYMD) { params.daily = true return params } - // If we have not checked this week, but have this month - if (seconds >= secondsPerWeek && seconds < secondsPerMonth) { - params.weekly = true - return params - } - - params.monthly = true - + // Safety return (in case code above changes) return params } @@ -134,19 +122,19 @@ var paramsFromLastCheckDelta = (seconds) => { var requestVersionInfo = (done) => { if (!platformBaseUrl) throw new Error('platformBaseUrl not set') - // Get the timestamp of the last update request - var lastCheckTimestamp = AppStore.getState().toJS().updates['lastCheckTimestamp'] || 0 - debug(`lastCheckTimestamp = ${lastCheckTimestamp}`) + // Get the YMD of the last update request + var lastCheckYMD = AppStore.getState().toJS().updates['lastCheckYMD'] || null + debug(`lastCheckYMD = ${lastCheckYMD}`) - // Calculate the number of seconds since the last update - var secondsSinceLastCheck = 0 - if (lastCheckTimestamp) { - secondsSinceLastCheck = Math.round(((new Date()).getTime() - lastCheckTimestamp) / 1000) - } - debug(`secondsSinceLastCheck = ${secondsSinceLastCheck}`) + // Has the browser ever asked for an update + var firstCheckMade = AppStore.getState().toJS().updates['firstCheckMade'] || false + debug(`firstCheckMade = ${firstCheckMade}`) - // Build query string based on the number of seconds since last check - var query = paramsFromLastCheckDelta(secondsSinceLastCheck) + // Build query string based on the last date an update request was made + var query = paramsFromLastCheckDelta( + lastCheckYMD, + firstCheckMade + ) var queryString = `${platformBaseUrl}?${querystring.stringify(query)}` debug(queryString) diff --git a/js/stores/appStore.js b/js/stores/appStore.js index effb2a4a126..78369956ce4 100644 --- a/js/stores/appStore.js +++ b/js/stores/appStore.js @@ -13,6 +13,7 @@ const LocalShortcuts = require('../../app/localShortcuts') const AppActions = require('../actions/appActions') const firstDefinedValue = require('../lib/functional').firstDefinedValue const Serializer = require('../dispatcher/serializer') +const dates = require('../../app/dates') let appState @@ -240,6 +241,8 @@ const handleAppAction = (action) => { break case AppConstants.APP_UPDATE_LAST_CHECK: appState = appState.setIn(['updates', 'lastCheckTimestamp'], (new Date()).getTime()) + appState = appState.setIn(['updates', 'lastCheckYMD'], dates.todayYMD()) + appState = appState.setIn(['updates', 'firstCheckMade'], true) appStore.emitChange() break case AppConstants.APP_SET_UPDATE_STATUS: diff --git a/package.json b/package.json index 170d2a41279..ffefed62c8c 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "font-awesome": "^4.5.0", "font-awesome-webpack": "0.0.4", "immutable": "^3.7.5", + "moment": "^2.11.1", "react": "^0.14.3", "react-dom": "^0.14.3", "sqlite3": "^3.1.0", From f09a2270a58e56d2ac16ff28ce79f4b1915ec2a0 Mon Sep 17 00:00:00 2001 From: yan Date: Sat, 30 Jan 2016 12:03:40 -0800 Subject: [PATCH 03/23] Blacklist more https everywhere 5.1.2 sites Due to reported brokenness. Auditors: @bbondy --- preload-httpse.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/preload-httpse.js b/preload-httpse.js index 97fa5620813..4f2e8c67ab9 100644 --- a/preload-httpse.js +++ b/preload-httpse.js @@ -5,7 +5,10 @@ var parseString = require('xml2js').parseString // Manually exclude sites that are broken until they are fixed in the next // HTTPS Everywhere release. var exclusions = { - 'Nike.com.xml': 'breaks nikeplus.com' + 'Nike.com.xml': 'breaks nikeplus.com', + 'PJ_Media.xml': 'mixed content on https://pjmedia.com/instapundit/', + 'Slashdot.xml': 'redirect loop on mobile slashdot.org', + 'Vox.com.xml': 'redirect loop on vox.com' } // Preload mapping of HTTPS Everywhere hosts to ruleset IDs and convert From da0882b802b865547dcbc9f094a75349480950c1 Mon Sep 17 00:00:00 2001 From: yan Date: Sat, 30 Jan 2016 12:06:01 -0800 Subject: [PATCH 04/23] Fix https everywhere URL canonicalization The host already contains a trailing slash, so no need to add another one. Auditors: @bbondy --- app/httpsEverywhere.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/httpsEverywhere.js b/app/httpsEverywhere.js index a0db3e52ad7..5dfa98962e2 100644 --- a/app/httpsEverywhere.js +++ b/app/httpsEverywhere.js @@ -232,7 +232,7 @@ function onBeforeRedirect (details) { */ function canonicalizeUrl (url) { var parsed = urlParse(url) - return [parsed.host, parsed.pathname].join('/') + return [parsed.host, parsed.pathname].join('') } /** From 1e236553a5dff2b330ca0eb6c6954fb0862d778a Mon Sep 17 00:00:00 2001 From: yan Date: Sat, 30 Jan 2016 12:35:21 -0800 Subject: [PATCH 05/23] Fix HTTPS Everywhere redirect blacklisting redirectBlacklist is an array, not an object. Auditors: @bbondy --- app/httpsEverywhere.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/httpsEverywhere.js b/app/httpsEverywhere.js index 5dfa98962e2..8f9d066a5e3 100644 --- a/app/httpsEverywhere.js +++ b/app/httpsEverywhere.js @@ -191,8 +191,9 @@ function onBeforeHTTPRequest (details, cb) { return } - if (canonicalizeUrl(details.url) in redirectBlacklist) { + if (redirectBlacklist.includes(canonicalizeUrl(details.url))) { // Don't try to rewrite this request, it'll probably just redirect again. + console.log('https everywhere ignoring blacklisted url', details.url) cb({}) } else { getRewrittenUrl(details.url, (url) => { From fe282dae7d00c992a56a237e645796d1fc5a2118 Mon Sep 17 00:00:00 2001 From: yan Date: Sat, 30 Jan 2016 13:44:17 -0800 Subject: [PATCH 06/23] Revert "Add left/right arrow navigation shortcuts" This reverts commit 8ac6ff7670ed1217041eab532a2818f8e95039a1. --- app/localShortcuts.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/localShortcuts.js b/app/localShortcuts.js index 97aa1eafd3d..e06cf8314a1 100644 --- a/app/localShortcuts.js +++ b/app/localShortcuts.js @@ -15,8 +15,6 @@ module.exports.register = (win) => { const simpleWebContentEvents = [ ['CmdOrCtrl+Shift+]', messages.SHORTCUT_NEXT_TAB], ['CmdOrCtrl+Shift+[', messages.SHORTCUT_PREV_TAB], - ['CmdOrCtrl+Right', messages.SHORTCUT_ACTIVE_FRAME_FORWARD], - ['CmdOrCtrl+Left', messages.SHORTCUT_ACTIVE_FRAME_BACK], ['CmdOrCtrl+9', messages.SHORTCUT_SET_ACTIVE_FRAME_TO_LAST] ] From 735a60a7969a0595e9e3c467be98ab369cba3172 Mon Sep 17 00:00:00 2001 From: yan Date: Sat, 30 Jan 2016 14:10:31 -0800 Subject: [PATCH 07/23] map cmd+[left,right] to navigation on non-editable elements Fix #378. TODO: map ctrl+[left, right] on Windows. Auditors: @bbondy --- app/content/webviewPreload.js | 41 ++++++++++++++++++++++++++++++----- js/constants/keyCodes.js | 7 +++++- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/app/content/webviewPreload.js b/app/content/webviewPreload.js index 677eec6188d..c4221370478 100644 --- a/app/content/webviewPreload.js +++ b/app/content/webviewPreload.js @@ -198,6 +198,18 @@ function hasSelection (node) { return false } +/** + * Whether an element is editable or can be typed into. + * @param {Element} elem + * @return {boolean} + */ +function isEditable (elem) { + // TODO: find other node types that are editable + return (elem.contentEditable === 'true' || + elem.nodeName === 'INPUT' || + elem.nodeName === 'TEXTAREA') +} + document.addEventListener('contextmenu', (e) => { var name = e.target.nodeName.toUpperCase() var nodeProps = { @@ -211,6 +223,7 @@ document.addEventListener('contextmenu', (e) => { }, false) var shiftDown = false +var cmdDown = false document.onkeydown = (e) => { switch (e.keyCode) { case KeyCodes.ESC: @@ -219,17 +232,29 @@ document.onkeydown = (e) => { break case KeyCodes.BACKSPACE: const msg = shiftDown ? messages.GO_FORWARD : messages.GO_BACK - const elem = document.activeElement - if (elem.contentEditable !== 'true' && - elem.nodeName !== 'INPUT' && - elem.nodeName !== 'TEXTAREA') { - // TODO: find other node types where this shortcut should be disabled + if (!isEditable(document.activeElement)) { ipc.send(msg) } break case KeyCodes.SHIFT: shiftDown = true break + case KeyCodes.CMD1: + cmdDown = true + break + case KeyCodes.CMD2: + cmdDown = true + break + case KeyCodes.LEFT: + if (cmdDown && !isEditable(document.activeElement)) { + ipc.send(messages.GO_BACK) + } + break + case KeyCodes.RIGHT: + if (cmdDown && !isEditable(document.activeElement)) { + ipc.send(messages.GO_FORWARD) + } + break } } document.onkeyup = (e) => { @@ -237,6 +262,12 @@ document.onkeyup = (e) => { case KeyCodes.SHIFT: shiftDown = false break + case KeyCodes.CMD1: + cmdDown = false + break + case KeyCodes.CMD2: + cmdDown = false + break } } diff --git a/js/constants/keyCodes.js b/js/constants/keyCodes.js index 7ba94801b53..7b80ceeaedc 100644 --- a/js/constants/keyCodes.js +++ b/js/constants/keyCodes.js @@ -8,7 +8,12 @@ const KeyCodes = { UP: 38, DOWN: 40, SHIFT: 16, - BACKSPACE: 8 + BACKSPACE: 8, + CTRL: 17, + CMD1: 91, + CMD2: 93, + LEFT: 37, + RIGHT: 39 } module.exports = KeyCodes From bdb5fdb84e00f3b67384a9c7d6641b1c12b431f4 Mon Sep 17 00:00:00 2001 From: yan Date: Sat, 30 Jan 2016 15:21:21 -0800 Subject: [PATCH 08/23] Only register cmd+left,right nav shortcut on OS X Auditors: @bbondy --- app/content/webviewPreload.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/content/webviewPreload.js b/app/content/webviewPreload.js index c4221370478..6645c373156 100644 --- a/app/content/webviewPreload.js +++ b/app/content/webviewPreload.js @@ -210,6 +210,15 @@ function isEditable (elem) { elem.nodeName === 'TEXTAREA') } +/** + * Whether we are on OS X + * @return {boolean} + */ +function isPlatformOSX () { + // TODO: navigator.platform is getting deprecated + return window.navigator.platform.includes('Mac') +} + document.addEventListener('contextmenu', (e) => { var name = e.target.nodeName.toUpperCase() var nodeProps = { @@ -240,13 +249,11 @@ document.onkeydown = (e) => { shiftDown = true break case KeyCodes.CMD1: - cmdDown = true - break case KeyCodes.CMD2: cmdDown = true break case KeyCodes.LEFT: - if (cmdDown && !isEditable(document.activeElement)) { + if (cmdDown && !isEditable(document.activeElement) && isPlatformOSX()) { ipc.send(messages.GO_BACK) } break @@ -263,8 +270,6 @@ document.onkeyup = (e) => { shiftDown = false break case KeyCodes.CMD1: - cmdDown = false - break case KeyCodes.CMD2: cmdDown = false break From cab14e9a487640b4f19c5dc4354f11b9bed1c58a Mon Sep 17 00:00:00 2001 From: yan Date: Sat, 30 Jan 2016 15:30:13 -0800 Subject: [PATCH 09/23] OS X-only navigation on Cmd-Left also Auditors: @bbondy --- app/content/webviewPreload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/content/webviewPreload.js b/app/content/webviewPreload.js index 6645c373156..c8003cb411a 100644 --- a/app/content/webviewPreload.js +++ b/app/content/webviewPreload.js @@ -258,7 +258,7 @@ document.onkeydown = (e) => { } break case KeyCodes.RIGHT: - if (cmdDown && !isEditable(document.activeElement)) { + if (cmdDown && !isEditable(document.activeElement) && isPlatformOSX()) { ipc.send(messages.GO_FORWARD) } break From 3dd62cdb2b8ce4f798293b5225e32e3d6ff3a270 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Sat, 30 Jan 2016 19:07:42 -0500 Subject: [PATCH 10/23] Initial window size to workspace size Fix #477 Reviewers: @bridiver --- js/stores/appStore.js | 4 ++-- test/lib/brave.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/js/stores/appStore.js b/js/stores/appStore.js index 91459cb0f10..39efc8a2701 100644 --- a/js/stores/appStore.js +++ b/js/stores/appStore.js @@ -160,8 +160,8 @@ function setDefaultWindowSize () { const screen = electron.screen const primaryDisplay = screen.getPrimaryDisplay() if (!appState.get('defaultWindowWidth') && !appState.get('defaultWindowHeight')) { - appState = appState.set('defaultWindowWidth', Math.floor(primaryDisplay.bounds.width / 2)) - appState = appState.set('defaultWindowHeight', Math.floor(primaryDisplay.bounds.height / 2)) + appState = appState.set('defaultWindowWidth', primaryDisplay.workAreaSize.width) + appState = appState.set('defaultWindowHeight', primaryDisplay.workAreaSize.height) } } diff --git a/test/lib/brave.js b/test/lib/brave.js index e926cc515e5..e62bdb2cb57 100644 --- a/test/lib/brave.js +++ b/test/lib/brave.js @@ -109,7 +109,7 @@ var exports = { return this.execute(function () { let screen = require('electron').screen let primaryDisplay = screen.getPrimaryDisplay() - return Math.floor(primaryDisplay.bounds.height / 2) + return primaryDisplay.workAreaSize.height }).then((response) => response.value) }) @@ -117,7 +117,7 @@ var exports = { return this.execute(function () { let screen = require('electron').screen let primaryDisplay = screen.getPrimaryDisplay() - return Math.floor(primaryDisplay.bounds.width / 2) + return primaryDisplay.workAreaSize.width }).then((response) => response.value) }) From 55e48e7a335e970e514091d9db62f4744894de06 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Sat, 30 Jan 2016 21:34:05 -0500 Subject: [PATCH 11/23] Add clean https-e data command Auditors: @diracdeltas --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index fd62146ba83..cc950fd55b4 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "clean-session-store": "rm -f ~/Library/Application\\ Support/Brave/session-store-*", "clean-adblock-data": "rm -f ~/Library/Application\\ Support/Brave/ABPFilterParserData.dat", "clean-tp-data": "rm -f ~/Library/Application\\ Support/Brave/TrackingProtection.dat", + "clean-httpse-data": "rm -f ~/Library/Application\\ Support/Brave/httpse-targets.json ~/Library/Application\\ Support/Brave/rulesets.sqlite*", "postinstall": "node ./tools/rebuildNativeModules.js&&webpack", "test": "NODE_ENV=test mocha --compilers js:babel-register --recursive $(find test -name '*Test.js')" }, From 95cddf68d868b9a756cac5eb8d8dd9236e3166d3 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Sun, 31 Jan 2016 00:02:02 -0500 Subject: [PATCH 12/23] Fix failing tests Auditors: @bridiver --- test/lib/brave.js | 12 ++++++++++++ test/navigationBarTest.js | 26 +++++++++----------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/test/lib/brave.js b/test/lib/brave.js index e62bdb2cb57..e7ab8915e7a 100644 --- a/test/lib/brave.js +++ b/test/lib/brave.js @@ -185,6 +185,18 @@ var exports = { require('electron').ipcRenderer.emit('ATOM_SHELL_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-' + internal.viewInstanceId, ...params) }, frameKey, eventName, ...params).then((response) => response.value) }) + + this.app.client.addCommand('waitForElementFocus', function (selector) { + let activeElement + return this.waitUntil(function () { + return this.elementActive() + .then(function (el) { + activeElement = el + return this.element(selector) + }) + .then(queryElement => queryElement.value.ELEMENT === activeElement.value.ELEMENT) + }) + }) }, startApp: function () { diff --git a/test/navigationBarTest.js b/test/navigationBarTest.js index 83a1181bc37..eacfebb4c19 100644 --- a/test/navigationBarTest.js +++ b/test/navigationBarTest.js @@ -18,9 +18,7 @@ describe('urlbar', function () { .ipcSend('shortcut-new-frame') // wait for correct urlInput based on frameKey .waitForVisible('div[id="navigator"][data-frame-key="' + frameKey + '"] ' + urlInput) - .waitUntil(function () { - return this.getAttribute(':focus', 'id').then(value => value === 'urlInput') - }) + .waitForElementFocus(urlInput) } function blur (client) { @@ -31,12 +29,6 @@ describe('urlbar', function () { }) } - function hasFocus (client) { - return client.waitUntil(function () { - return this.getAttribute(':focus', 'id').then(function (value) { return value === 'urlInput' }) - }) - } - function defaultUrlInputValue (client) { return client.waitUntil(function () { return this.getAttribute(urlInput, 'value').then(value => value === '') @@ -220,7 +212,7 @@ describe('urlbar', function () { }) it('has focus', function *() { - yield hasFocus(this.app.client) + yield this.app.client.waitForElementFocus(urlInput) }) it('selects the text', function *() { @@ -228,7 +220,7 @@ describe('urlbar', function () { }) }) - describe('new tab', function () { + describe('new tab from ipc', function () { Brave.beforeAll(this) before(function *() { @@ -242,7 +234,7 @@ describe('urlbar', function () { }) it('has focus', function *() { - yield hasFocus(this.app.client) + yield this.app.client.waitForElementFocus(urlInput) }) }) @@ -302,7 +294,7 @@ describe('urlbar', function () { }) it('has focus', function *() { - yield hasFocus(this.app.client) + yield this.app.client.waitForElementFocus(urlInput) }) it('selects the text', function *() { @@ -321,7 +313,7 @@ describe('urlbar', function () { }) it('has focus', function *() { - yield hasFocus(this.app.client) + yield this.app.client.waitForElementFocus(urlInput) }) it('selects the text', function *() { @@ -426,7 +418,7 @@ describe('urlbar', function () { }) it('has focus', function *() { - yield hasFocus(this.app.client) + yield this.app.client.waitForElementFocus(urlInput) }) it('selects the text', function *() { @@ -449,7 +441,7 @@ describe('urlbar', function () { }) it('has focus', function *() { - yield hasFocus(this.app.client) + yield this.app.client.waitForElementFocus(urlInput) }) it('unselects the text', function *() { @@ -478,7 +470,7 @@ describe('urlbar', function () { }) it('has focus', function *() { - yield hasFocus(this.app.client) + yield this.app.client.waitForElementFocus(urlInput) }) }) }) From 1c8f83cceb4519d8614502d55df3683164b9ef47 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Sun, 31 Jan 2016 01:00:05 -0500 Subject: [PATCH 13/23] Fix devpack reload Auditors: @diracdeltas --- js/stores/appStore.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/stores/appStore.js b/js/stores/appStore.js index 39efc8a2701..3e6a9b6b35b 100644 --- a/js/stores/appStore.js +++ b/js/stores/appStore.js @@ -13,6 +13,7 @@ const LocalShortcuts = require('../../app/localShortcuts') const AppActions = require('../actions/appActions') const firstDefinedValue = require('../lib/functional').firstDefinedValue const Serializer = require('../dispatcher/serializer') +const path = require('path') let appState @@ -212,8 +213,8 @@ const handleAppAction = (action) => { } const whitelistedUrl = process.env.NODE_ENV === 'development' - ? 'file://' + __dirname + '/../../app/index-dev.html?' + queryString - : 'file://' + __dirname + '/../../app/index.html?' + queryString + ? 'file://' + path.resolve(__dirname, '..', '..') + '/app/index-dev.html?' + queryString + : 'file://' + path.resolve(__dirname + '..', '..') + '/app/index.html?' + queryString mainWindow.loadURL(whitelistedUrl) mainWindow.webContents.on('will-navigate', willNavigateHandler.bind(null, whitelistedUrl)) appStore.emitChange() From d98f76391f78ddce63fe2dd643525d54e6acaf6a Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Sun, 31 Jan 2016 01:46:47 -0500 Subject: [PATCH 14/23] Fix Windows taskbar grouping Fix #486 Auditors: @aekeus --- app/index.js | 6 +----- app/windowsInit.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 app/windowsInit.js diff --git a/app/index.js b/app/index.js index 3d49a8c8cee..f6445ec27cf 100644 --- a/app/index.js +++ b/app/index.js @@ -4,12 +4,8 @@ 'use strict' - // windows installation events etc... if (process.platform === 'win32') { - // TODO - register browser as HTTP handler in Windows (maybe need to fork) - if (require('electron-squirrel-startup')) { - process.exit(0) - } + require('./windowsInit') } const Immutable = require('immutable') diff --git a/app/windowsInit.js b/app/windowsInit.js new file mode 100644 index 00000000000..7ff75ffc69a --- /dev/null +++ b/app/windowsInit.js @@ -0,0 +1,19 @@ +/* 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/. */ + +const electron = require('electron') +const app = electron.app +const appUserModelId = 'BraveSoftware.Brave.browser' + + // windows installation events etc... +if (process.platform === 'win32') { + // TODO - register browser as HTTP handler in Windows (maybe need to fork) + if (require('electron-squirrel-startup')) { + process.exit(0) + } +} + +app.on('will-finish-launching', function () { + app.setAppUserModelId(appUserModelId) +}) From 8607d753fbf97fbf7a21b02749ecd625c43c05d0 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Sun, 31 Jan 2016 12:50:09 -0500 Subject: [PATCH 15/23] Fix packaged builds Recently regressed from security bug fix and follow up dev tools fix Auditors: @aekeus --- js/stores/appStore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/stores/appStore.js b/js/stores/appStore.js index 3e6a9b6b35b..851d66b419d 100644 --- a/js/stores/appStore.js +++ b/js/stores/appStore.js @@ -214,7 +214,7 @@ const handleAppAction = (action) => { const whitelistedUrl = process.env.NODE_ENV === 'development' ? 'file://' + path.resolve(__dirname, '..', '..') + '/app/index-dev.html?' + queryString - : 'file://' + path.resolve(__dirname + '..', '..') + '/app/index.html?' + queryString + : 'file://' + path.resolve(__dirname + '..', '..', '..') + '/app/index.html?' + queryString mainWindow.loadURL(whitelistedUrl) mainWindow.webContents.on('will-navigate', willNavigateHandler.bind(null, whitelistedUrl)) appStore.emitChange() From e65b2e505b2cc56865b80fad503678c38deb9c25 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Sun, 31 Jan 2016 14:13:46 -0500 Subject: [PATCH 16/23] Reduce packaging size ~40% Auditors: @aekeus --- tools/buildPackage.js | 7 ++++++- tools/lib/ignoredPaths.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 tools/lib/ignoredPaths.js diff --git a/tools/buildPackage.js b/tools/buildPackage.js index f54b19eba0a..975d949008d 100644 --- a/tools/buildPackage.js +++ b/tools/buildPackage.js @@ -1,5 +1,10 @@ +/* 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/. */ + var VersionInfo = require('./lib/versionInfo') var execute = require('./lib/execute') +const ignoredPaths = require('./lib/ignoredPaths') const isWindows = process.platform === 'win32' const isDarwin = process.platform === 'darwin' @@ -45,7 +50,7 @@ cmds = cmds.concat([ 'npm run checks', 'node ./node_modules/electron-packager/cli.js . Brave' + ' --overwrite' + - ' --ignore="electron-download|electron-rebuild|electron-packager|electron-builder|electron-prebuilt|electron-rebuild|babel$|babel-(?!polyfill|regenerator-runtime)"' + + ' --ignore="' + ignoredPaths.join('|') + '"' + ' --platform=' + process.platform + ' --arch=' + arch + ' --version=' + VersionInfo.electronVersion + diff --git a/tools/lib/ignoredPaths.js b/tools/lib/ignoredPaths.js new file mode 100644 index 00000000000..246549ce71f --- /dev/null +++ b/tools/lib/ignoredPaths.js @@ -0,0 +1,28 @@ +/* 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/. */ + +module.exports = [ + 'test/', + 'tools/', + 'abp-filter-parser-cpp/(node_modules|test|perf|sample|scripts|test|vendor|ABPFilterParserData.dat)', + 'tracking-protection/(node_modules|test|data|scripts|vendor)', + 'sqlite3/(src|deps)', + 'sqlite3/build/Release/(obj|obj.target|.deps)', + 'abp-filter-parser-cpp/build/Release/(obj|obj.target|.deps)', + 'tracking-protection/build/Release/(obj|obj.target|.deps)', + 'nsp/node_modules', + 'electron-installer-squirrel-windows', + 'electron-chromedriver', + 'node-notifier/vendor', + 'node-gyp', + '.brave-gyp', + 'electron-download', + 'electron-rebuild', + 'electron-packager', + 'electron-builder', + 'electron-prebuilt', + 'electron-rebuild', + 'babel$', + 'babel-(?!polyfill|regenerator-runtime)' +] From a707ac4036c45e146c0f89a0b9adc34b84954c2f Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Sun, 31 Jan 2016 17:02:49 -0500 Subject: [PATCH 17/23] Make patitioned tabs another 12.36% less nerdy Fix #497 Auditors: @diracdeltas --- app/locales/en-US/app.l20n | 2 +- js/commonMenu.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/locales/en-US/app.l20n b/app/locales/en-US/app.l20n index 1b1f2432ca0..65b8214d4ce 100644 --- a/app/locales/en-US/app.l20n +++ b/app/locales/en-US/app.l20n @@ -78,7 +78,7 @@ - + diff --git a/js/commonMenu.js b/js/commonMenu.js index fe5dd959983..d3f4f1b1327 100644 --- a/js/commonMenu.js +++ b/js/commonMenu.js @@ -68,7 +68,7 @@ module.exports.newPrivateTabMenuItem = { } module.exports.newPartitionedTabMenuItem = { - label: 'New Partitioned Session', + label: 'New Session Tab', accelerator: 'CmdOrCtrl+Alt+S', click: function (item, focusedWindow) { module.exports.sendToFocusedWindow(focusedWindow, [messages.SHORTCUT_NEW_FRAME, undefined, { isPartitioned: true }]) From b622dad488d4a6e333e48be180ad53d89655b9f1 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Sun, 31 Jan 2016 17:23:49 -0500 Subject: [PATCH 18/23] Add visual identity to session tabs Fix #499 Auditors: @diracdeltas --- app/locales/en-US/app.l20n | 5 ++++- js/components/tab.js | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/locales/en-US/app.l20n b/app/locales/en-US/app.l20n index 65b8214d4ce..d81ebd58f92 100644 --- a/app/locales/en-US/app.l20n +++ b/app/locales/en-US/app.l20n @@ -78,7 +78,10 @@ - + + + diff --git a/js/components/tab.js b/js/components/tab.js index 82d11e2a8ff..de02e83bf81 100644 --- a/js/components/tab.js +++ b/js/components/tab.js @@ -210,6 +210,10 @@ class Tab extends ImmutableComponent { style={activeTabStyle}> { this.props.frameProps.get('isPrivate') ?
: null } + { this.props.frameProps.get('partitionNumber') + ?
: null }
Date: Sun, 31 Jan 2016 20:43:58 -0500 Subject: [PATCH 19/23] Restart on close, and save app data Fix #504. Fix# 165. Auditors: @aekeus --- app/index.js | 19 +++++++++++++++++-- app/sessionStore.js | 19 ++++++++++++++----- app/updater.js | 7 ++++++- js/actions/appActions.js | 2 -- js/components/updateBar.js | 4 +++- js/constants/updateStatus.js | 8 +++++++- js/stores/appStore.js | 5 +++++ 7 files changed, 52 insertions(+), 12 deletions(-) diff --git a/app/index.js b/app/index.js index f6445ec27cf..243b7c18bf0 100644 --- a/app/index.js +++ b/app/index.js @@ -27,6 +27,7 @@ const AdBlock = require('./adBlock') const HttpsEverywhere = require('./httpsEverywhere') const SiteHacks = require('./siteHacks') const CmdLine = require('./cmdLine') +const UpdateStatus = require('../js/constants/updateStatus') let loadAppStatePromise = SessionStore.loadAppState().catch(() => { return SessionStore.defaultAppState() @@ -43,9 +44,23 @@ const saveIfAllCollected = () => { const ignoreCatch = () => {} if (process.env.NODE_ENV !== 'test') { + // If the status is still UPDATE_AVAILABLE then the user wants to quit + // and not restart + if (appState.updates.status === UpdateStatus.UPDATE_AVAILABLE || + appState.updates.status === UpdateStatus.UPDATE_AVAILABLE_DEFERRED) { + appState.updates.status = UpdateStatus.UPDATE_APPLYING_NO_RESTART + } + SessionStore.saveAppState(appState).catch(ignoreCatch).then(() => { sessionStateStoreAttempted = true - app.quit() + // If there's an update to apply, then do it here. + // Otherwise just quit. + if (appState.updates.status === UpdateStatus.UPDATE_APPLYING_NO_RESTART || + appState.updates.status === UpdateStatus.UPDATE_APPLYING_RESTART) { + Updater.quitAndInstall() + } else { + app.quit() + } }) } else { sessionStateStoreAttempted = true @@ -146,7 +161,7 @@ app.on('ready', function () { SiteHacks.init() ipcMain.on(messages.UPDATE_REQUESTED, () => { - Updater.update() + Updater.updateNowRequested() }) // Setup the crash handling diff --git a/app/sessionStore.js b/app/sessionStore.js index 012809ef73a..fecad1c75cf 100644 --- a/app/sessionStore.js +++ b/app/sessionStore.js @@ -14,6 +14,7 @@ const fs = require('fs') const path = require('path') const app = require('app') +const UpdateStatus = require('../js/constants/updateStatus') const sessionStorageVersion = 1 const sessionStorageName = `session-store-${sessionStorageVersion}` const storagePath = path.join(app.getPath('userData'), sessionStorageName) @@ -34,11 +35,6 @@ module.exports.saveAppState = (payload) => { wndPayload.frames = wndPayload.frames.filter(frame => !frame.isPrivate)) } - // Always recalculate the update status - if (payload.updates) { - delete payload.updates.status - } - // payload.frames = payload.frames.filter(frame => !frame.isPrivate) fs.writeFile(storagePath, JSON.stringify(payload), (err) => { if (err) { @@ -159,6 +155,19 @@ module.exports.loadAppState = () => { reject(e) return } + // Always recalculate the update status + if (data.updates) { + const updateStatus = data.updates.status + delete data.updates.status + // The process always restarts after an update so if the state + // indicates that a restart isn't wanted, close right away. + if (updateStatus === UpdateStatus.UPDATE_APPLYING_NO_RESTART) { + module.exports.saveAppState(data) + // Exit immediately without doing the session store saving stuff + // since we want the same state saved except for the update status + app.exit(0) + } + } if (data.perWindowState) { data.perWindowState.forEach(module.exports.cleanSessionData) } diff --git a/app/updater.js b/app/updater.js index 673914e0481..88522b8c52d 100644 --- a/app/updater.js +++ b/app/updater.js @@ -204,8 +204,13 @@ exports.checkForUpdate = (verbose) => { } // The UI indicates that we should update the software -exports.update = () => { +exports.updateNowRequested = () => { debug('update requested in updater') + // App shutdown process will save state and then call autoUpdater.quitAndInstall + AppActions.setUpdateStatus(UpdateStatus.UPDATE_APPLYING_RESTART) +} + +exports.quitAndInstall = () => { autoUpdater.quitAndInstall() } diff --git a/js/actions/appActions.js b/js/actions/appActions.js index 117a1532087..1908b0a490f 100644 --- a/js/actions/appActions.js +++ b/js/actions/appActions.js @@ -44,8 +44,6 @@ const AppActions = { * Dispatches an event to the main process to update the browser */ updateRequested: function () { - // TODO - change to dispatcher - console.log('appActions updateRequested') global.require('electron').ipcRenderer.send(messages.UPDATE_REQUESTED) }, diff --git a/js/components/updateBar.js b/js/components/updateBar.js index 785c458038f..bc36a93140f 100644 --- a/js/components/updateBar.js +++ b/js/components/updateBar.js @@ -157,7 +157,9 @@ class UpdateBar extends ImmutableComponent { let updateStatus = this.props.updates.get('status') if (!updateStatus || !verbose && updateStatus !== UpdateStatus.UPDATE_AVAILABLE || - updateStatus === UpdateStatus.UPDATE_NONE) { + updateStatus === UpdateStatus.UPDATE_NONE || + updateStatus === UpdateStatus.UPDATE_APPLYING_RESTART || + updateStatus === UpdateStatus.UPDATE_APPLYING_NO_RESTART) { return null } diff --git a/js/constants/updateStatus.js b/js/constants/updateStatus.js index 0b75a9dcd11..6f20b320676 100644 --- a/js/constants/updateStatus.js +++ b/js/constants/updateStatus.js @@ -12,7 +12,13 @@ const updateStatus = { UPDATE_AVAILABLE_DEFERRED: _, UPDATE_DOWNLOADING: _, UPDATE_NOT_AVAILABLE: _, - UPDATE_ERROR: _ + UPDATE_ERROR: _, + // Used only when closing from the update UI. + // indicate the app should close and allow restart. + // A restart always happens after an update but will + // re-close unless this is set. + UPDATE_APPLYING_RESTART: _, + UPDATE_APPLYING_NO_RESTART: _ } module.exports = mapValuesByKeys(updateStatus) diff --git a/js/stores/appStore.js b/js/stores/appStore.js index 851d66b419d..9c2f3b14e89 100644 --- a/js/stores/appStore.js +++ b/js/stores/appStore.js @@ -6,8 +6,10 @@ const AppConstants = require('../constants/appConstants') const SiteUtil = require('../state/siteUtil') const electron = require('electron') +const app = electron.app const ipcMain = electron.ipcMain const messages = require('../constants/messages') +const UpdateStatus = require('../constants/updateStatus') const BrowserWindow = electron.BrowserWindow const LocalShortcuts = require('../../app/localShortcuts') const AppActions = require('../actions/appActions') @@ -261,6 +263,9 @@ const handleAppAction = (action) => { if (action.metadata !== undefined) { appState = appState.setIn(['updates', 'metadata'], action.metadata) } + if (action.status === UpdateStatus.UPDATE_APPLYING_RESTART) { + app.quit() + } appStore.emitChange() break case AppConstants.APP_SET_RESOURCE_ENABLED: From c17ac1469ac6192ef1886dab3b9f01409ee1b0f0 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Sun, 31 Jan 2016 23:31:59 -0500 Subject: [PATCH 20/23] Update metadata check errors should not show checking forever Fix #507 Audiotrs: @aekeus --- app/updater.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/updater.js b/app/updater.js index 88522b8c52d..712335c5119 100644 --- a/app/updater.js +++ b/app/updater.js @@ -161,7 +161,7 @@ var requestVersionInfo = (done) => { done(null, body) } else { // Network error or mis-configuration - debug(err.toString()) + autoUpdater.emit('error', err) } }) } From 2746bfee83528cd8485a4f8ec86ff887939817e6 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Mon, 1 Feb 2016 00:30:06 -0500 Subject: [PATCH 21/23] 0.7.12 release notes --- CHANGELOG.md | 11 +++++++++++ package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8702b55a41c..0e1cc4a57e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## [0.7.12](https://github.com/brave/browser-laptop/releases/v0.7.12dev) +- Various crash fixes and window.opener fixes. +- Fix for state saving when an update is applied. +- Fix for update error handling when on a flaky connection. +- Visual indicator for Session Tabs added. +- Installers and updates reduced by ~40%. +- Windows taskbar grouping fix. +- Initial window size is now bigger. +- Various keyboard shortcuts added. +- HTTPS Everywhere fixes. + ## [0.7.11](https://github.com/brave/browser-laptop/releases/v0.7.11dev) - Security fix (Severity: High): Prevent BrowserWindow from navigating to remote content ([#445](https://github.com/brave/browser-laptop/issues/445)). Impact: if the user is tricked into dragging and dropping a malicious link outside of the tab content area, the linked site is loaded outside the webview sandbox and can compromise the user's system. diff --git a/package.json b/package.json index cc950fd55b4..814a99b22eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "brave", - "version": "0.7.11", + "version": "0.7.12", "description": "Brave laptop and desktop browser", "main": "./app/index.js", "scripts": { From dad1177b9962aae2edb72f39b96ed7ebb1bd4ac7 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Mon, 1 Feb 2016 07:49:11 -0500 Subject: [PATCH 22/23] Move check for update to proper menus Fix #455 Auditors: @diracdeltas --- app/menu.js | 15 +++++---------- js/commonMenu.js | 10 ++++++++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/menu.js b/app/menu.js index fb90f5dcbfc..cc650a95473 100644 --- a/app/menu.js +++ b/app/menu.js @@ -3,7 +3,6 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ const electron = require('electron') -const BrowserWindow = electron.BrowserWindow const AppConfig = require('../js/constants/appConfig') const Menu = require('menu') const messages = require('../js/constants/messages') @@ -69,15 +68,6 @@ const init = (args) => { } const fileMenu = [ - { - label: 'Check for updates ...', - click: function (item, focusedWindow) { - if (BrowserWindow.getAllWindows().length === 0) { - AppActions.newWindow() - } - process.emit(messages.CHECK_FOR_UPDATE) - } - }, // Note: we are keeping this here for testing. Calling process.crash() from the inspector does not create a crash report. // { // label: 'Crash!!!!!', @@ -200,6 +190,9 @@ const init = (args) => { if (isWindows) { fileMenu.push(CommonMenu.separatorMenuItem) fileMenu.push(CommonMenu.quitMenuItem) + helpMenu.push(CommonMenu.separatorMenuItem) + helpMenu.push(CommonMenu.checkForUpdateMenuItem) + helpMenu.push(CommonMenu.separatorMenuItem) helpMenu.push(aboutBraveMenuItem) } @@ -514,6 +507,8 @@ const init = (args) => { submenu: [ aboutBraveMenuItem, CommonMenu.separatorMenuItem, + CommonMenu.checkForUpdateMenuItem, + CommonMenu.separatorMenuItem, preferencesMenuItem, CommonMenu.separatorMenuItem, { diff --git a/js/commonMenu.js b/js/commonMenu.js index d3f4f1b1327..6af20750ec9 100644 --- a/js/commonMenu.js +++ b/js/commonMenu.js @@ -101,6 +101,16 @@ module.exports.findOnPageMenuItem = { } } +module.exports.checkForUpdateMenuItem = { + label: 'Check for updates ...', + click: function (item, focusedWindow) { + if (electron.BrowserWindow.getAllWindows().length === 0) { + AppActions.newWindow() + } + process.emit(messages.CHECK_FOR_UPDATE) + } +} + module.exports.buildBraveryMenu = function (settings, init) { const replaceAds = settings[adInsertion] || false const blockAds = settings[adblock] || false From 22a6ea3bc70baffd80f337dccd1b3fe69fea48ed Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Mon, 1 Feb 2016 10:42:48 -0500 Subject: [PATCH 23/23] Trim URLbar input Fix #519 Auditors: @diracdeltas --- js/actions/windowActions.js | 2 ++ js/lib/appUrlUtil.js | 1 + 2 files changed, 3 insertions(+) diff --git a/js/actions/windowActions.js b/js/actions/windowActions.js index 3b59ec5280d..efdd073eade 100644 --- a/js/actions/windowActions.js +++ b/js/actions/windowActions.js @@ -42,6 +42,7 @@ const WindowActions = { * @param {string} location - The URL of the page to load */ loadUrl: function (activeFrame, location) { + location = location.trim() let newFrame = false if (activeFrame.get('isPinned')) { try { @@ -82,6 +83,7 @@ const WindowActions = { * it is active the URL text will also be changed. */ setLocation: function (location, key) { + location = location.trim() if (UrlUtil.isURL(location)) { location = UrlUtil.getUrlFromInput(location) } diff --git a/js/lib/appUrlUtil.js b/js/lib/appUrlUtil.js index ac0fef1178c..6b4a160d85c 100644 --- a/js/lib/appUrlUtil.js +++ b/js/lib/appUrlUtil.js @@ -83,5 +83,6 @@ export function isPrivilegedUrl (input) { * @param {string} input */ export function isUrl (input) { + input = input.trim() return (UrlUtil.isURL(input) && !input.includes(' ')) }