fix: let Node.js perform microtask checkpoint in the main process (#24131)

* fix: let Node.js perform microtask checkpoint in the main process

* fix: don't specify v8::MicrotasksScope for explicit policy

* fix: remove checkpoint from some call-sites

We already perform checkpoint at the end of a task,
either through MicrotaskRunner or through NodeBindings.
There isn't a need to add them again when calling into JS
except when dealing with promises.

* fix: remove checkpoint from some call-sites

We already perform checkpoint at the end of a task,
either through MicrotaskRunner or through NodeBindings.
There isn't a need to add them again when calling into JS
except when dealing with promises.

* fix incorrect specs

* default constructor arguments are considered for explicit mark

* add regression spec
This commit is contained in:
Robo 2020-06-17 10:08:10 -07:00 committed by GitHub
parent 59f9d75324
commit 7cc780d077
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 145 additions and 39 deletions

View file

@ -597,28 +597,50 @@ describe('webContents module', () => {
// On Mac, zooming isn't done with the mouse wheel.
ifdescribe(process.platform !== 'darwin')('zoom-changed', () => {
afterEach(closeAllWindows);
it('is emitted with the correct zooming info', async () => {
it('is emitted with the correct zoom-in info', async () => {
const w = new BrowserWindow({ show: false });
await w.loadFile(path.join(fixturesPath, 'pages', 'base-page.html'));
const testZoomChanged = async ({ zoomingIn }: { zoomingIn: boolean }) => {
const testZoomChanged = async () => {
w.webContents.sendInputEvent({
type: 'mouseWheel',
x: 300,
y: 300,
deltaX: 0,
deltaY: zoomingIn ? 1 : -1,
deltaY: 1,
wheelTicksX: 0,
wheelTicksY: zoomingIn ? 1 : -1,
wheelTicksY: 1,
modifiers: ['control', 'meta']
});
const [, zoomDirection] = await emittedOnce(w.webContents, 'zoom-changed');
expect(zoomDirection).to.equal(zoomingIn ? 'in' : 'out');
expect(zoomDirection).to.equal('in');
};
await testZoomChanged({ zoomingIn: true });
await testZoomChanged({ zoomingIn: false });
await testZoomChanged();
});
it('is emitted with the correct zoom-out info', async () => {
const w = new BrowserWindow({ show: false });
await w.loadFile(path.join(fixturesPath, 'pages', 'base-page.html'));
const testZoomChanged = async () => {
w.webContents.sendInputEvent({
type: 'mouseWheel',
x: 300,
y: 300,
deltaX: 0,
deltaY: -1,
wheelTicksX: 0,
wheelTicksY: -1,
modifiers: ['control', 'meta']
});
const [, zoomDirection] = await emittedOnce(w.webContents, 'zoom-changed');
expect(zoomDirection).to.equal('out');
};
await testZoomChanged();
});
});