build: enable JS semicolons (#22783)

This commit is contained in:
Samuel Attard 2020-03-20 13:28:31 -07:00 committed by GitHub
parent 24e21467b9
commit 5d657dece4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
354 changed files with 21512 additions and 21510 deletions

View file

@ -1,22 +1,22 @@
import { expect } from 'chai'
import * as path from 'path'
import { expect } from 'chai';
import * as path from 'path';
import { ipcMain, BrowserWindow, WebPreferences, app } from 'electron'
import { closeWindow } from './window-helpers'
import { ipcMain, BrowserWindow, WebPreferences, app } from 'electron';
import { closeWindow } from './window-helpers';
describe('BrowserWindow with affinity module', () => {
const fixtures = path.resolve(__dirname, '..', 'spec', 'fixtures')
const myAffinityName = 'myAffinity'
const myAffinityNameUpper = 'MYAFFINITY'
const anotherAffinityName = 'anotherAffinity'
const fixtures = path.resolve(__dirname, '..', 'spec', 'fixtures');
const myAffinityName = 'myAffinity';
const myAffinityNameUpper = 'MYAFFINITY';
const anotherAffinityName = 'anotherAffinity';
before(() => {
app.allowRendererProcessReuse = false
})
app.allowRendererProcessReuse = false;
});
after(() => {
app.allowRendererProcessReuse = true
})
app.allowRendererProcessReuse = true;
});
async function createWindowWithWebPrefs (webPrefs: WebPreferences) {
const w = new BrowserWindow({
@ -24,83 +24,83 @@ describe('BrowserWindow with affinity module', () => {
width: 400,
height: 400,
webPreferences: webPrefs || {}
})
await w.loadFile(path.join(fixtures, 'api', 'blank.html'))
return w
});
await w.loadFile(path.join(fixtures, 'api', 'blank.html'));
return w;
}
function testAffinityProcessIds (name: string, webPreferences: WebPreferences = {}) {
describe(name, () => {
let mAffinityWindow: BrowserWindow
let mAffinityWindow: BrowserWindow;
before(async () => {
mAffinityWindow = await createWindowWithWebPrefs({ affinity: myAffinityName, ...webPreferences })
})
mAffinityWindow = await createWindowWithWebPrefs({ affinity: myAffinityName, ...webPreferences });
});
after(async () => {
await closeWindow(mAffinityWindow, { assertNotWindows: false })
mAffinityWindow = null as unknown as BrowserWindow
})
await closeWindow(mAffinityWindow, { assertNotWindows: false });
mAffinityWindow = null as unknown as BrowserWindow;
});
it('should have a different process id than a default window', async () => {
const w = await createWindowWithWebPrefs({ ...webPreferences })
const affinityID = mAffinityWindow.webContents.getOSProcessId()
const wcID = w.webContents.getOSProcessId()
const w = await createWindowWithWebPrefs({ ...webPreferences });
const affinityID = mAffinityWindow.webContents.getOSProcessId();
const wcID = w.webContents.getOSProcessId();
expect(affinityID).to.not.equal(wcID, 'Should have different OS process IDs')
await closeWindow(w, { assertNotWindows: false })
})
expect(affinityID).to.not.equal(wcID, 'Should have different OS process IDs');
await closeWindow(w, { assertNotWindows: false });
});
it(`should have a different process id than a window with a different affinity '${anotherAffinityName}'`, async () => {
const w = await createWindowWithWebPrefs({ affinity: anotherAffinityName, ...webPreferences })
const affinityID = mAffinityWindow.webContents.getOSProcessId()
const wcID = w.webContents.getOSProcessId()
const w = await createWindowWithWebPrefs({ affinity: anotherAffinityName, ...webPreferences });
const affinityID = mAffinityWindow.webContents.getOSProcessId();
const wcID = w.webContents.getOSProcessId();
expect(affinityID).to.not.equal(wcID, 'Should have different OS process IDs')
await closeWindow(w, { assertNotWindows: false })
})
expect(affinityID).to.not.equal(wcID, 'Should have different OS process IDs');
await closeWindow(w, { assertNotWindows: false });
});
it(`should have the same OS process id than a window with the same affinity '${myAffinityName}'`, async () => {
const w = await createWindowWithWebPrefs({ affinity: myAffinityName, ...webPreferences })
const affinityID = mAffinityWindow.webContents.getOSProcessId()
const wcID = w.webContents.getOSProcessId()
const w = await createWindowWithWebPrefs({ affinity: myAffinityName, ...webPreferences });
const affinityID = mAffinityWindow.webContents.getOSProcessId();
const wcID = w.webContents.getOSProcessId();
expect(affinityID).to.equal(wcID, 'Should have the same OS process ID')
await closeWindow(w, { assertNotWindows: false })
})
expect(affinityID).to.equal(wcID, 'Should have the same OS process ID');
await closeWindow(w, { assertNotWindows: false });
});
it(`should have the same OS process id than a window with an equivalent affinity '${myAffinityNameUpper}' (case insensitive)`, async () => {
const w = await createWindowWithWebPrefs({ affinity: myAffinityNameUpper, ...webPreferences })
const affinityID = mAffinityWindow.webContents.getOSProcessId()
const wcID = w.webContents.getOSProcessId()
const w = await createWindowWithWebPrefs({ affinity: myAffinityNameUpper, ...webPreferences });
const affinityID = mAffinityWindow.webContents.getOSProcessId();
const wcID = w.webContents.getOSProcessId();
expect(affinityID).to.equal(wcID, 'Should have the same OS process ID')
await closeWindow(w, { assertNotWindows: false })
})
})
expect(affinityID).to.equal(wcID, 'Should have the same OS process ID');
await closeWindow(w, { assertNotWindows: false });
});
});
}
testAffinityProcessIds(`BrowserWindow with an affinity '${myAffinityName}'`)
testAffinityProcessIds(`BrowserWindow with an affinity '${myAffinityName}' and sandbox enabled`, { sandbox: true })
testAffinityProcessIds(`BrowserWindow with an affinity '${myAffinityName}' and nativeWindowOpen enabled`, { nativeWindowOpen: true })
testAffinityProcessIds(`BrowserWindow with an affinity '${myAffinityName}'`);
testAffinityProcessIds(`BrowserWindow with an affinity '${myAffinityName}' and sandbox enabled`, { sandbox: true });
testAffinityProcessIds(`BrowserWindow with an affinity '${myAffinityName}' and nativeWindowOpen enabled`, { nativeWindowOpen: true });
describe('BrowserWindow with an affinity : nodeIntegration=false', () => {
const preload = path.join(fixtures, 'module', 'send-later.js')
const affinityWithNodeTrue = 'affinityWithNodeTrue'
const affinityWithNodeFalse = 'affinityWithNodeFalse'
const preload = path.join(fixtures, 'module', 'send-later.js');
const affinityWithNodeTrue = 'affinityWithNodeTrue';
const affinityWithNodeFalse = 'affinityWithNodeFalse';
function testNodeIntegration (present: boolean) {
return new Promise<void>((resolve) => {
ipcMain.once('answer', (event, typeofProcess, typeofBuffer) => {
if (present) {
expect(typeofProcess).to.not.equal('undefined')
expect(typeofBuffer).to.not.equal('undefined')
expect(typeofProcess).to.not.equal('undefined');
expect(typeofBuffer).to.not.equal('undefined');
} else {
expect(typeofProcess).to.equal('undefined')
expect(typeofBuffer).to.equal('undefined')
expect(typeofProcess).to.equal('undefined');
expect(typeofBuffer).to.equal('undefined');
}
resolve()
})
})
resolve();
});
});
}
it('disables node integration when specified to false', async () => {
@ -111,9 +111,9 @@ describe('BrowserWindow with affinity module', () => {
preload,
nodeIntegration: false
})
])
await closeWindow(w, { assertNotWindows: false })
})
]);
await closeWindow(w, { assertNotWindows: false });
});
it('disables node integration when first window is false', async () => {
const [, w1] = await Promise.all([
testNodeIntegration(false),
@ -122,7 +122,7 @@ describe('BrowserWindow with affinity module', () => {
preload,
nodeIntegration: false
})
])
]);
const [, w2] = await Promise.all([
testNodeIntegration(false),
createWindowWithWebPrefs({
@ -130,12 +130,12 @@ describe('BrowserWindow with affinity module', () => {
preload,
nodeIntegration: true
})
])
]);
await Promise.all([
closeWindow(w1, { assertNotWindows: false }),
closeWindow(w2, { assertNotWindows: false })
])
})
]);
});
it('enables node integration when specified to true', async () => {
const [, w] = await Promise.all([
@ -145,9 +145,9 @@ describe('BrowserWindow with affinity module', () => {
preload,
nodeIntegration: true
})
])
await closeWindow(w, { assertNotWindows: false })
})
]);
await closeWindow(w, { assertNotWindows: false });
});
it('enables node integration when first window is true', async () => {
const [, w1] = await Promise.all([
@ -157,7 +157,7 @@ describe('BrowserWindow with affinity module', () => {
preload,
nodeIntegration: true
})
])
]);
const [, w2] = await Promise.all([
testNodeIntegration(true),
createWindowWithWebPrefs({
@ -165,11 +165,11 @@ describe('BrowserWindow with affinity module', () => {
preload,
nodeIntegration: false
})
])
]);
await Promise.all([
closeWindow(w1, { assertNotWindows: false }),
closeWindow(w2, { assertNotWindows: false })
])
})
})
})
]);
});
});
});