mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Merge pull request #2712 from jmbockhorst/playwright
Use playwright instead of puppeteer
This commit is contained in:
@@ -3,39 +3,35 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import * as puppeteer from 'puppeteer';
|
||||
import WebSocket = require('ws');
|
||||
import { openTerminal, pollFor } from '../../../out-test/api/TestUtils';
|
||||
import { openTerminal, pollFor, getBrowserType } from '../../../out-test/api/TestUtils';
|
||||
import { Browser, Page } from 'playwright-core';
|
||||
|
||||
const APP = 'http://127.0.0.1:3000/test';
|
||||
|
||||
let browser: puppeteer.Browser;
|
||||
let page: puppeteer.Page;
|
||||
let browser: Browser;
|
||||
let page: Page;
|
||||
const width = 800;
|
||||
const height = 600;
|
||||
|
||||
describe('AttachAddon', () => {
|
||||
before(async function(): Promise<any> {
|
||||
this.timeout(20000);
|
||||
browser = await puppeteer.launch({
|
||||
const browserType = getBrowserType();
|
||||
browser = await browserType.launch({
|
||||
headless: process.argv.indexOf('--headless') !== -1,
|
||||
args: [`--window-size=${width},${height}`, `--no-sandbox`]
|
||||
});
|
||||
page = (await browser.pages())[0];
|
||||
await page.setViewport({ width, height });
|
||||
page = await (await browser.newContext()).newPage();
|
||||
await page.setViewportSize({ width, height });
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
beforeEach(async function(): Promise<any> {
|
||||
this.timeout(20000);
|
||||
await page.goto(APP);
|
||||
});
|
||||
beforeEach(async () => await page.goto(APP));
|
||||
|
||||
it('string', async function(): Promise<any> {
|
||||
this.timeout(20000);
|
||||
await openTerminal(page, { rendererType: 'dom' });
|
||||
const port = 8080;
|
||||
const server = new WebSocket.Server({ port });
|
||||
@@ -46,7 +42,6 @@ describe('AttachAddon', () => {
|
||||
});
|
||||
|
||||
it('utf8', async function(): Promise<any> {
|
||||
this.timeout(20000);
|
||||
await openTerminal(page, { rendererType: 'dom' });
|
||||
const port = 8080;
|
||||
const server = new WebSocket.Server({ port });
|
||||
|
||||
@@ -3,28 +3,34 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import * as puppeteer from 'puppeteer';
|
||||
import { assert } from 'chai';
|
||||
import { openTerminal } from '../../../out-test/api/TestUtils';
|
||||
import { openTerminal, getBrowserType } from '../../../out-test/api/TestUtils';
|
||||
import { Browser, Page } from 'playwright-core';
|
||||
|
||||
const APP = 'http://127.0.0.1:3000/test';
|
||||
|
||||
let browser: puppeteer.Browser;
|
||||
let page: puppeteer.Page;
|
||||
let browser: Browser;
|
||||
let page: Page;
|
||||
const width = 1024;
|
||||
const height = 768;
|
||||
|
||||
let isFirefox = false;
|
||||
|
||||
describe('FitAddon', () => {
|
||||
before(async function(): Promise<any> {
|
||||
this.timeout(20000);
|
||||
browser = await puppeteer.launch({
|
||||
const browserType = getBrowserType();
|
||||
browser = await browserType.launch({
|
||||
headless: process.argv.indexOf('--headless') !== -1,
|
||||
args: [`--window-size=${width},${height}`, `--no-sandbox`]
|
||||
});
|
||||
page = (await browser.pages())[0];
|
||||
await page.setViewport({ width, height });
|
||||
page = await (await browser.newContext()).newPage();
|
||||
await page.setViewportSize({ width, height });
|
||||
await page.goto(APP);
|
||||
await openTerminal(page);
|
||||
// This is used to do conditional assertions since cell height is 1 pixel higher with the
|
||||
// default font on Firefox. Minor differences in font rendering/sizing is expected so this is
|
||||
// fine.
|
||||
isFirefox = await page.evaluate(`navigator.userAgent.toLowerCase().indexOf('firefox') > -1`);
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
@@ -45,7 +51,7 @@ describe('FitAddon', () => {
|
||||
await loadFit();
|
||||
assert.deepEqual(await page.evaluate(`window.fit.proposeDimensions()`), {
|
||||
cols: 87,
|
||||
rows: 26
|
||||
rows: isFirefox ? 28 : 26
|
||||
});
|
||||
});
|
||||
|
||||
@@ -53,7 +59,7 @@ describe('FitAddon', () => {
|
||||
await loadFit(1008);
|
||||
assert.deepEqual(await page.evaluate(`window.fit.proposeDimensions()`), {
|
||||
cols: 110,
|
||||
rows: 26
|
||||
rows: isFirefox ? 28 : 26
|
||||
});
|
||||
});
|
||||
|
||||
@@ -75,14 +81,14 @@ describe('FitAddon', () => {
|
||||
await loadFit();
|
||||
await page.evaluate(`window.fit.fit()`);
|
||||
assert.equal(await page.evaluate(`window.term.cols`), 87);
|
||||
assert.equal(await page.evaluate(`window.term.rows`), 26);
|
||||
assert.equal(await page.evaluate(`window.term.rows`), isFirefox ? 28 : 26);
|
||||
});
|
||||
|
||||
it('width', async function(): Promise<any> {
|
||||
await loadFit(1008);
|
||||
await page.evaluate(`window.fit.fit()`);
|
||||
assert.equal(await page.evaluate(`window.term.cols`), 110);
|
||||
assert.equal(await page.evaluate(`window.term.rows`), 26);
|
||||
assert.equal(await page.evaluate(`window.term.rows`), isFirefox ? 28 : 26);
|
||||
});
|
||||
|
||||
it('small', async function(): Promise<any> {
|
||||
|
||||
@@ -3,29 +3,28 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import * as puppeteer from 'puppeteer';
|
||||
import { assert } from 'chai';
|
||||
import { readFile } from 'fs';
|
||||
import { resolve } from 'path';
|
||||
import { openTerminal, writeSync } from '../../../out-test/api/TestUtils';
|
||||
import { openTerminal, writeSync, getBrowserType } from '../../../out-test/api/TestUtils';
|
||||
import { Browser, Page } from 'playwright-core';
|
||||
|
||||
const APP = 'http://127.0.0.1:3000/test';
|
||||
|
||||
let browser: puppeteer.Browser;
|
||||
let page: puppeteer.Page;
|
||||
let browser: Browser;
|
||||
let page: Page;
|
||||
const width = 800;
|
||||
const height = 600;
|
||||
|
||||
describe('Search Tests', function(): void {
|
||||
this.timeout(20000);
|
||||
|
||||
before(async function(): Promise<any> {
|
||||
browser = await puppeteer.launch({
|
||||
const browserType = getBrowserType();
|
||||
browser = await browserType.launch({
|
||||
headless: process.argv.indexOf('--headless') !== -1,
|
||||
args: [`--window-size=${width},${height}`, `--no-sandbox`]
|
||||
});
|
||||
page = (await browser.pages())[0];
|
||||
await page.setViewport({ width, height });
|
||||
page = await (await browser.newContext()).newPage();
|
||||
await page.setViewportSize({ width, height });
|
||||
await page.goto(APP);
|
||||
await openTerminal(page);
|
||||
await page.evaluate(`window.search = new SearchAddon();`);
|
||||
|
||||
@@ -3,25 +3,26 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import * as puppeteer from 'puppeteer';
|
||||
import { assert } from 'chai';
|
||||
import { openTerminal, writeSync } from '../../../out-test/api/TestUtils';
|
||||
import { openTerminal, writeSync, getBrowserType } from '../../../out-test/api/TestUtils';
|
||||
import { Browser, Page } from 'playwright-core';
|
||||
|
||||
const APP = 'http://127.0.0.1:3000/test';
|
||||
|
||||
let browser: puppeteer.Browser;
|
||||
let page: puppeteer.Page;
|
||||
let browser: Browser;
|
||||
let page: Page;
|
||||
const width = 800;
|
||||
const height = 600;
|
||||
|
||||
describe('SerializeAddon', () => {
|
||||
before(async function (): Promise<any> {
|
||||
browser = await puppeteer.launch({
|
||||
before(async function(): Promise<any> {
|
||||
const browserType = getBrowserType();
|
||||
browser = await browserType.launch({
|
||||
headless: process.argv.indexOf('--headless') !== -1,
|
||||
args: [`--window-size=${width},${height}`]
|
||||
});
|
||||
page = (await browser.pages())[0];
|
||||
await page.setViewport({ width, height });
|
||||
page = await (await browser.newContext()).newPage();
|
||||
await page.setViewportSize({ width, height });
|
||||
await page.goto(APP);
|
||||
await openTerminal(page, { rows: 10, cols: 10, rendererType: 'dom' });
|
||||
await page.evaluate(`
|
||||
@@ -33,13 +34,13 @@ describe('SerializeAddon', () => {
|
||||
after(async () => await browser.close());
|
||||
beforeEach(async () => await page.evaluate(`window.term.reset()`));
|
||||
|
||||
it('empty content', async function (): Promise<any> {
|
||||
it('empty content', async function(): Promise<any> {
|
||||
const rows = 10;
|
||||
const cols = 10;
|
||||
assert.equal(await page.evaluate(`serializeAddon.serialize();`), '');
|
||||
});
|
||||
|
||||
it('trim last empty lines', async function (): Promise<any> {
|
||||
it('trim last empty lines', async function(): Promise<any> {
|
||||
const cols = 10;
|
||||
const lines = [
|
||||
'',
|
||||
@@ -58,7 +59,7 @@ describe('SerializeAddon', () => {
|
||||
assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.slice(0, 8).join('\r\n'));
|
||||
});
|
||||
|
||||
it('digits content', async function (): Promise<any> {
|
||||
it('digits content', async function(): Promise<any> {
|
||||
const rows = 10;
|
||||
const cols = 10;
|
||||
const digitsLine = digitsString(cols);
|
||||
@@ -67,7 +68,7 @@ describe('SerializeAddon', () => {
|
||||
assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n'));
|
||||
});
|
||||
|
||||
it('serialize half rows of content', async function (): Promise<any> {
|
||||
it('serialize half rows of content', async function(): Promise<any> {
|
||||
const rows = 10;
|
||||
const halfRows = rows >> 1;
|
||||
const cols = 10;
|
||||
@@ -76,7 +77,7 @@ describe('SerializeAddon', () => {
|
||||
assert.equal(await page.evaluate(`serializeAddon.serialize(${halfRows});`), lines.slice(halfRows, 2 * halfRows).join('\r\n'));
|
||||
});
|
||||
|
||||
it('serialize 0 rows of content', async function (): Promise<any> {
|
||||
it('serialize 0 rows of content', async function(): Promise<any> {
|
||||
const rows = 10;
|
||||
const cols = 10;
|
||||
const lines = newArray<string>((index: number) => digitsString(cols, index), rows);
|
||||
@@ -84,7 +85,7 @@ describe('SerializeAddon', () => {
|
||||
assert.equal(await page.evaluate(`serializeAddon.serialize(0);`), '');
|
||||
});
|
||||
|
||||
it('serialize all rows of content with color16', async function (): Promise<any> {
|
||||
it('serialize all rows of content with color16', async function(): Promise<any> {
|
||||
const cols = 10;
|
||||
const color16 = [
|
||||
30, 31, 32, 33, 34, 35, 36, 37, // Set foreground color
|
||||
@@ -101,7 +102,7 @@ describe('SerializeAddon', () => {
|
||||
assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n'));
|
||||
});
|
||||
|
||||
it('serialize all rows of content with fg/bg flags', async function (): Promise<any> {
|
||||
it('serialize all rows of content with fg/bg flags', async function(): Promise<any> {
|
||||
const cols = 10;
|
||||
const line = '+'.repeat(cols);
|
||||
const lines: string[] = [
|
||||
@@ -122,7 +123,7 @@ describe('SerializeAddon', () => {
|
||||
assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n'));
|
||||
});
|
||||
|
||||
it('serialize all rows of content with color256', async function (): Promise<any> {
|
||||
it('serialize all rows of content with color256', async function(): Promise<any> {
|
||||
const rows = 32;
|
||||
const cols = 10;
|
||||
const lines = newArray<string>(
|
||||
@@ -133,7 +134,7 @@ describe('SerializeAddon', () => {
|
||||
assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n'));
|
||||
});
|
||||
|
||||
it('serialize all rows of content with color16 and style separately', async function (): Promise<any> {
|
||||
it('serialize all rows of content with color16 and style separately', async function(): Promise<any> {
|
||||
const cols = 10;
|
||||
const line = '+'.repeat(cols);
|
||||
const lines: string[] = [
|
||||
@@ -152,7 +153,7 @@ describe('SerializeAddon', () => {
|
||||
assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n'));
|
||||
});
|
||||
|
||||
it('serialize all rows of content with color16 and style together', async function (): Promise<any> {
|
||||
it('serialize all rows of content with color16 and style together', async function(): Promise<any> {
|
||||
const cols = 10;
|
||||
const line = '+'.repeat(cols);
|
||||
const lines: string[] = [
|
||||
@@ -174,7 +175,7 @@ describe('SerializeAddon', () => {
|
||||
assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n'));
|
||||
});
|
||||
|
||||
it('serialize all rows of content with color256 and style separately', async function (): Promise<any> {
|
||||
it('serialize all rows of content with color256 and style separately', async function(): Promise<any> {
|
||||
const cols = 10;
|
||||
const line = '+'.repeat(cols);
|
||||
const lines: string[] = [
|
||||
@@ -193,7 +194,7 @@ describe('SerializeAddon', () => {
|
||||
assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n'));
|
||||
});
|
||||
|
||||
it('serialize all rows of content with color256 and style together', async function (): Promise<any> {
|
||||
it('serialize all rows of content with color256 and style together', async function(): Promise<any> {
|
||||
const cols = 10;
|
||||
const line = '+'.repeat(cols);
|
||||
const lines: string[] = [
|
||||
@@ -215,7 +216,7 @@ describe('SerializeAddon', () => {
|
||||
assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n'));
|
||||
});
|
||||
|
||||
it('serialize all rows of content with colorRGB and style separately', async function (): Promise<any> {
|
||||
it('serialize all rows of content with colorRGB and style separately', async function(): Promise<any> {
|
||||
const cols = 10;
|
||||
const line = '+'.repeat(cols);
|
||||
const lines: string[] = [
|
||||
@@ -234,7 +235,7 @@ describe('SerializeAddon', () => {
|
||||
assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n'));
|
||||
});
|
||||
|
||||
it('serialize all rows of content with colorRGB and style together', async function (): Promise<any> {
|
||||
it('serialize all rows of content with colorRGB and style together', async function(): Promise<any> {
|
||||
const cols = 10;
|
||||
const line = '+'.repeat(cols);
|
||||
const lines: string[] = [
|
||||
|
||||
@@ -3,26 +3,26 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import * as puppeteer from 'puppeteer';
|
||||
import { assert } from 'chai';
|
||||
import { openTerminal } from '../../../out-test/api/TestUtils';
|
||||
import { openTerminal, getBrowserType } from '../../../out-test/api/TestUtils';
|
||||
import { Browser, Page } from 'playwright-core';
|
||||
|
||||
const APP = 'http://127.0.0.1:3000/test';
|
||||
|
||||
let browser: puppeteer.Browser;
|
||||
let page: puppeteer.Page;
|
||||
let browser: Browser;
|
||||
let page: Page;
|
||||
const width = 800;
|
||||
const height = 600;
|
||||
|
||||
describe('Unicode11Addon', () => {
|
||||
before(async function(): Promise<any> {
|
||||
this.timeout(20000);
|
||||
browser = await puppeteer.launch({
|
||||
const browserType = getBrowserType();
|
||||
browser = await browserType.launch({
|
||||
headless: process.argv.indexOf('--headless') !== -1,
|
||||
args: [`--window-size=${width},${height}`, `--no-sandbox`]
|
||||
});
|
||||
page = (await browser.pages())[0];
|
||||
await page.setViewport({ width, height });
|
||||
page = await (await browser.newContext()).newPage();
|
||||
await page.setViewportSize({ width, height });
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
@@ -30,7 +30,6 @@ describe('Unicode11Addon', () => {
|
||||
});
|
||||
|
||||
beforeEach(async function(): Promise<any> {
|
||||
this.timeout(20000);
|
||||
await page.goto(APP);
|
||||
await openTerminal(page);
|
||||
});
|
||||
|
||||
@@ -3,49 +3,40 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import * as puppeteer from 'puppeteer';
|
||||
import { assert } from 'chai';
|
||||
import { openTerminal, pollFor, writeSync } from '../../../out-test/api/TestUtils';
|
||||
import { openTerminal, pollFor, writeSync, getBrowserType } from '../../../out-test/api/TestUtils';
|
||||
import { Browser, Page } from 'playwright-core';
|
||||
|
||||
const APP = 'http://127.0.0.1:3000/test';
|
||||
|
||||
let browser: puppeteer.Browser;
|
||||
let page: puppeteer.Page;
|
||||
let browser: Browser;
|
||||
let page: Page;
|
||||
const width = 800;
|
||||
const height = 600;
|
||||
|
||||
describe('WebLinksAddon', () => {
|
||||
before(async function(): Promise<any> {
|
||||
this.timeout(10000);
|
||||
browser = await puppeteer.launch({
|
||||
const browserType = getBrowserType();
|
||||
browser = await browserType.launch({
|
||||
headless: process.argv.indexOf('--headless') !== -1,
|
||||
args: [`--window-size=${width},${height}`, `--no-sandbox`]
|
||||
});
|
||||
page = (await browser.pages())[0];
|
||||
await page.setViewport({ width, height });
|
||||
page = await (await browser.newContext()).newPage();
|
||||
await page.setViewportSize({ width, height });
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
beforeEach(async function(): Promise<any> {
|
||||
this.timeout(5000);
|
||||
await page.goto(APP);
|
||||
});
|
||||
after(async () => await browser.close());
|
||||
beforeEach(async () => await page.goto(APP));
|
||||
|
||||
it('.com', async function(): Promise<any> {
|
||||
this.timeout(20000);
|
||||
await testHostName('foo.com');
|
||||
});
|
||||
|
||||
it('.com.au', async function(): Promise<any> {
|
||||
this.timeout(20000);
|
||||
await testHostName('foo.com.au');
|
||||
});
|
||||
|
||||
it('.io', async function(): Promise<any> {
|
||||
this.timeout(20000);
|
||||
await testHostName('foo.io');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,21 +3,29 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import * as puppeteer from 'puppeteer';
|
||||
import { ITerminalOptions } from '../../../src/Types';
|
||||
import { ITheme } from 'xterm';
|
||||
import { assert } from 'chai';
|
||||
import { openTerminal, pollFor, writeSync } from '../../../out-test/api/TestUtils';
|
||||
import { openTerminal, pollFor, writeSync, getBrowserType } from '../../../out-test/api/TestUtils';
|
||||
import { Browser, Page } from 'playwright-core';
|
||||
|
||||
const APP = 'http://127.0.0.1:3000/test';
|
||||
|
||||
let browser: puppeteer.Browser;
|
||||
let page: puppeteer.Page;
|
||||
let browser: Browser;
|
||||
let page: Page;
|
||||
const width = 800;
|
||||
const height = 600;
|
||||
|
||||
describe('WebGL Renderer Integration Tests', function(): void {
|
||||
it('dispose removes renderer canvases', async () => {
|
||||
let itWebgl: (expectation: string, callback?: (this: Mocha.ITestCallbackContext, done: MochaDone) => any) => Mocha.ITest | void;
|
||||
|
||||
describe('WebGL Renderer Integration Tests', async () => {
|
||||
const browserType = getBrowserType();
|
||||
const isHeadless = process.argv.indexOf('--headless') !== -1;
|
||||
// Firefox works only in non-headless mode https://github.com/microsoft/playwright/issues/1032
|
||||
const areTestsEnabled = browserType.name() === 'chromium' || (browserType.name() === 'firefox' && !isHeadless);
|
||||
itWebgl = areTestsEnabled ? it : it.skip;
|
||||
|
||||
itWebgl('dispose removes renderer canvases', async function(): Promise<void> {
|
||||
await setupBrowser();
|
||||
assert.equal(await page.evaluate(`document.querySelectorAll('.xterm canvas').length`), 3);
|
||||
await page.evaluate(`addon.dispose()`);
|
||||
@@ -26,11 +34,13 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
});
|
||||
|
||||
describe('colors', () => {
|
||||
before(async () => setupBrowser());
|
||||
after(async () => browser.close());
|
||||
beforeEach(async () => page.evaluate(`window.term.reset()`));
|
||||
if (areTestsEnabled) {
|
||||
before(async () => setupBrowser());
|
||||
after(async () => browser.close());
|
||||
beforeEach(async () => page.evaluate(`window.term.reset()`));
|
||||
}
|
||||
|
||||
it('foreground 0-15', async () => {
|
||||
itWebgl('foreground 0-15', async () => {
|
||||
const theme: ITheme = {
|
||||
black: '#010203',
|
||||
red: '#040506',
|
||||
@@ -53,7 +63,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
await pollFor(page, () => getCellColor(8, 1), [22, 23, 24, 255]);
|
||||
});
|
||||
|
||||
it('foreground 0-7 drawBoldTextInBrightColors', async () => {
|
||||
itWebgl('foreground 0-7 drawBoldTextInBrightColors', async () => {
|
||||
const theme: ITheme = {
|
||||
brightBlack: '#010203',
|
||||
brightRed: '#040506',
|
||||
@@ -79,7 +89,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
await pollFor(page, () => getCellColor(8, 1), [22, 23, 24, 255]);
|
||||
});
|
||||
|
||||
it('background 0-15', async () => {
|
||||
itWebgl('background 0-15', async () => {
|
||||
const theme: ITheme = {
|
||||
black: '#010203',
|
||||
red: '#040506',
|
||||
@@ -102,7 +112,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
await pollFor(page, () => getCellColor(8, 1), [22, 23, 24, 255]);
|
||||
});
|
||||
|
||||
it('foreground 0-15 inverse', async () => {
|
||||
itWebgl('foreground 0-15 inverse', async () => {
|
||||
const theme: ITheme = {
|
||||
black: '#010203',
|
||||
red: '#040506',
|
||||
@@ -125,7 +135,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
await pollFor(page, () => getCellColor(8, 1), [22, 23, 24, 255]);
|
||||
});
|
||||
|
||||
it('background 0-15 inverse', async () => {
|
||||
itWebgl('background 0-15 inverse', async () => {
|
||||
const theme: ITheme = {
|
||||
black: '#010203',
|
||||
red: '#040506',
|
||||
@@ -148,7 +158,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
await pollFor(page, () => getCellColor(8, 1), [22, 23, 24, 255]);
|
||||
});
|
||||
|
||||
it('foreground 0-15 inivisible', async () => {
|
||||
itWebgl('foreground 0-15 inivisible', async () => {
|
||||
const theme: ITheme = {
|
||||
black: '#010203',
|
||||
red: '#040506',
|
||||
@@ -171,7 +181,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
await pollFor(page, () => getCellColor(8, 1), [0, 0, 0, 255]);
|
||||
});
|
||||
|
||||
it('background 0-15 inivisible', async () => {
|
||||
itWebgl('background 0-15 inivisible', async () => {
|
||||
const theme: ITheme = {
|
||||
black: '#010203',
|
||||
red: '#040506',
|
||||
@@ -194,7 +204,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
await pollFor(page, () => getCellColor(8, 1), [22, 23, 24, 255]);
|
||||
});
|
||||
|
||||
it('foreground 0-15 bright', async () => {
|
||||
itWebgl('foreground 0-15 bright', async () => {
|
||||
const theme: ITheme = {
|
||||
brightBlack: '#010203',
|
||||
brightRed: '#040506',
|
||||
@@ -217,7 +227,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
await pollFor(page, () => getCellColor(8, 1), [22, 23, 24, 255]);
|
||||
});
|
||||
|
||||
it('background 0-15 bright', async () => {
|
||||
itWebgl('background 0-15 bright', async () => {
|
||||
const theme: ITheme = {
|
||||
brightBlack: '#010203',
|
||||
brightRed: '#040506',
|
||||
@@ -240,7 +250,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
await pollFor(page, () => getCellColor(8, 1), [22, 23, 24, 255]);
|
||||
});
|
||||
|
||||
it('foreground 16-255', async () => {
|
||||
itWebgl('foreground 16-255', async () => {
|
||||
let data = '';
|
||||
for (let y = 0; y < 240 / 16; y++) {
|
||||
for (let x = 0; x < 16; x++) {
|
||||
@@ -260,7 +270,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
}
|
||||
});
|
||||
|
||||
it('background 16-255', async () => {
|
||||
itWebgl('background 16-255', async () => {
|
||||
let data = '';
|
||||
for (let y = 0; y < 240 / 16; y++) {
|
||||
for (let x = 0; x < 16; x++) {
|
||||
@@ -280,7 +290,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
}
|
||||
});
|
||||
|
||||
it('foreground 16-255 inverse', async () => {
|
||||
itWebgl('foreground 16-255 inverse', async () => {
|
||||
let data = '';
|
||||
for (let y = 0; y < 240 / 16; y++) {
|
||||
for (let x = 0; x < 16; x++) {
|
||||
@@ -300,7 +310,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
}
|
||||
});
|
||||
|
||||
it('background 16-255 inverse', async () => {
|
||||
itWebgl('background 16-255 inverse', async () => {
|
||||
let data = '';
|
||||
for (let y = 0; y < 240 / 16; y++) {
|
||||
for (let x = 0; x < 16; x++) {
|
||||
@@ -320,7 +330,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
}
|
||||
});
|
||||
|
||||
it('foreground 16-255 invisible', async () => {
|
||||
itWebgl('foreground 16-255 invisible', async () => {
|
||||
let data = '';
|
||||
for (let y = 0; y < 240 / 16; y++) {
|
||||
for (let x = 0; x < 16; x++) {
|
||||
@@ -340,7 +350,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
}
|
||||
});
|
||||
|
||||
it('background 16-255 invisible', async () => {
|
||||
itWebgl('background 16-255 invisible', async () => {
|
||||
let data = '';
|
||||
for (let y = 0; y < 240 / 16; y++) {
|
||||
for (let x = 0; x < 16; x++) {
|
||||
@@ -360,7 +370,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
}
|
||||
});
|
||||
|
||||
it('foreground true color red', async () => {
|
||||
itWebgl('foreground true color red', async () => {
|
||||
let data = '';
|
||||
for (let y = 0; y < 16; y++) {
|
||||
for (let x = 0; x < 16; x++) {
|
||||
@@ -378,7 +388,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
}
|
||||
});
|
||||
|
||||
it('background true color red', async () => {
|
||||
itWebgl('background true color red', async () => {
|
||||
let data = '';
|
||||
for (let y = 0; y < 16; y++) {
|
||||
for (let x = 0; x < 16; x++) {
|
||||
@@ -396,7 +406,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
}
|
||||
});
|
||||
|
||||
it('foreground true color green', async () => {
|
||||
itWebgl('foreground true color green', async () => {
|
||||
let data = '';
|
||||
for (let y = 0; y < 16; y++) {
|
||||
for (let x = 0; x < 16; x++) {
|
||||
@@ -414,7 +424,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
}
|
||||
});
|
||||
|
||||
it('background true color green', async () => {
|
||||
itWebgl('background true color green', async () => {
|
||||
let data = '';
|
||||
for (let y = 0; y < 16; y++) {
|
||||
for (let x = 0; x < 16; x++) {
|
||||
@@ -432,7 +442,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
}
|
||||
});
|
||||
|
||||
it('foreground true color blue', async () => {
|
||||
itWebgl('foreground true color blue', async () => {
|
||||
let data = '';
|
||||
for (let y = 0; y < 16; y++) {
|
||||
for (let x = 0; x < 16; x++) {
|
||||
@@ -450,7 +460,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
}
|
||||
});
|
||||
|
||||
it('background true color blue', async () => {
|
||||
itWebgl('background true color blue', async () => {
|
||||
let data = '';
|
||||
for (let y = 0; y < 16; y++) {
|
||||
for (let x = 0; x < 16; x++) {
|
||||
@@ -468,7 +478,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
}
|
||||
});
|
||||
|
||||
it('foreground true color grey', async () => {
|
||||
itWebgl('foreground true color grey', async () => {
|
||||
let data = '';
|
||||
for (let y = 0; y < 16; y++) {
|
||||
for (let x = 0; x < 16; x++) {
|
||||
@@ -486,7 +496,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
}
|
||||
});
|
||||
|
||||
it('background true color grey', async () => {
|
||||
itWebgl('background true color grey', async () => {
|
||||
let data = '';
|
||||
for (let y = 0; y < 16; y++) {
|
||||
for (let x = 0; x < 16; x++) {
|
||||
@@ -504,7 +514,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
}
|
||||
});
|
||||
|
||||
it('foreground true color red inverse', async function(): Promise<void> {
|
||||
itWebgl('foreground true color red inverse', async function(): Promise<void> {
|
||||
let data = '';
|
||||
for (let y = 0; y < 16; y++) {
|
||||
for (let x = 0; x < 16; x++) {
|
||||
@@ -522,7 +532,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
}
|
||||
});
|
||||
|
||||
it('background true color red inverse', async function(): Promise<void> {
|
||||
itWebgl('background true color red inverse', async function(): Promise<void> {
|
||||
let data = '';
|
||||
for (let y = 0; y < 16; y++) {
|
||||
for (let x = 0; x < 16; x++) {
|
||||
@@ -540,7 +550,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
}
|
||||
});
|
||||
|
||||
it('foreground true color green inverse', async () => {
|
||||
itWebgl('foreground true color green inverse', async () => {
|
||||
let data = '';
|
||||
for (let y = 0; y < 16; y++) {
|
||||
for (let x = 0; x < 16; x++) {
|
||||
@@ -558,7 +568,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
}
|
||||
});
|
||||
|
||||
it('background true color green inverse', async () => {
|
||||
itWebgl('background true color green inverse', async () => {
|
||||
let data = '';
|
||||
for (let y = 0; y < 16; y++) {
|
||||
for (let x = 0; x < 16; x++) {
|
||||
@@ -576,7 +586,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
}
|
||||
});
|
||||
|
||||
it('foreground true color blue inverse', async () => {
|
||||
itWebgl('foreground true color blue inverse', async () => {
|
||||
let data = '';
|
||||
for (let y = 0; y < 16; y++) {
|
||||
for (let x = 0; x < 16; x++) {
|
||||
@@ -594,7 +604,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
}
|
||||
});
|
||||
|
||||
it('background true color blue inverse', async () => {
|
||||
itWebgl('background true color blue inverse', async () => {
|
||||
let data = '';
|
||||
for (let y = 0; y < 16; y++) {
|
||||
for (let x = 0; x < 16; x++) {
|
||||
@@ -612,7 +622,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
}
|
||||
});
|
||||
|
||||
it('foreground true color grey inverse', async () => {
|
||||
itWebgl('foreground true color grey inverse', async () => {
|
||||
let data = '';
|
||||
for (let y = 0; y < 16; y++) {
|
||||
for (let x = 0; x < 16; x++) {
|
||||
@@ -630,7 +640,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
}
|
||||
});
|
||||
|
||||
it('background true color grey inverse', async () => {
|
||||
itWebgl('background true color grey inverse', async () => {
|
||||
let data = '';
|
||||
for (let y = 0; y < 16; y++) {
|
||||
for (let x = 0; x < 16; x++) {
|
||||
@@ -648,7 +658,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
}
|
||||
});
|
||||
|
||||
it('foreground true color grey invisible', async () => {
|
||||
itWebgl('foreground true color grey invisible', async () => {
|
||||
let data = '';
|
||||
for (let y = 0; y < 16; y++) {
|
||||
for (let x = 0; x < 16; x++) {
|
||||
@@ -666,7 +676,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
}
|
||||
});
|
||||
|
||||
it('background true color grey invisible', async () => {
|
||||
itWebgl('background true color grey invisible', async () => {
|
||||
let data = '';
|
||||
for (let y = 0; y < 16; y++) {
|
||||
for (let x = 0; x < 16; x++) {
|
||||
@@ -686,11 +696,13 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
});
|
||||
|
||||
describe('minimumContrastRatio', async () => {
|
||||
before(async () => setupBrowser());
|
||||
after(async () => browser.close());
|
||||
beforeEach(async () => page.evaluate(`window.term.reset()`));
|
||||
if (areTestsEnabled) {
|
||||
before(async () => setupBrowser());
|
||||
after(async () => browser.close());
|
||||
beforeEach(async () => page.evaluate(`window.term.reset()`));
|
||||
}
|
||||
|
||||
it('should adjust 0-15 colors on black background', async () => {
|
||||
itWebgl('should adjust 0-15 colors on black background', async () => {
|
||||
const theme: ITheme = {
|
||||
black: '#2e3436',
|
||||
red: '#cc0000',
|
||||
@@ -757,7 +769,7 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
await pollFor(page, () => getCellColor(8, 2), [0xee, 0xee, 0xec, 255]);
|
||||
});
|
||||
|
||||
it('should adjust 0-15 colors on white background', async () => {
|
||||
itWebgl('should adjust 0-15 colors on white background', async () => {
|
||||
const theme: ITheme = {
|
||||
background: '#ffffff',
|
||||
black: '#2e3436',
|
||||
@@ -826,11 +838,13 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
});
|
||||
|
||||
describe('selection', async () => {
|
||||
before(async () => setupBrowser());
|
||||
after(async () => browser.close());
|
||||
beforeEach(async () => page.evaluate(`window.term.reset()`));
|
||||
if (areTestsEnabled) {
|
||||
before(async () => setupBrowser());
|
||||
after(async () => browser.close());
|
||||
beforeEach(async () => page.evaluate(`window.term.reset()`));
|
||||
}
|
||||
|
||||
it('should resolve the inverse foreground color based on the original background color, not the selection', async () => {
|
||||
itWebgl('should resolve the inverse foreground color based on the original background color, not the selection', async () => {
|
||||
const theme: ITheme = {
|
||||
foreground: '#FF0000',
|
||||
background: '#00FF00',
|
||||
@@ -850,10 +864,13 @@ describe('WebGL Renderer Integration Tests', function(): void {
|
||||
});
|
||||
|
||||
describe('allowTransparency', async () => {
|
||||
before(async () => setupBrowser({ rendererType: 'dom', allowTransparency: true }));
|
||||
after(async () => browser.close());
|
||||
beforeEach(async () => page.evaluate(`window.term.reset()`));
|
||||
it('transparent background inverse', async () => {
|
||||
if (areTestsEnabled) {
|
||||
before(async () => setupBrowser({ rendererType: 'dom', allowTransparency: true }));
|
||||
after(async () => browser.close());
|
||||
beforeEach(async () => page.evaluate(`window.term.reset()`));
|
||||
}
|
||||
|
||||
itWebgl('transparent background inverse', async () => {
|
||||
const theme: ITheme = {
|
||||
background: '#ff000080'
|
||||
};
|
||||
@@ -881,12 +898,13 @@ async function getCellColor(col: number, row: number): Promise<number[]> {
|
||||
}
|
||||
|
||||
async function setupBrowser(options: ITerminalOptions = { rendererType: 'dom' }): Promise<void> {
|
||||
browser = await puppeteer.launch({
|
||||
const browserType = getBrowserType();
|
||||
browser = await browserType.launch({
|
||||
headless: process.argv.indexOf('--headless') !== -1,
|
||||
args: [`--window-size=${width},${height}`, `--no-sandbox`]
|
||||
});
|
||||
page = (await browser.pages())[0];
|
||||
await page.setViewport({ width, height });
|
||||
page = await (await browser.newContext()).newPage();
|
||||
await page.setViewportSize({ width, height });
|
||||
await page.goto(APP);
|
||||
await openTerminal(page, options);
|
||||
await page.evaluate(`
|
||||
|
||||
@@ -81,7 +81,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
||||
};
|
||||
this._gl = this._canvas.getContext('webgl2', contextAttributes) as IWebGL2RenderingContext;
|
||||
if (!this._gl) {
|
||||
throw new Error('WebGL2 not supported');
|
||||
throw new Error('WebGL2 not supported ' + this._gl);
|
||||
}
|
||||
this._core.screenElement.appendChild(this._canvas);
|
||||
|
||||
|
||||
+27
-19
@@ -7,12 +7,10 @@ jobs:
|
||||
- job: Linux
|
||||
pool:
|
||||
vmImage: 'ubuntu-16.04'
|
||||
variables:
|
||||
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1
|
||||
steps:
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: '8.x'
|
||||
versionSpec: '10.x'
|
||||
displayName: 'Install Node.js'
|
||||
- task: YarnInstaller@3
|
||||
inputs:
|
||||
@@ -42,12 +40,10 @@ jobs:
|
||||
- job: macOS
|
||||
pool:
|
||||
vmImage: 'xcode9-macos10.13'
|
||||
variables:
|
||||
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1
|
||||
steps:
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: '8.x'
|
||||
versionSpec: '10.x'
|
||||
displayName: 'Install Node.js'
|
||||
- task: CacheBeta@1
|
||||
inputs:
|
||||
@@ -64,12 +60,10 @@ jobs:
|
||||
- job: Windows
|
||||
pool:
|
||||
vmImage: 'vs2017-win2016'
|
||||
variables:
|
||||
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1
|
||||
steps:
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: '8.x'
|
||||
versionSpec: '10.x'
|
||||
displayName: 'Install Node.js'
|
||||
- task: CacheBeta@1
|
||||
inputs:
|
||||
@@ -89,35 +83,51 @@ jobs:
|
||||
steps:
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: '8.x'
|
||||
versionSpec: '10.x'
|
||||
displayName: 'Install Node.js'
|
||||
- task: YarnInstaller@3
|
||||
inputs:
|
||||
versionSpec: '1.x'
|
||||
displayName: 'Install Yarn'
|
||||
- task: CacheBeta@1
|
||||
inputs:
|
||||
key: yarn2 | $(Agent.OS) | yarn.lock
|
||||
path: node_modules
|
||||
displayName: Cache node modules
|
||||
- script: yarn --frozen-lockfile
|
||||
displayName: 'Install dependencies and build'
|
||||
- script: |
|
||||
yarn start &
|
||||
sleep 10
|
||||
yarn test-api --headless --forbid-only
|
||||
displayName: 'Linux Integration tests'
|
||||
displayName: 'Start test server'
|
||||
- script: yarn test-api-chromium --headless --forbid-only
|
||||
displayName: 'Integration tests (Chromium)'
|
||||
|
||||
- job: macOS_IntegrationTests
|
||||
pool:
|
||||
vmImage: 'xcode9-macos10.13'
|
||||
vmImage: 'macOS-10.15'
|
||||
steps:
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: '8.x'
|
||||
versionSpec: '10.x'
|
||||
displayName: 'Install Node.js'
|
||||
- task: CacheBeta@1
|
||||
inputs:
|
||||
key: yarn2 | $(Agent.OS) | yarn.lock
|
||||
path: node_modules
|
||||
displayName: Cache node modules
|
||||
- script: yarn --frozen-lockfile
|
||||
displayName: 'Install dependencies and build'
|
||||
- script: |
|
||||
yarn start &
|
||||
sleep 10
|
||||
yarn test-api --headless --forbid-only
|
||||
displayName: 'MacOS Integration tests'
|
||||
displayName: 'Start test server'
|
||||
- script: yarn test-api-chromium --headless --forbid-only
|
||||
displayName: 'Integration tests (Chromium)'
|
||||
- script: yarn test-api-firefox --headless --forbid-only
|
||||
displayName: 'Integration tests (Firefox)'
|
||||
- script: yarn test-api-webkit --headless --forbid-only
|
||||
displayName: 'Integration tests (Webkit)'
|
||||
|
||||
- job: Release
|
||||
dependsOn:
|
||||
@@ -129,12 +139,10 @@ jobs:
|
||||
condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['FORCE_RELEASE'], 'true')))
|
||||
pool:
|
||||
vmImage: 'ubuntu-16.04'
|
||||
variables:
|
||||
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1
|
||||
steps:
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: '8.x'
|
||||
versionSpec: '10.x'
|
||||
displayName: 'Install Node.js'
|
||||
- task: YarnInstaller@3
|
||||
inputs:
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Copyright (c) 2020 The xterm.js authors. All rights reserved.
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
const playwright = require('playwright-core');
|
||||
const fs = require('fs');
|
||||
|
||||
// Default to chromium
|
||||
let browserType = playwright['chromium'];
|
||||
const index = process.argv.indexOf('--browser');
|
||||
if (index !== -1 && process.argv.length > index + 1 && typeof process.argv[index + 1] === 'string') {
|
||||
const string = process.argv[index + 1];
|
||||
if (string === 'firefox' || string === 'webkit') {
|
||||
browserType = playwright[string];
|
||||
}
|
||||
}
|
||||
|
||||
const exists = fs.existsSync(browserType.executablePath());
|
||||
if (!exists) {
|
||||
console.log(`Downloading ${browserType.name()}`);
|
||||
browserType.downloadBrowserIfNeeded().then(() => process.exit(0));
|
||||
}
|
||||
+9
-3
@@ -14,7 +14,13 @@
|
||||
"lint": "tslint 'src/**/*.ts' 'addons/*/src/**/*.ts'",
|
||||
"test": "npm run test-unit",
|
||||
"posttest": "npm run lint",
|
||||
"test-api": "mocha \"**/*.api.js\"",
|
||||
"test-api": "npm run test-api-chromium",
|
||||
"test-api-chromium": "mocha \"**/*.api.js\" --browser chromium --timeout 20000",
|
||||
"test-api-firefox": "mocha \"**/*.api.js\" --browser firefox --timeout 20000",
|
||||
"test-api-webkit": "mocha \"**/*.api.js\" --browser webkit --timeout 20000",
|
||||
"pretest-api-chromium": "node ./bin/download_browser.js --browser chromium",
|
||||
"pretest-api-firefox": "node ./bin/download_browser.js --browser firefox",
|
||||
"pretest-api-webkit": "node ./bin/download_browser.js --browser webkit",
|
||||
"test-unit": "node ./bin/test.js",
|
||||
"test-unit-coverage": "node ./bin/test.js --coverage",
|
||||
"build": "tsc -b ./tsconfig.all.json",
|
||||
@@ -31,12 +37,12 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/chai": "^3.4.34",
|
||||
"@types/debug": "^4.1.5",
|
||||
"@types/deep-equal": "^1.0.1",
|
||||
"@types/glob": "^5.0.35",
|
||||
"@types/jsdom": "11.0.1",
|
||||
"@types/mocha": "^2.2.33",
|
||||
"@types/node": "6.0.108",
|
||||
"@types/puppeteer": "^1.12.4",
|
||||
"@types/utf8": "^2.1.6",
|
||||
"@types/webpack": "^4.4.11",
|
||||
"@types/ws": "^6.0.1",
|
||||
@@ -50,7 +56,7 @@
|
||||
"mustache": "^3.0.1",
|
||||
"node-pty": "^0.9.0",
|
||||
"nyc": "13",
|
||||
"puppeteer": "^1.15.0",
|
||||
"playwright-core": "^0.11.1",
|
||||
"source-map-loader": "^0.2.4",
|
||||
"ts-loader": "^6.0.4",
|
||||
"tslint": "^5.18.0",
|
||||
|
||||
@@ -3,24 +3,25 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import * as puppeteer from 'puppeteer';
|
||||
import { pollFor, openTerminal } from './TestUtils';
|
||||
import { pollFor, openTerminal, getBrowserType } from './TestUtils';
|
||||
import { Browser, Page } from 'playwright-core';
|
||||
|
||||
const APP = 'http://127.0.0.1:3000/test';
|
||||
|
||||
let browser: puppeteer.Browser;
|
||||
let page: puppeteer.Page;
|
||||
let browser: Browser;
|
||||
let page: Page;
|
||||
const width = 800;
|
||||
const height = 600;
|
||||
|
||||
describe('CharWidth Integration Tests', function(): void {
|
||||
before(async function(): Promise<any> {
|
||||
browser = await puppeteer.launch({
|
||||
const browserType = getBrowserType();
|
||||
browser = await browserType.launch({
|
||||
headless: process.argv.indexOf('--headless') !== -1,
|
||||
args: [`--window-size=${width},${height}`, `--no-sandbox`]
|
||||
});
|
||||
page = (await browser.pages())[0];
|
||||
await page.setViewport({ width, height });
|
||||
page = await (await browser.newContext()).newPage();
|
||||
await page.setViewportSize({ width, height });
|
||||
await page.goto(APP);
|
||||
await openTerminal(page, { rows: 5, cols: 30 });
|
||||
});
|
||||
|
||||
@@ -3,25 +3,30 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import * as puppeteer from 'puppeteer';
|
||||
import { assert } from 'chai';
|
||||
import { pollFor, openTerminal } from './TestUtils';
|
||||
import { pollFor, openTerminal, getBrowserType } from './TestUtils';
|
||||
import { Browser, Page } from 'playwright-core';
|
||||
import { IRenderDimensions } from 'browser/renderer/Types';
|
||||
|
||||
const APP = 'http://127.0.0.1:3000/test';
|
||||
|
||||
let browser: puppeteer.Browser;
|
||||
let page: puppeteer.Page;
|
||||
let browser: Browser;
|
||||
let page: Page;
|
||||
const width = 800;
|
||||
const height = 600;
|
||||
|
||||
let isChromium = false;
|
||||
|
||||
describe('InputHandler Integration Tests', function(): void {
|
||||
before(async function(): Promise<any> {
|
||||
browser = await puppeteer.launch({
|
||||
const browserType = getBrowserType();
|
||||
isChromium = browserType.name() === 'chromium';
|
||||
browser = await browserType.launch({
|
||||
headless: process.argv.indexOf('--headless') !== -1,
|
||||
args: [`--window-size=${width},${height}`, `--no-sandbox`]
|
||||
});
|
||||
page = (await browser.pages())[0];
|
||||
await page.setViewport({ width, height });
|
||||
page = await (await browser.newContext()).newPage();
|
||||
await page.setViewportSize({ width, height });
|
||||
await page.goto(APP);
|
||||
await openTerminal(page);
|
||||
});
|
||||
@@ -260,17 +265,17 @@ describe('InputHandler Integration Tests', function(): void {
|
||||
describe('SM: Set Mode', () => {
|
||||
describe('CSI ? Pm h', () => {
|
||||
it('Pm = 1003, Set Use All Motion (any event) Mouse Tracking', async () => {
|
||||
const coords = await page.evaluate(`
|
||||
(function() {
|
||||
const rect = window.term.element.getBoundingClientRect();
|
||||
return {left: rect.left, top: rect.top, bottom: rect.bottom, right: rect.right};
|
||||
})();
|
||||
const coords: { left: number, top: number, bottom: number, right: number } = await page.evaluate(`
|
||||
(function() {
|
||||
const rect = window.term.element.getBoundingClientRect();
|
||||
return { left: rect.left, top: rect.top, bottom: rect.bottom, right: rect.right };
|
||||
})();
|
||||
`);
|
||||
// Click and drag and ensure there is a selection
|
||||
await page.mouse.click((coords.left + coords.right) / 2, (coords.top + coords.bottom) / 2);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move((coords.left + coords.right) / 2, (coords.top + coords.bottom) / 4);
|
||||
assert.ok(await page.evaluate(`window.term.getSelection().length`) > 0, 'mouse events are off so there should be a selection');
|
||||
assert.ok(await page.evaluate(`window.term.getSelection().length`) as number > 0, 'mouse events are off so there should be a selection');
|
||||
await page.mouse.up();
|
||||
// Clear selection
|
||||
await page.mouse.click((coords.left + coords.right) / 2, (coords.top + coords.bottom) / 2);
|
||||
@@ -285,9 +290,9 @@ describe('InputHandler Integration Tests', function(): void {
|
||||
await pollFor(page, () => page.evaluate(`window.term.getSelection().length`), 0);
|
||||
await page.mouse.up();
|
||||
});
|
||||
it('Pm = 2004, Set bracketed paste mode', async function(): Promise<any> {
|
||||
(isChromium ? it : it.skip)('Pm = 2004, Set bracketed paste mode', async function(): Promise<any> {
|
||||
await pollFor(page, () => simulatePaste('foo'), 'foo');
|
||||
await page.evaluate(`window.term.write('\x1b[?2004h')`);
|
||||
await page.evaluate(`window.term.write('\x1b[?2004h')`)
|
||||
await pollFor(page, () => simulatePaste('bar'), '\x1b[200~bar\x1b[201~');
|
||||
await page.evaluate(`window.term.write('\x1b[?2004l')`);
|
||||
await pollFor(page, () => simulatePaste('baz'), 'baz');
|
||||
@@ -298,86 +303,86 @@ describe('InputHandler Integration Tests', function(): void {
|
||||
it('REP: Repeat preceding character, ECMA48 - CSI Ps b', async function(): Promise<any> {
|
||||
// default to 1
|
||||
await page.evaluate(`
|
||||
window.term.resize(10, 10);
|
||||
window.term.write('#\x1b[b');
|
||||
window.term.writeln('');
|
||||
window.term.write('#\x1b[0b');
|
||||
window.term.writeln('');
|
||||
window.term.write('#\x1b[1b');
|
||||
window.term.writeln('');
|
||||
window.term.write('#\x1b[5b');
|
||||
`);
|
||||
window.term.resize(10, 10);
|
||||
window.term.write('#\x1b[b');
|
||||
window.term.writeln('');
|
||||
window.term.write('#\x1b[0b');
|
||||
window.term.writeln('');
|
||||
window.term.write('#\x1b[1b');
|
||||
window.term.writeln('');
|
||||
window.term.write('#\x1b[5b');
|
||||
`);
|
||||
await pollFor(page, () => getLinesAsArray(4), ['##', '##', '##', '######']);
|
||||
await pollFor(page, () => getCursor(), { col: 6, row: 3 });
|
||||
// should not repeat on fullwidth chars
|
||||
await page.evaluate(`
|
||||
window.term.reset();
|
||||
window.term.write('¥\x1b[10b');
|
||||
`);
|
||||
window.term.reset();
|
||||
window.term.write('¥\x1b[10b');
|
||||
`);
|
||||
await pollFor(page, () => getLinesAsArray(1), ['¥']);
|
||||
// should repeat only base char of combining
|
||||
await page.evaluate(`
|
||||
window.term.reset();
|
||||
window.term.write('e\u0301\x1b[5b');
|
||||
`);
|
||||
window.term.reset();
|
||||
window.term.write('e\u0301\x1b[5b');
|
||||
`);
|
||||
await pollFor(page, () => getLinesAsArray(1), ['e\u0301eeeee']);
|
||||
// should wrap correctly
|
||||
await page.evaluate(`
|
||||
window.term.reset();
|
||||
window.term.write('#\x1b[15b');
|
||||
`);
|
||||
window.term.reset();
|
||||
window.term.write('#\x1b[15b');
|
||||
`);
|
||||
await pollFor(page, () => getLinesAsArray(2), ['##########', '######']);
|
||||
await page.evaluate(`
|
||||
window.term.reset();
|
||||
window.term.write('\x1b[?7l'); // disable wrap around
|
||||
window.term.write('#\x1b[15b');
|
||||
`);
|
||||
window.term.reset();
|
||||
window.term.write('\x1b[?7l'); // disable wrap around
|
||||
window.term.write('#\x1b[15b');
|
||||
`);
|
||||
await pollFor(page, () => getLinesAsArray(2), ['##########', '']);
|
||||
// any successful sequence should reset REP
|
||||
await page.evaluate(`
|
||||
window.term.reset();
|
||||
window.term.write('\x1b[?7h'); // re-enable wrap around
|
||||
window.term.write('#\\n\x1b[3b');
|
||||
window.term.write('#\\r\x1b[3b');
|
||||
window.term.writeln('');
|
||||
window.term.write('abcdefg\x1b[3D\x1b[10b#\x1b[3b');
|
||||
`);
|
||||
window.term.reset();
|
||||
window.term.write('\x1b[?7h'); // re-enable wrap around
|
||||
window.term.write('#\\n\x1b[3b');
|
||||
window.term.write('#\\r\x1b[3b');
|
||||
window.term.writeln('');
|
||||
window.term.write('abcdefg\x1b[3D\x1b[10b#\x1b[3b');
|
||||
`);
|
||||
await pollFor(page, () => getLinesAsArray(3), ['#', ' #', 'abcd####']);
|
||||
});
|
||||
|
||||
describe('Window Options - CSI Ps ; Ps ; Ps t', () => {
|
||||
it('should be disabled by default', async function(): Promise<void> {
|
||||
it('should be disabled by default', async function(): Promise<any> {
|
||||
await page.evaluate(`(() => {
|
||||
window._stack = [];
|
||||
const _h = window.term.onData(data => window._stack.push(data));
|
||||
window.term.write('\x1b[14t');
|
||||
window.term.write('\x1b[16t');
|
||||
window.term.write('\x1b[18t');
|
||||
window.term.write('\x1b[20t');
|
||||
window.term.write('\x1b[21t');
|
||||
return new Promise((r) => window.term.write('', () => { _h.dispose(); r(); }));
|
||||
})()`);
|
||||
window._stack = [];
|
||||
const _h = window.term.onData(data => window._stack.push(data));
|
||||
window.term.write('\x1b[14t');
|
||||
window.term.write('\x1b[16t');
|
||||
window.term.write('\x1b[18t');
|
||||
window.term.write('\x1b[20t');
|
||||
window.term.write('\x1b[21t');
|
||||
return new Promise((r) => window.term.write('', () => { _h.dispose(); r(); }));
|
||||
})()`);
|
||||
await pollFor(page, async () => await page.evaluate(`(() => _stack)()`), []);
|
||||
});
|
||||
it('14 - GetWinSizePixels', async function(): Promise<void> {
|
||||
await page.evaluate(`window.term.setOption('windowOptions', {getWinSizePixels: true});`);
|
||||
it('14 - GetWinSizePixels', async function(): Promise<any> {
|
||||
await page.evaluate(`window.term.setOption('windowOptions', { getWinSizePixels: true }); `);
|
||||
await page.evaluate(`(() => {
|
||||
window._stack = [];
|
||||
const _h = window.term.onData(data => window._stack.push(data));
|
||||
window.term.write('\x1b[14t');
|
||||
return new Promise((r) => window.term.write('', () => { _h.dispose(); r(); }));
|
||||
})()`);
|
||||
window._stack = [];
|
||||
const _h = window.term.onData(data => window._stack.push(data));
|
||||
window.term.write('\x1b[14t');
|
||||
return new Promise((r) => window.term.write('', () => { _h.dispose(); r(); }));
|
||||
})()`);
|
||||
const d = await getDimensions();
|
||||
await pollFor(page, async () => await page.evaluate(`(() => _stack)()`), [`\x1b[4;${d.height};${d.width}t`]);
|
||||
});
|
||||
it('16 - GetCellSizePixels', async function(): Promise<void> {
|
||||
await page.evaluate(`window.term.setOption('windowOptions', {getCellSizePixels: true});`);
|
||||
it('16 - GetCellSizePixels', async function(): Promise<any> {
|
||||
await page.evaluate(`window.term.setOption('windowOptions', { getCellSizePixels: true }); `);
|
||||
await page.evaluate(`(() => {
|
||||
window._stack = [];
|
||||
const _h = window.term.onData(data => window._stack.push(data));
|
||||
window.term.write('\x1b[16t');
|
||||
return new Promise((r) => window.term.write('', () => { _h.dispose(); r(); }));
|
||||
})()`);
|
||||
window._stack = [];
|
||||
const _h = window.term.onData(data => window._stack.push(data));
|
||||
window.term.write('\x1b[16t');
|
||||
return new Promise((r) => window.term.write('', () => { _h.dispose(); r(); }));
|
||||
})()`);
|
||||
const d = await getDimensions();
|
||||
await pollFor(page, async () => await page.evaluate(`(() => _stack)()`), [`\x1b[6;${d.cellHeight};${d.cellWidth}t`]);
|
||||
});
|
||||
@@ -391,11 +396,11 @@ describe('InputHandler Integration Tests', function(): void {
|
||||
window.term.resize(10, 2);
|
||||
window.term.write('1\\n\\r2\\n\\r3\\n\\r4\\n\\r5');
|
||||
window.term.write('\\x1b7\\x1b[?47h');
|
||||
`);
|
||||
`);
|
||||
await page.evaluate(`
|
||||
window.term.resize(10, 4);
|
||||
window.term.write('\\x1b[?47l\\x1b8');
|
||||
`);
|
||||
`);
|
||||
await pollFor(page, () => getCursor(), { col: 1, row: 3 });
|
||||
});
|
||||
});
|
||||
@@ -405,7 +410,7 @@ describe('InputHandler Integration Tests', function(): void {
|
||||
async function getLinesAsArray(count: number, start: number = 0): Promise<string[]> {
|
||||
let text = '';
|
||||
for (let i = start; i < start + count; i++) {
|
||||
text += `window.term.buffer.getLine(${i}).translateToString(true),`;
|
||||
text += `window.term.buffer.getLine(${i}).translateToString(true), `;
|
||||
}
|
||||
return await page.evaluate(`[${text}]`);
|
||||
}
|
||||
@@ -413,26 +418,26 @@ async function getLinesAsArray(count: number, start: number = 0): Promise<string
|
||||
async function simulatePaste(text: string): Promise<string> {
|
||||
const id = Math.floor(Math.random() * 1000000);
|
||||
await page.evaluate(`
|
||||
(function () {
|
||||
window.term.onData(e => window.result_${id} = e);
|
||||
const clipboardData = new DataTransfer();
|
||||
clipboardData.setData('text/plain', '${text}');
|
||||
window.term.textarea.dispatchEvent(new ClipboardEvent('paste', { clipboardData }));
|
||||
})();
|
||||
`);
|
||||
return await page.evaluate(`window.result_${id}`);
|
||||
(function() {
|
||||
window.term.onData(e => window.result_${id} = e);
|
||||
const clipboardData = new DataTransfer();
|
||||
clipboardData.setData('text/plain', '${text}');
|
||||
window.term.textarea.dispatchEvent(new ClipboardEvent('paste', { clipboardData }));
|
||||
})();
|
||||
`);
|
||||
return await page.evaluate(`window.result_${id} `);
|
||||
}
|
||||
|
||||
async function getCursor(): Promise<{ col: number, row: number }> {
|
||||
return page.evaluate(`
|
||||
(function() {
|
||||
return {col: term.buffer.cursorX, row: term.buffer.cursorY};
|
||||
})();
|
||||
`);
|
||||
(function() {
|
||||
return { col: term.buffer.cursorX, row: term.buffer.cursorY };
|
||||
})();
|
||||
`);
|
||||
}
|
||||
|
||||
async function getDimensions(): Promise<any> {
|
||||
const dim = await page.evaluate(`term._core._renderService.dimensions`);
|
||||
const dim: IRenderDimensions = await page.evaluate(`term._core._renderService.dimensions`);
|
||||
return {
|
||||
cellWidth: dim.actualCellWidth.toFixed(0),
|
||||
cellHeight: dim.actualCellHeight.toFixed(0),
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import * as puppeteer from 'puppeteer';
|
||||
import { pollFor, writeSync, openTerminal } from './TestUtils';
|
||||
import { pollFor, writeSync, openTerminal, getBrowserType } from './TestUtils';
|
||||
import { Browser, Page } from 'playwright-core';
|
||||
|
||||
const APP = 'http://127.0.0.1:3000/test';
|
||||
|
||||
let browser: puppeteer.Browser;
|
||||
let page: puppeteer.Page;
|
||||
let browser: Browser;
|
||||
let page: Page;
|
||||
// adjusted to work inside devcontainer
|
||||
// see https://github.com/xtermjs/xterm.js/issues/2379
|
||||
const width = 1280;
|
||||
@@ -21,6 +21,9 @@ const fontSize = 6;
|
||||
const cols = 260;
|
||||
const rows = 50;
|
||||
|
||||
// Wheel events are hacked using private API that is only available in Chromium
|
||||
const isChromium = false
|
||||
|
||||
// for some reason shift gets not caught by selection manager on macos
|
||||
const noShift = process.platform === 'darwin' ? false : true;
|
||||
|
||||
@@ -35,7 +38,7 @@ async function resetMouseModes(): Promise<void> {
|
||||
}
|
||||
|
||||
async function getReports(encoding: string): Promise<any[]> {
|
||||
const reports = await page.evaluate(`window.calls`);
|
||||
const reports: any = await page.evaluate(`window.calls`);
|
||||
await page.evaluate(`window.calls = [];`);
|
||||
return reports.map((report: number[]) => parseReport(encoding, report));
|
||||
}
|
||||
@@ -44,7 +47,7 @@ async function getReports(encoding: string): Promise<any[]> {
|
||||
// always adds +2 in each direction so we dont end up in the wrong cell
|
||||
// due to rounding issues
|
||||
async function cellPos(col: number, row: number): Promise<number[]> {
|
||||
const coords = await page.evaluate(`
|
||||
const coords: any = await page.evaluate(`
|
||||
(function() {
|
||||
const rect = window.term.element.getBoundingClientRect();
|
||||
const dim = term._core._renderService.dimensions;
|
||||
@@ -55,7 +58,7 @@ async function cellPos(col: number, row: number): Promise<number[]> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Patched puppeteer functions.
|
||||
* Patched playwright functions.
|
||||
* This is needed to:
|
||||
* - translate cell positions into pixel positions
|
||||
* - allow modifiers to be set
|
||||
@@ -73,27 +76,44 @@ async function mouseUp(button: 'left' | 'right' | 'middle' | undefined): Promise
|
||||
}
|
||||
async function wheelUp(): Promise<void> {
|
||||
const self = (page.mouse as any);
|
||||
return await self._client.send('Input.dispatchMouseEvent', {
|
||||
return await self._raw._client.send('Input.dispatchMouseEvent', {
|
||||
type: 'mouseWheel',
|
||||
x: self._x,
|
||||
y: self._y,
|
||||
deltaX: 0,
|
||||
deltaY: -10,
|
||||
modifiers: self._keyboard._modifiers
|
||||
modifiers: toModifiersMask(page.keyboard._modifiers())
|
||||
});
|
||||
}
|
||||
async function wheelDown(): Promise<void> {
|
||||
const self = (page.mouse as any);
|
||||
return await self._client.send('Input.dispatchMouseEvent', {
|
||||
return await self._raw._client.send('Input.dispatchMouseEvent', {
|
||||
type: 'mouseWheel',
|
||||
x: self._x,
|
||||
y: self._y,
|
||||
deltaX: 0,
|
||||
deltaY: 10,
|
||||
modifiers: self._keyboard._modifiers
|
||||
modifiers: toModifiersMask(page.keyboard._modifiers())
|
||||
});
|
||||
}
|
||||
|
||||
function toModifiersMask(modifiers: Set<String>): number {
|
||||
let mask = 0;
|
||||
if (modifiers.has('Alt')) {
|
||||
mask |= 1;
|
||||
}
|
||||
if (modifiers.has('Control')) {
|
||||
mask |= 2;
|
||||
}
|
||||
if (modifiers.has('Meta')) {
|
||||
mask |= 4;
|
||||
}
|
||||
if (modifiers.has('Shift')) {
|
||||
mask |= 8;
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
// button definitions
|
||||
const buttons: { [key: string]: number } = {
|
||||
'<none>': -1,
|
||||
@@ -187,14 +207,18 @@ function parseReport(encoding: string, msg: number[]): { state: any; row: number
|
||||
/**
|
||||
* Mouse tracking tests.
|
||||
*/
|
||||
describe('Mouse Tracking Tests', () => {
|
||||
describe('Mouse Tracking Tests', async () => {
|
||||
const browserType = getBrowserType();
|
||||
browserType.name() === 'chromium';
|
||||
const itMouse = isChromium ? it : it.skip;
|
||||
|
||||
before(async function(): Promise<void> {
|
||||
browser = await puppeteer.launch({
|
||||
browser = await browserType.launch({
|
||||
headless: process.argv.indexOf('--headless') !== -1,
|
||||
args: [`--window-size=${width},${height}`, `--no-sandbox`]
|
||||
});
|
||||
page = (await browser.pages())[0];
|
||||
await page.setViewport({ width, height });
|
||||
page = await (await browser.newContext()).newPage();
|
||||
await page.setViewportSize({ width, height });
|
||||
});
|
||||
|
||||
after(async () => browser.close());
|
||||
@@ -223,7 +247,7 @@ describe('Mouse Tracking Tests', () => {
|
||||
* - no move
|
||||
* - no modifiers
|
||||
*/
|
||||
it('default encoding', async () => {
|
||||
itMouse('default encoding', async () => {
|
||||
const encoding = 'DEFAULT';
|
||||
await resetMouseModes();
|
||||
await mouseMove(0, 0);
|
||||
@@ -350,7 +374,7 @@ describe('Mouse Tracking Tests', () => {
|
||||
// await page.keyboard.up('Shift');
|
||||
await pollFor(page, () => getReports(encoding), [{ col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }]);
|
||||
});
|
||||
it('SGR encoding', async () => {
|
||||
itMouse('SGR encoding', async () => {
|
||||
const encoding = 'SGR';
|
||||
await resetMouseModes();
|
||||
await mouseMove(0, 0);
|
||||
@@ -477,7 +501,7 @@ describe('Mouse Tracking Tests', () => {
|
||||
* - no move
|
||||
* - all modifiers
|
||||
*/
|
||||
it('default encoding', async () => {
|
||||
itMouse('default encoding', async () => {
|
||||
const encoding = 'DEFAULT';
|
||||
await resetMouseModes();
|
||||
await mouseMove(0, 0);
|
||||
@@ -628,7 +652,7 @@ describe('Mouse Tracking Tests', () => {
|
||||
{ col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: true, shift: false, meta: true } } }
|
||||
]);
|
||||
});
|
||||
it('SGR encoding', async () => {
|
||||
itMouse('SGR encoding', async () => {
|
||||
const encoding = 'SGR';
|
||||
await resetMouseModes();
|
||||
await mouseMove(0, 0);
|
||||
@@ -786,7 +810,7 @@ describe('Mouse Tracking Tests', () => {
|
||||
* - all modifiers
|
||||
* Note: tmux runs this with SGR encoding.
|
||||
*/
|
||||
it('default encoding', async () => {
|
||||
itMouse('default encoding', async () => {
|
||||
const encoding = 'DEFAULT';
|
||||
await resetMouseModes();
|
||||
await mouseMove(0, 0);
|
||||
@@ -942,7 +966,7 @@ describe('Mouse Tracking Tests', () => {
|
||||
{ col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: true, shift: false, meta: true } } }
|
||||
]);
|
||||
});
|
||||
it('SGR encoding', async () => {
|
||||
itMouse('SGR encoding', async () => {
|
||||
const encoding = 'SGR';
|
||||
await resetMouseModes();
|
||||
await mouseMove(0, 0);
|
||||
@@ -1104,7 +1128,7 @@ describe('Mouse Tracking Tests', () => {
|
||||
* - all events (press, release, wheel, move)
|
||||
* - all modifiers
|
||||
*/
|
||||
it('default encoding', async () => {
|
||||
itMouse('default encoding', async () => {
|
||||
const encoding = 'DEFAULT';
|
||||
await resetMouseModes();
|
||||
await mouseMove(0, 0);
|
||||
@@ -1264,7 +1288,7 @@ describe('Mouse Tracking Tests', () => {
|
||||
{ col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: true, shift: false, meta: true } } }
|
||||
]);
|
||||
});
|
||||
it('SGR encoding', async () => {
|
||||
itMouse('SGR encoding', async () => {
|
||||
const encoding = 'SGR';
|
||||
await resetMouseModes();
|
||||
await mouseMove(0, 0);
|
||||
@@ -1428,7 +1452,7 @@ describe('Mouse Tracking Tests', () => {
|
||||
});
|
||||
/**
|
||||
* move tests with multiple buttons pressed:
|
||||
* currently not possible due to a limitation of the puppeteer mouse interface
|
||||
* currently not possible due to a limitation of the playwright mouse interface
|
||||
* (saves only the last one pressed)
|
||||
*/
|
||||
});
|
||||
|
||||
@@ -3,25 +3,26 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import * as puppeteer from 'puppeteer';
|
||||
import { assert } from 'chai';
|
||||
import { writeSync, openTerminal } from './TestUtils';
|
||||
import { writeSync, openTerminal, getBrowserType } from './TestUtils';
|
||||
import { Browser, Page } from 'playwright-core';
|
||||
|
||||
const APP = 'http://127.0.0.1:3000/test';
|
||||
|
||||
let browser: puppeteer.Browser;
|
||||
let page: puppeteer.Page;
|
||||
let browser: Browser;
|
||||
let page: Page;
|
||||
const width = 800;
|
||||
const height = 600;
|
||||
|
||||
describe('Parser Integration Tests', function(): void {
|
||||
before(async function(): Promise<any> {
|
||||
browser = await puppeteer.launch({
|
||||
const browserType = getBrowserType();
|
||||
browser = await browserType.launch({
|
||||
headless: process.argv.indexOf('--headless') !== -1,
|
||||
args: [`--window-size=${width},${height}`, `--no-sandbox`]
|
||||
});
|
||||
page = (await browser.pages())[0];
|
||||
await page.setViewport({ width, height });
|
||||
page = await (await browser.newContext()).newPage();
|
||||
await page.setViewportSize({ width, height });
|
||||
await page.goto(APP);
|
||||
await openTerminal(page);
|
||||
});
|
||||
|
||||
@@ -3,25 +3,26 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import * as puppeteer from 'puppeteer';
|
||||
import { assert } from 'chai';
|
||||
import { pollFor, timeout, writeSync, openTerminal } from './TestUtils';
|
||||
import { pollFor, timeout, writeSync, openTerminal, getBrowserType } from './TestUtils';
|
||||
import { Browser, Page } from 'playwright-core';
|
||||
|
||||
const APP = 'http://127.0.0.1:3000/test';
|
||||
|
||||
let browser: puppeteer.Browser;
|
||||
let page: puppeteer.Page;
|
||||
let browser: Browser;
|
||||
let page: Page;
|
||||
const width = 800;
|
||||
const height = 600;
|
||||
|
||||
describe('API Integration Tests', function(): void {
|
||||
before(async () => {
|
||||
browser = await puppeteer.launch({
|
||||
const browserType = getBrowserType();
|
||||
browser = await browserType.launch({
|
||||
headless: process.argv.indexOf('--headless') !== -1,
|
||||
args: [`--window-size=${width},${height}`, `--no-sandbox`]
|
||||
});
|
||||
page = (await browser.pages())[0];
|
||||
await page.setViewport({ width, height });
|
||||
page = await (await browser.newContext()).newPage();
|
||||
await page.setViewportSize({ width, height });
|
||||
});
|
||||
|
||||
after(async () => browser.close());
|
||||
@@ -702,7 +703,7 @@ async function getCellCoordinates(dimensions: IDimensions, col: number, row: num
|
||||
};
|
||||
}
|
||||
|
||||
async function moveMouseCell(page: puppeteer.Page, dimensions: IDimensions, col: number, row: number): Promise<void> {
|
||||
async function moveMouseCell(page: Page, dimensions: IDimensions, col: number, row: number): Promise<void> {
|
||||
const coords = await getCellCoordinates(dimensions, col, row);
|
||||
await page.mouse.move(coords.x, coords.y);
|
||||
}
|
||||
|
||||
+19
-4
@@ -3,11 +3,11 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import * as puppeteer from 'puppeteer';
|
||||
import * as playwright from 'playwright-core';
|
||||
import deepEqual = require('deep-equal');
|
||||
import { ITerminalOptions } from 'xterm';
|
||||
|
||||
export async function pollFor<T>(page: puppeteer.Page, evalOrFn: string | (() => Promise<T>), val: T, preFn?: () => Promise<void>): Promise<void> {
|
||||
export async function pollFor<T>(page: playwright.Page, evalOrFn: string | (() => Promise<T>), val: T, preFn?: () => Promise<void>): Promise<void> {
|
||||
if (preFn) {
|
||||
await preFn();
|
||||
}
|
||||
@@ -19,7 +19,7 @@ export async function pollFor<T>(page: puppeteer.Page, evalOrFn: string | (() =>
|
||||
}
|
||||
}
|
||||
|
||||
export async function writeSync(page: puppeteer.Page, data: string): Promise<void> {
|
||||
export async function writeSync(page: playwright.Page, data: string): Promise<void> {
|
||||
await page.evaluate(`
|
||||
window.ready = false;
|
||||
window.term.write('${data}', () => window.ready = true);
|
||||
@@ -31,7 +31,7 @@ export async function timeout(ms: number): Promise<void> {
|
||||
return new Promise<void>(r => setTimeout(r, ms));
|
||||
}
|
||||
|
||||
export async function openTerminal(page: puppeteer.Page, options: ITerminalOptions = {}): Promise<void> {
|
||||
export async function openTerminal(page: playwright.Page, options: ITerminalOptions = {}): Promise<void> {
|
||||
await page.evaluate(`window.term = new Terminal(${JSON.stringify(options)})`);
|
||||
await page.evaluate(`window.term.open(document.querySelector('#terminal-container'))`);
|
||||
if (options.rendererType === 'dom') {
|
||||
@@ -40,3 +40,18 @@ export async function openTerminal(page: puppeteer.Page, options: ITerminalOptio
|
||||
await page.waitForSelector('.xterm-text-layer');
|
||||
}
|
||||
}
|
||||
|
||||
export function getBrowserType(): playwright.BrowserType {
|
||||
// Default to chromium
|
||||
let browserType: playwright.BrowserType = playwright['chromium'];
|
||||
|
||||
const index = process.argv.indexOf('--browser');
|
||||
if (index !== -1 && process.argv.length > index + 1 && typeof process.argv[index + 1] === 'string') {
|
||||
const string = process.argv[index + 1];
|
||||
if (string === 'firefox' || string === 'webkit') {
|
||||
browserType = playwright[string];
|
||||
}
|
||||
}
|
||||
|
||||
return browserType;
|
||||
}
|
||||
|
||||
+12
-1
@@ -12,11 +12,22 @@
|
||||
"sourceMap": true,
|
||||
"removeComments": true,
|
||||
"pretty": true,
|
||||
"strict": true,
|
||||
"declaration": true,
|
||||
"strict": true
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"browser/*": [
|
||||
"../../src/browser/*"
|
||||
]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"./**/*",
|
||||
"../../typings/xterm.d.ts"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../src/browser"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -130,6 +130,11 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/cli-table/-/cli-table-0.3.0.tgz#f1857156bf5fd115c6a2db260ba0be1f8fc5671c"
|
||||
integrity sha512-QnZUISJJXyhyD6L1e5QwXDV/A5i2W1/gl6D6YMc8u0ncPepbv/B4w3S+izVvtAg60m6h+JP09+Y/0zF2mojlFQ==
|
||||
|
||||
"@types/debug@^4.1.5":
|
||||
version "4.1.5"
|
||||
resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.5.tgz#b14efa8852b7768d898906613c23f688713e02cd"
|
||||
integrity sha512-Q1y515GcOdTHgagaVFhHnIFQ38ygs/kmxdNpvpou+raI9UO3YZcHDngBSYKQklcKlvA7iuQlmIKbzvmxcOE9CQ==
|
||||
|
||||
"@types/deep-equal@^1.0.1":
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/deep-equal/-/deep-equal-1.0.1.tgz#71cfabb247c22bcc16d536111f50c0ed12476b03"
|
||||
@@ -447,6 +452,13 @@ agent-base@^4.1.0:
|
||||
dependencies:
|
||||
es6-promisify "^5.0.0"
|
||||
|
||||
agent-base@^4.3.0:
|
||||
version "4.3.0"
|
||||
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.3.0.tgz#8165f01c436009bccad0b1d122f05ed770efc6ee"
|
||||
integrity sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==
|
||||
dependencies:
|
||||
es6-promisify "^5.0.0"
|
||||
|
||||
ajv-errors@^1.0.0:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/ajv-errors/-/ajv-errors-1.0.1.tgz#f35986aceb91afadec4102fbd85014950cefa64d"
|
||||
@@ -2451,6 +2463,14 @@ https-proxy-agent@^2.2.1:
|
||||
agent-base "^4.1.0"
|
||||
debug "^3.1.0"
|
||||
|
||||
https-proxy-agent@^3.0.0:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-3.0.1.tgz#b8c286433e87602311b01c8ea34413d856a4af81"
|
||||
integrity sha512-+ML2Rbh6DAuee7d07tYGEKOEi2voWPUGan+ExdPbPW6Z3svq+JCqr0v8WmKPOkz1vOVykPCBSuobe7G8GJUtVg==
|
||||
dependencies:
|
||||
agent-base "^4.3.0"
|
||||
debug "^3.1.0"
|
||||
|
||||
iconv-lite@0.4.19:
|
||||
version "0.4.19"
|
||||
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b"
|
||||
@@ -2843,6 +2863,11 @@ javascript-natural-sort@0.7.1:
|
||||
resolved "https://registry.yarnpkg.com/javascript-natural-sort/-/javascript-natural-sort-0.7.1.tgz#f9e2303d4507f6d74355a73664d1440fb5a0ef59"
|
||||
integrity sha1-+eIwPUUH9tdDVac2ZNFED7Wg71k=
|
||||
|
||||
jpeg-js@^0.3.6:
|
||||
version "0.3.6"
|
||||
resolved "https://registry.yarnpkg.com/jpeg-js/-/jpeg-js-0.3.6.tgz#c40382aac9506e7d1f2d856eb02f6c7b2a98b37c"
|
||||
integrity sha512-MUj2XlMB8kpe+8DJUGH/3UJm4XpI8XEgZQ+CiHDeyrGoKPdW/8FJv6ku+3UiYm5Fz3CWaL+iXmD8Q4Ap6aC1Jw==
|
||||
|
||||
js-tokens@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
|
||||
@@ -4001,11 +4026,32 @@ pkg-dir@^3.0.0:
|
||||
dependencies:
|
||||
find-up "^3.0.0"
|
||||
|
||||
playwright-core@^0.11.1:
|
||||
version "0.11.1"
|
||||
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-0.11.1.tgz#b488ad17015a4d0f54db5a5fb6a9d380afea6d5a"
|
||||
integrity sha512-9xsSkXlglvHIAofyNInA1p3beOAOBMWHZgiuH99gX1R8VL6fTXgfWD7pIvt+rJhVMJWMDAyMXRo4TYtYtdspIg==
|
||||
dependencies:
|
||||
debug "^4.1.0"
|
||||
extract-zip "^1.6.6"
|
||||
https-proxy-agent "^3.0.0"
|
||||
jpeg-js "^0.3.6"
|
||||
pngjs "^3.4.0"
|
||||
progress "^2.0.3"
|
||||
proxy-from-env "^1.0.0"
|
||||
rimraf "^3.0.2"
|
||||
uuid "^3.4.0"
|
||||
ws "^6.1.0"
|
||||
|
||||
pn@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/pn/-/pn-1.1.0.tgz#e2f4cef0e219f463c179ab37463e4e1ecdccbafb"
|
||||
integrity sha512-2qHaIQr2VLRFoxe2nASzsV6ef4yOOH+Fi9FBOVH6cqeSgUnoyySPZkxzLuzd+RYOQTRpROA0ztTMqxROKSb/nA==
|
||||
|
||||
pngjs@^3.4.0:
|
||||
version "3.4.0"
|
||||
resolved "https://registry.yarnpkg.com/pngjs/-/pngjs-3.4.0.tgz#99ca7d725965fb655814eaf65f38f12bbdbf555f"
|
||||
integrity sha512-NCrCHhWmnQklfH4MtJMRjZ2a8c80qXeMlQMv2uVp9ISJMTt562SbGd6n2oq0PaPgKm7Z6pL9E2UlLIhC+SHL3w==
|
||||
|
||||
posix-character-classes@^0.1.0:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
|
||||
@@ -4026,7 +4072,7 @@ process@^0.11.10:
|
||||
resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182"
|
||||
integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI=
|
||||
|
||||
progress@^2.0.1:
|
||||
progress@^2.0.1, progress@^2.0.3:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8"
|
||||
integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==
|
||||
@@ -4116,20 +4162,6 @@ punycode@^2.1.0:
|
||||
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
|
||||
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==
|
||||
|
||||
puppeteer@^1.15.0:
|
||||
version "1.15.0"
|
||||
resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-1.15.0.tgz#1680fac13e51f609143149a5b7fa99eec392b34f"
|
||||
integrity sha512-D2y5kwA9SsYkNUmcBzu9WZ4V1SGHiQTmgvDZSx6sRYFsgV25IebL4V6FaHjF6MbwLK9C6f3G3pmck9qmwM8H3w==
|
||||
dependencies:
|
||||
debug "^4.1.0"
|
||||
extract-zip "^1.6.6"
|
||||
https-proxy-agent "^2.2.1"
|
||||
mime "^2.0.3"
|
||||
progress "^2.0.1"
|
||||
proxy-from-env "^1.0.0"
|
||||
rimraf "^2.6.1"
|
||||
ws "^6.1.0"
|
||||
|
||||
puppeteer@^1.17.0:
|
||||
version "1.17.0"
|
||||
resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-1.17.0.tgz#371957d227a2f450fa74b78e78a2dadb2be7f14f"
|
||||
@@ -4412,6 +4444,13 @@ rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2, rimraf@^2.6.3:
|
||||
dependencies:
|
||||
glob "^7.1.3"
|
||||
|
||||
rimraf@^3.0.2:
|
||||
version "3.0.2"
|
||||
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
|
||||
integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==
|
||||
dependencies:
|
||||
glob "^7.1.3"
|
||||
|
||||
ripemd160@^2.0.0, ripemd160@^2.0.1:
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.2.tgz#a1c1a6f624751577ba5d07914cbc92850585890c"
|
||||
@@ -5342,6 +5381,11 @@ uuid@^3.3.2:
|
||||
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.3.tgz#4568f0216e78760ee1dbf3a4d2cf53e224112866"
|
||||
integrity sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==
|
||||
|
||||
uuid@^3.4.0:
|
||||
version "3.4.0"
|
||||
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
|
||||
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
|
||||
|
||||
v8-compile-cache@^2.0.0:
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.0.2.tgz#a428b28bb26790734c4fc8bc9fa106fccebf6a6c"
|
||||
|
||||
Reference in New Issue
Block a user