mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
@@ -6,7 +6,7 @@
|
||||
import test from '@playwright/test';
|
||||
import { readFileSync } from 'fs';
|
||||
import { FINALIZER, introducer, sixelEncode } from 'sixel';
|
||||
import { ITestContext, createTestContext, openTerminal, pollFor } from '../../../test/playwright/TestUtils';
|
||||
import { ITestContext, createTestContext, openTerminal, pollFor, timeout } from '../../../test/playwright/TestUtils';
|
||||
import { deepStrictEqual, ok, strictEqual } from 'assert';
|
||||
|
||||
/**
|
||||
@@ -199,7 +199,7 @@ test.describe('ImageAddon', () => {
|
||||
(await getScrollbackPlusRows() - 1)
|
||||
);
|
||||
// wait here, as we have to make sure, that eviction did not yet occur
|
||||
await new Promise(r => setTimeout(r, 100));
|
||||
await timeout(100);
|
||||
pollFor(ctx.page, 'window.imageAddon._storage._images.size', 1);
|
||||
// scroll one further should delete the image
|
||||
await ctx.page.evaluate(() => new Promise(res => (window as any).term.write('\n', res)));
|
||||
@@ -222,13 +222,13 @@ test.describe('ImageAddon', () => {
|
||||
await ctx.proxy.write(SIXEL_SEQ_0);
|
||||
await ctx.proxy.write(SIXEL_SEQ_0);
|
||||
await ctx.proxy.write(SIXEL_SEQ_0);
|
||||
await new Promise(r => setTimeout(r, 50));
|
||||
await timeout(100);
|
||||
const usage = await ctx.page.evaluate('window.imageAddon.storageUsage');
|
||||
await ctx.proxy.write(SIXEL_SEQ_0);
|
||||
await ctx.proxy.write(SIXEL_SEQ_0);
|
||||
await ctx.proxy.write(SIXEL_SEQ_0);
|
||||
await ctx.proxy.write(SIXEL_SEQ_0);
|
||||
await new Promise(r => setTimeout(r, 50));
|
||||
await timeout(100);
|
||||
strictEqual(await ctx.page.evaluate('window.imageAddon.storageUsage'), usage);
|
||||
strictEqual(usage as number < 1, true);
|
||||
});
|
||||
@@ -247,25 +247,26 @@ test.describe('ImageAddon', () => {
|
||||
strictEqual(await ctx.page.evaluate('window.imageAddon.storageUsage'), 0);
|
||||
});
|
||||
test('evict tiles by in-place overwrites (only full overwrite tested)', async () => {
|
||||
await new Promise(r => setTimeout(r, 50));
|
||||
await timeout(50);
|
||||
await ctx.proxy.write('\x1b[H' + SIXEL_SEQ_0 + '\x1b[100;100H');
|
||||
await timeout(50);
|
||||
let usage = await ctx.page.evaluate('window.imageAddon.storageUsage');
|
||||
while (usage === 0) {
|
||||
await new Promise(r => setTimeout(r, 50));
|
||||
await timeout(50);
|
||||
usage = await ctx.page.evaluate('window.imageAddon.storageUsage');
|
||||
}
|
||||
await ctx.proxy.write('\x1b[H' + SIXEL_SEQ_0 + '\x1b[100;100H');
|
||||
await new Promise(r => setTimeout(r, 200)); // wait some time and re-check
|
||||
await timeout(200); // wait some time and re-check
|
||||
strictEqual(await ctx.page.evaluate('window.imageAddon.storageUsage'), usage);
|
||||
});
|
||||
test('manual eviction on alternate buffer must not miss images', async () => {
|
||||
await ctx.proxy.write('\x1b[?1049h');
|
||||
await ctx.proxy.write(SIXEL_SEQ_0 + SIXEL_SEQ_0 + SIXEL_SEQ_0 + SIXEL_SEQ_0 + SIXEL_SEQ_0 + SIXEL_SEQ_0);
|
||||
await new Promise(r => setTimeout(r, 50));
|
||||
await timeout(100);
|
||||
const usage: number = await ctx.page.evaluate('window.imageAddon.storageUsage');
|
||||
await ctx.proxy.write(SIXEL_SEQ_0 + SIXEL_SEQ_0 + SIXEL_SEQ_0 + SIXEL_SEQ_0 + SIXEL_SEQ_0 + SIXEL_SEQ_0);
|
||||
await ctx.proxy.write(SIXEL_SEQ_0 + SIXEL_SEQ_0 + SIXEL_SEQ_0 + SIXEL_SEQ_0 + SIXEL_SEQ_0 + SIXEL_SEQ_0);
|
||||
await new Promise(r => setTimeout(r, 50));
|
||||
await timeout(100);
|
||||
const newUsage: number = await ctx.page.evaluate('window.imageAddon.storageUsage');
|
||||
strictEqual(newUsage, usage);
|
||||
});
|
||||
|
||||
@@ -35,10 +35,10 @@ test.describe('WebLinksAddon', () => {
|
||||
test.beforeEach(async () => {
|
||||
await ctx.page.evaluate(`
|
||||
window.term.reset();
|
||||
`);
|
||||
await timeout(50);
|
||||
await ctx.page.evaluate(`
|
||||
window._linkaddon?.dispose();
|
||||
`);
|
||||
await timeout(10);
|
||||
await ctx.page.evaluate(`
|
||||
window._linkaddon = new WebLinksAddon();
|
||||
window.term.loadAddon(window._linkaddon);
|
||||
`);
|
||||
|
||||
@@ -88,6 +88,9 @@ export class WebglAddon extends Disposable implements ITerminalAddon , IWebglApi
|
||||
renderService.setRenderer(this._renderer);
|
||||
|
||||
this._register(toDisposable(() => {
|
||||
if ((this._terminal as any)._core._store._isDisposed) {
|
||||
return;
|
||||
}
|
||||
const renderService: IRenderService = (this._terminal as any)._core._renderService;
|
||||
renderService.setRenderer((this._terminal as any)._core._createRenderer());
|
||||
renderService.handleResize(terminal.cols, terminal.rows);
|
||||
|
||||
Reference in New Issue
Block a user