mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Merge remote-tracking branch 'upstream/master' into pr/tisilent/4801
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { test } from '@playwright/test';
|
||||
import { deepStrictEqual, ok, strictEqual } from 'assert';
|
||||
import type { IDisposable } from 'xterm';
|
||||
import type { IDisposable } from '@xterm/xterm';
|
||||
import { createTestContext, ITestContext, openTerminal, pollFor } from './TestUtils';
|
||||
|
||||
let ctx: ITestContext;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { test } from '@playwright/test';
|
||||
import { deepStrictEqual, ok, strictEqual } from 'assert';
|
||||
import type { IDisposable } from 'xterm';
|
||||
import type { IDisposable } from '@xterm/xterm';
|
||||
import { createTestContext, ITestContext, openTerminal, pollFor } from './TestUtils';
|
||||
|
||||
let ctx: ITestContext;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import { test } from '@playwright/test';
|
||||
import { ITestContext, createTestContext, openTerminal } from './TestUtils';
|
||||
import { ISharedRendererTestContext, injectSharedRendererTests } from './SharedRendererTests';
|
||||
import { ISharedRendererTestContext, injectSharedRendererTestsStandalone, injectSharedRendererTests } from './SharedRendererTests';
|
||||
|
||||
let ctx: ITestContext;
|
||||
const ctxWrapper: ISharedRendererTestContext = { value: undefined } as any;
|
||||
@@ -18,5 +18,5 @@ test.afterAll(async () => await ctx.page.close());
|
||||
|
||||
test.describe('DOM Renderer Integration Tests', () => {
|
||||
injectSharedRendererTests(ctxWrapper);
|
||||
injectSharedRendererTestsStandalone(ctxWrapper);
|
||||
});
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
import { IImage32, decodePng } from '@lunapaint/png-codec';
|
||||
import { LocatorScreenshotOptions, test } from '@playwright/test';
|
||||
import { ITheme } from 'xterm';
|
||||
import { ITestContext, MaybeAsync, pollFor, pollForApproximate } from './TestUtils';
|
||||
import { ITheme } from '@xterm/xterm';
|
||||
import { ITestContext, MaybeAsync, openTerminal, pollFor, pollForApproximate } from './TestUtils';
|
||||
|
||||
export interface ISharedRendererTestContext {
|
||||
value: ITestContext;
|
||||
@@ -1092,6 +1092,30 @@ export function injectSharedRendererTests(ctx: ISharedRendererTestContext): void
|
||||
});
|
||||
|
||||
test.describe('regression tests', () => {
|
||||
test('#4736: inactive selection background should replace regular cell background color', async () => {
|
||||
const theme: ITheme = {
|
||||
selectionBackground: '#FF0000',
|
||||
selectionInactiveBackground: '#0000FF'
|
||||
};
|
||||
await ctx.value.page.evaluate(`window.term.options.theme = ${JSON.stringify(theme)};`);
|
||||
await ctx.value.proxy.writeln(' ');
|
||||
await ctx.value.proxy.writeln(' O ');
|
||||
await ctx.value.proxy.writeln(' ');
|
||||
await ctx.value.proxy.focus();
|
||||
await ctx.value.proxy.selectAll();
|
||||
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 1, 1), [255, 0, 0, 255]);
|
||||
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 2, 1), [255, 0, 0, 255]);
|
||||
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 2, 2), [255, 0, 0, 255]);
|
||||
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 2, 3), [255, 0, 0, 255]);
|
||||
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 3, 3), [255, 0, 0, 255]);
|
||||
await ctx.value.proxy.blur();
|
||||
frameDetails = undefined;
|
||||
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 1, 1), [0, 0, 255, 255]);
|
||||
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 2, 1), [0, 0, 255, 255]);
|
||||
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 2, 2), [0, 0, 255, 255]);
|
||||
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 2, 3), [0, 0, 255, 255]);
|
||||
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 3, 3), [0, 0, 255, 255]);
|
||||
});
|
||||
test('#4758: multiple invisible text characters without SGR change should not be rendered', async () => {
|
||||
// Regression test: #4758 when multiple invisible characters are used
|
||||
await ctx.value.proxy.writeln(`■\x1b[8m■■`);
|
||||
@@ -1176,6 +1200,40 @@ enum CellColorPosition {
|
||||
FIRST = 1
|
||||
}
|
||||
|
||||
/**
|
||||
* Injects shared renderer tests where it's required to re-initialize the terminal for each test.
|
||||
* This is much slower than just calling `Terminal.reset` but testing some features needs this
|
||||
* treatment.
|
||||
*/
|
||||
export function injectSharedRendererTestsStandalone(ctx: ISharedRendererTestContext): void {
|
||||
test.beforeEach(async () => {
|
||||
// Recreate terminal
|
||||
await openTerminal(ctx.value);
|
||||
ctx.value.page.evaluate(`
|
||||
window.term.options.minimumContrastRatio = 1;
|
||||
window.term.options.allowTransparency = false;
|
||||
window.term.options.theme = undefined;
|
||||
`);
|
||||
// Clear the cached screenshot before each test
|
||||
frameDetails = undefined;
|
||||
});
|
||||
test.describe('regression tests', () => {
|
||||
test('#4790: cursor should not be displayed before focusing', async () => {
|
||||
const theme: ITheme = {
|
||||
cursor: '#0000FF'
|
||||
};
|
||||
await ctx.value.page.evaluate(`window.term.options.theme = ${JSON.stringify(theme)};`);
|
||||
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 1, 1), [0, 0, 0, 255]);
|
||||
await ctx.value.proxy.focus();
|
||||
frameDetails = undefined;
|
||||
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 1, 1), [0, 0, 255, 255]);
|
||||
await ctx.value.proxy.blur();
|
||||
frameDetails = undefined;
|
||||
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 1, 1), [0, 0, 0, 255]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the color of the pixel in the center of a cell.
|
||||
* @param ctx The test context.
|
||||
|
||||
@@ -10,7 +10,7 @@ import type { IRenderService } from 'browser/services/Services';
|
||||
import type { ICoreTerminal, IMarker } from 'common/Types';
|
||||
import * as playwright from '@playwright/test';
|
||||
import { PageFunction } from 'playwright-core/types/structs';
|
||||
import { IBuffer, IBufferCell, IBufferLine, IBufferNamespace, IBufferRange, IDecoration, IDecorationOptions, IModes, ITerminalInitOnlyOptions, ITerminalOptions, Terminal } from 'xterm';
|
||||
import { IBuffer, IBufferCell, IBufferLine, IBufferNamespace, IBufferRange, IDecoration, IDecorationOptions, IModes, ITerminalInitOnlyOptions, ITerminalOptions, Terminal } from '@xterm/xterm';
|
||||
import { EventEmitter } from '../../out/common/EventEmitter';
|
||||
|
||||
export interface ITestContext {
|
||||
|
||||
Reference in New Issue
Block a user