mirror of
https://github.com/coder/code-server.git
synced 2026-06-22 18:07:10 +02:00
chore(vscode): update to 1.53.2
These conflicts will be resolved in the following commits. We do it this way so that PR review is possible.
This commit is contained in:
58
lib/vscode/src/vs/base/parts/ipc/test/browser/ipc.mp.test.ts
Normal file
58
lib/vscode/src/vs/base/parts/ipc/test/browser/ipc.mp.test.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { Client as MessagePortClient } from 'vs/base/parts/ipc/browser/ipc.mp';
|
||||
|
||||
suite('IPC, MessagePorts', () => {
|
||||
|
||||
test('message passing', async () => {
|
||||
const { port1, port2 } = new MessageChannel();
|
||||
|
||||
const client1 = new MessagePortClient(port1, 'client1');
|
||||
const client2 = new MessagePortClient(port2, 'client2');
|
||||
|
||||
client1.registerChannel('client1', {
|
||||
call(_: unknown, command: string, arg: any, cancellationToken: CancellationToken): Promise<any> {
|
||||
switch (command) {
|
||||
case 'testMethodClient1': return Promise.resolve('success1');
|
||||
default: return Promise.reject(new Error('not implemented'));
|
||||
}
|
||||
},
|
||||
|
||||
listen(_: unknown, event: string, arg?: any): Event<any> {
|
||||
switch (event) {
|
||||
default: throw new Error('not implemented');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
client2.registerChannel('client2', {
|
||||
call(_: unknown, command: string, arg: any, cancellationToken: CancellationToken): Promise<any> {
|
||||
switch (command) {
|
||||
case 'testMethodClient2': return Promise.resolve('success2');
|
||||
default: return Promise.reject(new Error('not implemented'));
|
||||
}
|
||||
},
|
||||
|
||||
listen(_: unknown, event: string, arg?: any): Event<any> {
|
||||
switch (event) {
|
||||
default: throw new Error('not implemented');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const channelClient1 = client2.getChannel('client1');
|
||||
assert.strictEqual(await channelClient1.call('testMethodClient1'), 'success1');
|
||||
|
||||
const channelClient2 = client1.getChannel('client2');
|
||||
assert.strictEqual(await channelClient2.call('testMethodClient2'), 'success2');
|
||||
|
||||
client1.dispose();
|
||||
client2.dispose();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,28 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { Client as MessagePortClient } from 'vs/base/parts/ipc/browser/ipc.mp';
|
||||
|
||||
suite('IPC, MessagePorts', () => {
|
||||
|
||||
test('message port close event', async () => {
|
||||
const { port1, port2 } = new MessageChannel();
|
||||
|
||||
new MessagePortClient(port1, 'client1');
|
||||
const client2 = new MessagePortClient(port2, 'client2');
|
||||
|
||||
// This test ensures that Electron's API for the close event
|
||||
// does not break because we rely on it to dispose client
|
||||
// connections from the server.
|
||||
//
|
||||
// This event is not provided by browser MessagePort API though.
|
||||
const whenClosed = new Promise<boolean>(resolve => port1.addEventListener('close', () => resolve(true)));
|
||||
|
||||
client2.dispose();
|
||||
|
||||
assert.ok(await whenClosed);
|
||||
});
|
||||
});
|
||||
@@ -11,7 +11,7 @@ import { getPathFromAmdModule } from 'vs/base/common/amd';
|
||||
function createClient(): Client {
|
||||
return new Client(getPathFromAmdModule(require, 'bootstrap-fork'), {
|
||||
serverName: 'TestServer',
|
||||
env: { AMD_ENTRYPOINT: 'vs/base/parts/ipc/test/node/testApp', verbose: true }
|
||||
env: { VSCODE_AMD_ENTRYPOINT: 'vs/base/parts/ipc/test/node/testApp', verbose: true }
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -135,13 +135,13 @@ suite('IPC, Socket Protocol', () => {
|
||||
|
||||
a.send(VSBuffer.fromString('foobarfarboo'));
|
||||
const msg1 = await bMessages.waitForOne();
|
||||
assert.equal(msg1.toString(), 'foobarfarboo');
|
||||
assert.strictEqual(msg1.toString(), 'foobarfarboo');
|
||||
|
||||
const buffer = VSBuffer.alloc(1);
|
||||
buffer.writeUInt8(123, 0);
|
||||
a.send(buffer);
|
||||
const msg2 = await bMessages.waitForOne();
|
||||
assert.equal(msg2.readUInt8(0), 123);
|
||||
assert.strictEqual(msg2.readUInt8(0), 123);
|
||||
});
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ suite('IPC, Socket Protocol', () => {
|
||||
|
||||
a.send(VSBuffer.fromString(JSON.stringify(data)));
|
||||
const msg = await bMessages.waitForOne();
|
||||
assert.deepEqual(JSON.parse(msg.toString()), data);
|
||||
assert.deepStrictEqual(JSON.parse(msg.toString()), data);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -179,49 +179,49 @@ suite('PersistentProtocol reconnection', () => {
|
||||
const bMessages = new MessageStream(b);
|
||||
|
||||
a.send(VSBuffer.fromString('a1'));
|
||||
assert.equal(a.unacknowledgedCount, 1);
|
||||
assert.equal(b.unacknowledgedCount, 0);
|
||||
assert.strictEqual(a.unacknowledgedCount, 1);
|
||||
assert.strictEqual(b.unacknowledgedCount, 0);
|
||||
|
||||
a.send(VSBuffer.fromString('a2'));
|
||||
assert.equal(a.unacknowledgedCount, 2);
|
||||
assert.equal(b.unacknowledgedCount, 0);
|
||||
assert.strictEqual(a.unacknowledgedCount, 2);
|
||||
assert.strictEqual(b.unacknowledgedCount, 0);
|
||||
|
||||
a.send(VSBuffer.fromString('a3'));
|
||||
assert.equal(a.unacknowledgedCount, 3);
|
||||
assert.equal(b.unacknowledgedCount, 0);
|
||||
assert.strictEqual(a.unacknowledgedCount, 3);
|
||||
assert.strictEqual(b.unacknowledgedCount, 0);
|
||||
|
||||
const a1 = await bMessages.waitForOne();
|
||||
assert.equal(a1.toString(), 'a1');
|
||||
assert.equal(a.unacknowledgedCount, 3);
|
||||
assert.equal(b.unacknowledgedCount, 0);
|
||||
assert.strictEqual(a1.toString(), 'a1');
|
||||
assert.strictEqual(a.unacknowledgedCount, 3);
|
||||
assert.strictEqual(b.unacknowledgedCount, 0);
|
||||
|
||||
const a2 = await bMessages.waitForOne();
|
||||
assert.equal(a2.toString(), 'a2');
|
||||
assert.equal(a.unacknowledgedCount, 3);
|
||||
assert.equal(b.unacknowledgedCount, 0);
|
||||
assert.strictEqual(a2.toString(), 'a2');
|
||||
assert.strictEqual(a.unacknowledgedCount, 3);
|
||||
assert.strictEqual(b.unacknowledgedCount, 0);
|
||||
|
||||
const a3 = await bMessages.waitForOne();
|
||||
assert.equal(a3.toString(), 'a3');
|
||||
assert.equal(a.unacknowledgedCount, 3);
|
||||
assert.equal(b.unacknowledgedCount, 0);
|
||||
assert.strictEqual(a3.toString(), 'a3');
|
||||
assert.strictEqual(a.unacknowledgedCount, 3);
|
||||
assert.strictEqual(b.unacknowledgedCount, 0);
|
||||
|
||||
b.send(VSBuffer.fromString('b1'));
|
||||
assert.equal(a.unacknowledgedCount, 3);
|
||||
assert.equal(b.unacknowledgedCount, 1);
|
||||
assert.strictEqual(a.unacknowledgedCount, 3);
|
||||
assert.strictEqual(b.unacknowledgedCount, 1);
|
||||
|
||||
const b1 = await aMessages.waitForOne();
|
||||
assert.equal(b1.toString(), 'b1');
|
||||
assert.equal(a.unacknowledgedCount, 0);
|
||||
assert.equal(b.unacknowledgedCount, 1);
|
||||
assert.strictEqual(b1.toString(), 'b1');
|
||||
assert.strictEqual(a.unacknowledgedCount, 0);
|
||||
assert.strictEqual(b.unacknowledgedCount, 1);
|
||||
|
||||
a.send(VSBuffer.fromString('a4'));
|
||||
assert.equal(a.unacknowledgedCount, 1);
|
||||
assert.equal(b.unacknowledgedCount, 1);
|
||||
assert.strictEqual(a.unacknowledgedCount, 1);
|
||||
assert.strictEqual(b.unacknowledgedCount, 1);
|
||||
|
||||
const b2 = await bMessages.waitForOne();
|
||||
assert.equal(b2.toString(), 'a4');
|
||||
assert.equal(a.unacknowledgedCount, 1);
|
||||
assert.equal(b.unacknowledgedCount, 0);
|
||||
assert.strictEqual(b2.toString(), 'a4');
|
||||
assert.strictEqual(a.unacknowledgedCount, 1);
|
||||
assert.strictEqual(b.unacknowledgedCount, 0);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user