Remove nodeIntegration warning of webview in BrowserWindow
nodeintegration attribute is ignored in React because it's unknown. So fortunately the integration is not working. New 'will-attach-webview' allows us to set nodeIntegration = false.
This commit is contained in:
@@ -233,7 +233,6 @@ const MattermostView = React.createClass({
|
|||||||
preload={preloadJS}
|
preload={preloadJS}
|
||||||
src={this.props.src}
|
src={this.props.src}
|
||||||
ref='webview'
|
ref='webview'
|
||||||
nodeintegration='false'
|
|
||||||
/>
|
/>
|
||||||
</div>);
|
</div>);
|
||||||
}
|
}
|
||||||
|
@@ -466,6 +466,10 @@ app.on('ready', () => {
|
|||||||
console.log('The application has crashed.');
|
console.log('The application has crashed.');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mainWindow.webContents.on('will-attach-webview', (event, webPreferences) => {
|
||||||
|
webPreferences.nodeIntegration = false;
|
||||||
|
});
|
||||||
|
|
||||||
mainWindow.on('unresponsive', () => {
|
mainWindow.on('unresponsive', () => {
|
||||||
console.log('The application has become unresponsive.');
|
console.log('The application has become unresponsive.');
|
||||||
});
|
});
|
||||||
|
@@ -51,17 +51,18 @@ describe('application', function desc() {
|
|||||||
|
|
||||||
it('should NOT be able to call Node.js API in webview', () => {
|
it('should NOT be able to call Node.js API in webview', () => {
|
||||||
env.addClientCommands(this.app.client);
|
env.addClientCommands(this.app.client);
|
||||||
|
|
||||||
|
// webview is handled as a window by chromedriver.
|
||||||
return this.app.client.
|
return this.app.client.
|
||||||
|
windowByIndex(1).isNodeEnabled().should.eventually.be.false.
|
||||||
|
windowByIndex(2).isNodeEnabled().should.eventually.be.false.
|
||||||
|
windowByIndex(0).
|
||||||
getAttribute('webview', 'nodeintegration').then((nodeintegration) => {
|
getAttribute('webview', 'nodeintegration').then((nodeintegration) => {
|
||||||
// nodeintegration is an array of string
|
// nodeintegration is an array of string
|
||||||
nodeintegration.forEach((n) => {
|
nodeintegration.forEach((n) => {
|
||||||
n.should.equal('false');
|
n.should.equal('false');
|
||||||
});
|
});
|
||||||
}).
|
});
|
||||||
|
|
||||||
// webview is handled as a window by chromedriver.
|
|
||||||
windowByIndex(1).isNodeEnabled().should.eventually.be.false.
|
|
||||||
windowByIndex(2).isNodeEnabled().should.eventually.be.false;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should NOT be able to call Node.js API in a new window', () => {
|
it('should NOT be able to call Node.js API in a new window', () => {
|
||||||
|
Reference in New Issue
Block a user