From f08db8c72b722558002324a0491149c4fc614f99 Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Sat, 18 Mar 2017 21:25:46 +0900 Subject: [PATCH] Remove "Display secure content only" option allowDisplayingInsecureContent is removed in Electron 1.6. And it's no longer necessary to show http contents in https server. --- CHANGELOG.md | 1 + src/browser/components/MainPage.jsx | 2 -- src/browser/components/MattermostView.jsx | 11 ------ src/browser/components/SettingsPage.jsx | 22 ------------ src/browser/index.jsx | 1 - src/common/settings.js | 1 - test/specs/browser/settings_test.js | 43 ----------------------- 7 files changed, 1 insertion(+), 80 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5df182d7..1e3d4b48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ from the final changelog of the release. Release date: TBD ### Improvements +- Removed "Display secure content only" option it's no longer necessary. ### Bug Fixes diff --git a/src/browser/components/MainPage.jsx b/src/browser/components/MainPage.jsx index e6b7658b..672ae5f5 100644 --- a/src/browser/components/MainPage.jsx +++ b/src/browser/components/MainPage.jsx @@ -36,7 +36,6 @@ const styles = { const MainPage = React.createClass({ propTypes: { - disablewebsecurity: React.PropTypes.bool.isRequired, onUnreadCountChange: React.PropTypes.func.isRequired, teams: React.PropTypes.array.isRequired, onTeamConfigChange: React.PropTypes.func.isRequired, @@ -291,7 +290,6 @@ const MainPage = React.createClass({ style={self.visibleStyle(isActive)} src={team.url} name={team.name} - disablewebsecurity={this.props.disablewebsecurity} onTargetURLChange={self.handleTargetURLChange} onUnreadCountChange={handleUnreadCountChange} onNotificationClick={handleNotificationClick} diff --git a/src/browser/components/MattermostView.jsx b/src/browser/components/MattermostView.jsx index f08c05ba..1df90318 100644 --- a/src/browser/components/MattermostView.jsx +++ b/src/browser/components/MattermostView.jsx @@ -12,7 +12,6 @@ const preloadJS = `file://${remote.app.getAppPath()}/browser/webview/mattermost_ const MattermostView = React.createClass({ propTypes: { - disablewebsecurity: React.PropTypes.bool, name: React.PropTypes.string, id: React.PropTypes.string, onTargetURLChange: React.PropTypes.func, @@ -38,12 +37,6 @@ const MattermostView = React.createClass({ var self = this; var webview = findDOMNode(this.refs.webview); - // This option allows insecure content, when set to true it is possible to - // load content via HTTP while the mattermost server serves HTTPS - if (this.props.disablewebsecurity === true) { - webview.setAttribute('webpreferences', 'allowDisplayingInsecureContent'); - } - webview.addEventListener('did-fail-load', (e) => { console.log(self.props.name, 'webview did-fail-load', e); if (e.errorCode === -3) { // An operation was aborted (due to user action). @@ -218,10 +211,6 @@ const MattermostView = React.createClass({ errorInfo={this.state.errorInfo} />) : null; - // 'disablewebsecurity' is necessary to display external images. - // However, it allows also CSS/JavaScript. - // So webview should use 'allowDisplayingInsecureContent' as same as BrowserWindow. - // Need to keep webview mounted when failed to load. return (
diff --git a/src/browser/components/SettingsPage.jsx b/src/browser/components/SettingsPage.jsx index dc9ec98a..895c9a1f 100644 --- a/src/browser/components/SettingsPage.jsx +++ b/src/browser/components/SettingsPage.jsx @@ -107,7 +107,6 @@ const SettingsPage = React.createClass({ teams: this.state.teams, showTrayIcon: this.state.showTrayIcon, trayIconTheme: this.state.trayIconTheme, - disablewebsecurity: this.state.disablewebsecurity, version: settings.version, minimizeToTray: this.state.minimizeToTray, notifications: { @@ -151,12 +150,6 @@ const SettingsPage = React.createClass({ handleCancel() { backToIndex(); }, - handleChangeDisableWebSecurity() { - this.setState({ - disablewebsecurity: this.refs.disablewebsecurity.props.checked - }); - setImmediate(this.startSaveConfig); - }, handleChangeShowTrayIcon() { var shouldShowTrayIcon = !this.refs.showTrayIcon.props.checked; this.setState({ @@ -272,21 +265,6 @@ const SettingsPage = React.createClass({ ); } - options.push( - {'Display secure content only'} - - {'If enabled, the app only displays secure (HTTPS/SSL) content.'} - {' '} - {'If disabled, the app displays secure and non-secure (HTTP) content such as images.'} - - ); - if (process.platform === 'darwin' || process.platform === 'win32') { const TASKBAR = process.platform === 'win32' ? 'taskbar' : 'Dock'; options.push( diff --git a/src/browser/index.jsx b/src/browser/index.jsx index 64c11d4b..43e7aab1 100644 --- a/src/browser/index.jsx +++ b/src/browser/index.jsx @@ -95,7 +95,6 @@ const initialIndex = parsedURL.query.index ? parseInt(parsedURL.query.index, 10) ReactDOM.render( { - [true, false].forEach((v) => { - it(`should be saved and loaded: ${v}`, () => { - const webPreferences = v ? '' : 'allowDisplayingInsecureContent'; - env.addClientCommands(this.app.client); - - return this.app.client. - loadSettingsPage(). - scroll('#inputDisableWebSecurity'). - isSelected('#inputDisableWebSecurity').then((isSelected) => { - if (isSelected !== v) { - return this.app.client.click('#inputDisableWebSecurity'); - } - return true; - }). - pause(600). - click('#btnClose'). - pause(1000).then(() => { - const savedConfig = JSON.parse(fs.readFileSync(env.configFilePath, 'utf8')); - savedConfig.disablewebsecurity.should.equal(!v); - }). - getAttribute('.mattermostView', 'webpreferences').then((disablewebsecurity) => { // confirm actual behavior - // disablewebsecurity is an array of String - disablewebsecurity.forEach((d) => { - d.should.equal(webPreferences); - }); - }).then(() => { - return this.app.restart(); - }).then(() => { - env.addClientCommands(this.app.client); - return this.app.client. // confirm actual behavior - getAttribute('.mattermostView', 'webpreferences').then((disablewebsecurity) => { // disablewebsecurity is an array of String - disablewebsecurity.forEach((d) => { - d.should.equal(webPreferences); - }); - }). - loadSettingsPage(). - isSelected('#inputDisableWebSecurity').should.eventually.equal(v); - }); - }); - }); - }); - describe('Start app on login', () => { it('should appear on win32 or linux', () => { const expected = (process.platform === 'win32' || process.platform === 'linux');