From 522378a507284e8800b35e847121211eeac0a24f Mon Sep 17 00:00:00 2001 From: Jon Bockhorst Date: Mon, 10 Feb 2020 11:18:23 -0600 Subject: [PATCH] Move openTerminal() to common util file --- test/api/CharWidth.api.ts | 15 +- test/api/InputHandler.api.ts | 29 +- test/api/MouseTracking.api.ts | 483 +++++++++++++++++----------------- test/api/Parser.api.ts | 15 +- test/api/Terminal.api.ts | 97 +++---- test/api/TestUtils.ts | 11 + 6 files changed, 303 insertions(+), 347 deletions(-) diff --git a/test/api/CharWidth.api.ts b/test/api/CharWidth.api.ts index a2352f40..5fa00723 100644 --- a/test/api/CharWidth.api.ts +++ b/test/api/CharWidth.api.ts @@ -4,8 +4,7 @@ */ import * as puppeteer from 'puppeteer'; -import { ITerminalOptions } from 'xterm'; -import { pollFor } from './TestUtils'; +import { pollFor, openTerminal } from './TestUtils'; const APP = 'http://127.0.0.1:3000/test'; @@ -23,7 +22,7 @@ describe('CharWidth Integration Tests', function(): void { page = (await browser.pages())[0]; await page.setViewport({ width, height }); await page.goto(APP); - await openTerminal({ rows: 5, cols: 30 }); + await openTerminal(page, { rows: 5, cols: 30 }); }); after(() => { @@ -75,16 +74,6 @@ describe('CharWidth Integration Tests', function(): void { }); }); -async function openTerminal(options: ITerminalOptions = {}): Promise { - await page.evaluate(`window.term = new Terminal(${JSON.stringify(options)})`); - await page.evaluate(`window.term.open(document.querySelector('#terminal-container'))`); - if (options.rendererType === 'dom') { - await page.waitForSelector('.xterm-rows'); - } else { - await page.waitForSelector('.xterm-text-layer'); - } -} - async function sumWidths(start: number, end: number, sentinel: string): Promise { await page.evaluate(` (function() { diff --git a/test/api/InputHandler.api.ts b/test/api/InputHandler.api.ts index ad30a51c..969cb2b3 100644 --- a/test/api/InputHandler.api.ts +++ b/test/api/InputHandler.api.ts @@ -5,8 +5,7 @@ import * as puppeteer from 'puppeteer'; import { assert } from 'chai'; -import { ITerminalOptions } from 'xterm'; -import { pollFor } from './TestUtils'; +import { pollFor, openTerminal } from './TestUtils'; const APP = 'http://127.0.0.1:3000/test'; @@ -24,7 +23,7 @@ describe('InputHandler Integration Tests', function(): void { page = (await browser.pages())[0]; await page.setViewport({ width, height }); await page.goto(APP); - await openTerminal(); + await openTerminal(page); }); after(() => { @@ -260,7 +259,7 @@ 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() => { + it('Pm = 1003, Set Use All Motion (any event) Mouse Tracking', async () => { const coords = await page.evaluate(` (function() { const rect = window.term.element.getBoundingClientRect(); @@ -309,7 +308,7 @@ describe('InputHandler Integration Tests', function(): void { window.term.write('#\x1b[5b'); `); await pollFor(page, () => getLinesAsArray(4), ['##', '##', '##', '######']); - await pollFor(page, () => getCursor(), {col: 6, row: 3}); + await pollFor(page, () => getCursor(), { col: 6, row: 3 }); // should not repeat on fullwidth chars await page.evaluate(` window.term.reset(); @@ -347,7 +346,7 @@ describe('InputHandler Integration Tests', function(): void { }); describe('Window Options - CSI Ps ; Ps ; Ps t', () => { - it('should be disabled by default', async function() { + it('should be disabled by default', async function(): Promise { await page.evaluate(`(() => { window._stack = []; const _h = window.term.onData(data => window._stack.push(data)); @@ -360,7 +359,7 @@ describe('InputHandler Integration Tests', function(): void { })()`); await pollFor(page, async () => await page.evaluate(`(() => _stack)()`), []); }); - it('14 - GetWinSizePixels', async function() { + it('14 - GetWinSizePixels', async function(): Promise { await page.evaluate(`window.term.setOption('windowOptions', {getWinSizePixels: true});`); await page.evaluate(`(() => { window._stack = []; @@ -371,7 +370,7 @@ describe('InputHandler Integration Tests', function(): void { const d = await getDimensions(); await pollFor(page, async () => await page.evaluate(`(() => _stack)()`), [`\x1b[4;${d.height};${d.width}t`]); }); - it('16 - GetCellSizePixels', async function() { + it('16 - GetCellSizePixels', async function(): Promise { await page.evaluate(`window.term.setOption('windowOptions', {getCellSizePixels: true});`); await page.evaluate(`(() => { window._stack = []; @@ -397,22 +396,12 @@ describe('InputHandler Integration Tests', function(): void { window.term.resize(10, 4); window.term.write('\\x1b[?47l\\x1b8'); `); - await pollFor(page, () => getCursor(), {col: 1, row: 3}); + await pollFor(page, () => getCursor(), { col: 1, row: 3 }); }); }); }); }); -async function openTerminal(options: ITerminalOptions = {}): Promise { - await page.evaluate(`window.term = new Terminal(${JSON.stringify(options)})`); - await page.evaluate(`window.term.open(document.querySelector('#terminal-container'))`); - if (options.rendererType === 'dom') { - await page.waitForSelector('.xterm-rows'); - } else { - await page.waitForSelector('.xterm-text-layer'); - } -} - async function getLinesAsArray(count: number, start: number = 0): Promise { let text = ''; for (let i = start; i < start + count; i++) { @@ -434,7 +423,7 @@ async function simulatePaste(text: string): Promise { return await page.evaluate(`window.result_${id}`); } -async function getCursor(): Promise<{col: number, row: number}> { +async function getCursor(): Promise<{ col: number, row: number }> { return page.evaluate(` (function() { return {col: term.buffer.cursorX, row: term.buffer.cursorY}; diff --git a/test/api/MouseTracking.api.ts b/test/api/MouseTracking.api.ts index 7cae660f..d04e06b5 100644 --- a/test/api/MouseTracking.api.ts +++ b/test/api/MouseTracking.api.ts @@ -4,8 +4,7 @@ */ import * as puppeteer from 'puppeteer'; -import { ITerminalOptions } from 'xterm'; -import { pollFor, writeSync } from './TestUtils'; +import { pollFor, writeSync, openTerminal } from './TestUtils'; const APP = 'http://127.0.0.1:3000/test'; @@ -28,16 +27,6 @@ const noShift = process.platform === 'darwin' ? false : true; /** * Helper functions. */ -async function openTerminal(options: ITerminalOptions = {}): Promise { - await page.evaluate(`window.term = new Terminal(${JSON.stringify(options)})`); - await page.evaluate(`window.term.open(document.querySelector('#terminal-container'))`); - if (options.rendererType === 'dom') { - await page.waitForSelector('.xterm-rows'); - } else { - await page.waitForSelector('.xterm-text-layer'); - } -} - async function resetMouseModes(): Promise { return await page.evaluate(` window.term.write('\x1b[?9l\x1b[?1000l\x1b[?1001l\x1b[?1002l\x1b[?1003l'); @@ -77,10 +66,10 @@ async function mouseMove(col: number, row: number): Promise { return await page.mouse.move(xPixels, yPixels); } async function mouseDown(button: 'left' | 'right' | 'middle' | undefined): Promise { - return await page.mouse.down({button}); + return await page.mouse.down({ button }); } async function mouseUp(button: 'left' | 'right' | 'middle' | undefined): Promise { - return await page.mouse.up({button}); + return await page.mouse.up({ button }); } async function wheelUp(): Promise { const self = (page.mouse as any); @@ -106,24 +95,24 @@ async function wheelDown(): Promise { } // button definitions -const buttons: {[key: string]: number} = { - '': -1, - left: 0, - middle: 1, - right: 2, - released: 3, - wheelUp: 4, - wheelDown: 5, - wheelLeft: 6, +const buttons: { [key: string]: number } = { + '': -1, + left: 0, + middle: 1, + right: 2, + released: 3, + wheelUp: 4, + wheelDown: 5, + wheelLeft: 6, wheelRight: 7, - aux8: 8, - aux9: 9, - aux10: 10, - aux11: 11, - aux12: 12, - aux13: 13, - aux14: 14, - aux15: 15 + aux8: 8, + aux9: 9, + aux10: 10, + aux11: 11, + aux12: 12, + aux13: 13, + aux14: 14, + aux15: 15 }; const reverseButtons: any = {}; for (const el in buttons) { @@ -133,9 +122,9 @@ for (const el in buttons) { // extract button data from buttonCode function evalButtonCode(code: number): any { if (code > 255) { - return {button: 'invalid', action: 'invalid', modifier: {}}; + return { button: 'invalid', action: 'invalid', modifier: {} }; } - const modifier = {shift: !!(code & 4), meta: !!(code & 8), control: !!(code & 16)}; + const modifier = { shift: !!(code & 4), meta: !!(code & 8), control: !!(code & 16) }; const move = code & 32; let button = code & 3; if (code & 128) { @@ -156,11 +145,11 @@ function evalButtonCode(code: number): any { buttonS = 'wheel'; actionS = button === 4 ? 'up' : button === 5 ? 'down' : button === 6 ? 'left' : 'right'; } - return {button: buttonS, action: actionS, modifier}; + return { button: buttonS, action: actionS, modifier }; } // parse a single mouse report -function parseReport(encoding: string, msg: number[]): {state: any; row: number; col: number; } | string { +function parseReport(encoding: string, msg: number[]): { state: any; row: number; col: number; } | string { let sReport: string; let buttonCode: number; let row: number; @@ -185,7 +174,7 @@ function parseReport(encoding: string, msg: number[]): {state: any; row: number; if (report[report.length - 1] === 'm') { state.action = 'release'; } - return {state, row, col}; + return { state, row, col }; default: return { state: evalButtonCode(report.charCodeAt(3) - 32), @@ -212,7 +201,7 @@ describe('Mouse Tracking Tests', () => { beforeEach(async () => { await page.goto(APP); - await openTerminal(); + await openTerminal(page); // patch terminal to get the onData calls // we encode the msg here to an array of codes to not lose bytes // (transmission strips non utf8 bytes) @@ -242,7 +231,7 @@ describe('Mouse Tracking Tests', () => { // test at 0,0 await mouseDown('left'); - await pollFor(page, () => getReports(encoding), [{col: 1, row: 1, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 1, row: 1, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }]); // mouseup should not report await mouseUp('left'); @@ -253,14 +242,14 @@ describe('Mouse Tracking Tests', () => { await pollFor(page, () => getReports(encoding), []); await mouseDown('left'); await mouseUp('left'); - await pollFor(page, () => getReports(encoding), [{col: 51, row: 11, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 51, row: 11, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }]); // test at max rows/cols // capped at 223 (1-based) await mouseMove(223 - 1, rows - 1); await mouseDown('left'); await mouseUp('left'); - await pollFor(page, () => getReports(encoding), [{col: 223, row: rows, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 223, row: rows, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }]); // higher than 223 should not report at all await mouseMove(257, rows - 1); @@ -275,7 +264,7 @@ describe('Mouse Tracking Tests', () => { await mouseDown('left'); await mouseMove(44, 24); await mouseUp('left'); - await pollFor(page, () => getReports(encoding), [{col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }]); // middle button // bug: default action not cancelled (adds data to getReports from clipboard under X11) // await mouseMove(43, 24); @@ -291,7 +280,7 @@ describe('Mouse Tracking Tests', () => { await mouseDown('right'); await mouseMove(44, 24); await mouseUp('right'); - await pollFor(page, () => getReports(encoding), [{col: 44, row: 25, state: {action: 'press', button: 'right', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 44, row: 25, state: { action: 'press', button: 'right', modifier: { control: false, shift: false, meta: false } } }]); // wheel await mouseMove(43, 24); @@ -311,7 +300,7 @@ describe('Mouse Tracking Tests', () => { await mouseUp('left'); await wheelDown(); await page.keyboard.up('Control'); - await pollFor(page, () => getReports(encoding), [{col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }]); // ALT @@ -323,7 +312,7 @@ describe('Mouse Tracking Tests', () => { await mouseUp('left'); await wheelDown(); await page.keyboard.up('Alt'); - await pollFor(page, () => getReports(encoding), [{col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }]); // SHIFT // note: caught by selection manager @@ -341,7 +330,7 @@ describe('Mouse Tracking Tests', () => { await pollFor(page, () => getReports(encoding), []); } else { await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}} + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } } ]); } @@ -359,7 +348,7 @@ describe('Mouse Tracking Tests', () => { await page.keyboard.up('Control'); await page.keyboard.up('Alt'); // 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}}}]); + 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 () => { const encoding = 'SGR'; @@ -369,7 +358,7 @@ describe('Mouse Tracking Tests', () => { // test at 0,0 await mouseDown('left'); - await pollFor(page, () => getReports(encoding), [{col: 1, row: 1, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 1, row: 1, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }]); // mouseup should not report await mouseUp('left'); @@ -380,13 +369,13 @@ describe('Mouse Tracking Tests', () => { await pollFor(page, () => getReports(encoding), []); await mouseDown('left'); await mouseUp('left'); - await pollFor(page, () => getReports(encoding), [{col: 51, row: 11, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 51, row: 11, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }]); // test at max rows/cols await mouseMove(cols - 1, rows - 1); await mouseDown('left'); await mouseUp('left'); - await pollFor(page, () => getReports(encoding), [{col: cols, row: rows, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: cols, row: rows, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }]); // button press/move/release tests // left button @@ -395,7 +384,7 @@ describe('Mouse Tracking Tests', () => { await mouseDown('left'); await mouseMove(44, 24); await mouseUp('left'); - await pollFor(page, () => getReports(encoding), [{col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }]); // middle button // bug: default action not cancelled (adds data to getReports from clipboard under X11) // await mouseMove(43, 24); @@ -411,7 +400,7 @@ describe('Mouse Tracking Tests', () => { await mouseDown('right'); await mouseMove(44, 24); await mouseUp('right'); - await pollFor(page, () => getReports(encoding), [{col: 44, row: 25, state: {action: 'press', button: 'right', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 44, row: 25, state: { action: 'press', button: 'right', modifier: { control: false, shift: false, meta: false } } }]); // wheel await mouseMove(43, 24); @@ -431,7 +420,7 @@ describe('Mouse Tracking Tests', () => { await mouseUp('left'); await wheelDown(); await page.keyboard.up('Control'); - await pollFor(page, () => getReports(encoding), [{col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }]); // ALT @@ -443,7 +432,7 @@ describe('Mouse Tracking Tests', () => { await mouseUp('left'); await wheelDown(); await page.keyboard.up('Alt'); - await pollFor(page, () => getReports(encoding), [{col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }]); // SHIFT // note: caught by selection manager @@ -459,7 +448,7 @@ describe('Mouse Tracking Tests', () => { await pollFor(page, () => getReports(encoding), []); } else { await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}} + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } } ]); } @@ -477,7 +466,7 @@ describe('Mouse Tracking Tests', () => { await page.keyboard.up('Control'); await page.keyboard.up('Alt'); // 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}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }]); }); }); describe('DECSET 1000 (VT200 mouse)', () => { @@ -497,13 +486,13 @@ describe('Mouse Tracking Tests', () => { // test at 0,0 await mouseDown('left'); await pollFor(page, () => getReports(encoding), [ - {col: 1, row: 1, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}} + { col: 1, row: 1, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } } ]); // mouseup should report, encoding cannot report released button await mouseUp('left'); await pollFor(page, () => getReports(encoding), [ - {col: 1, row: 1, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + { col: 1, row: 1, state: { action: 'release', button: '', modifier: { control: false, shift: false, meta: false } } } ]); // mousemove should not report @@ -512,8 +501,8 @@ describe('Mouse Tracking Tests', () => { await mouseDown('left'); await mouseUp('left'); await pollFor(page, () => getReports(encoding), [ - {col: 51, row: 11, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, - {col: 51, row: 11, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + { col: 51, row: 11, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }, + { col: 51, row: 11, state: { action: 'release', button: '', modifier: { control: false, shift: false, meta: false } } } ]); // test at max rows/cols @@ -522,8 +511,8 @@ describe('Mouse Tracking Tests', () => { await mouseDown('left'); await mouseUp('left'); await pollFor(page, () => getReports(encoding), [ - {col: 223, row: rows, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, - {col: 223, row: rows, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + { col: 223, row: rows, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }, + { col: 223, row: rows, state: { action: 'release', button: '', modifier: { control: false, shift: false, meta: false } } } ]); // button press/move/release tests @@ -534,8 +523,8 @@ describe('Mouse Tracking Tests', () => { await mouseMove(44, 24); await mouseUp('left'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'release', button: '', modifier: { control: false, shift: false, meta: false } } } ]); // middle button // bug: default action not cancelled (adds data to getReports from clipboard under X11) @@ -553,17 +542,17 @@ describe('Mouse Tracking Tests', () => { await mouseMove(44, 24); await mouseUp('right'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'right', modifier: {control: false, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + { col: 44, row: 25, state: { action: 'press', button: 'right', modifier: { control: false, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'release', button: '', modifier: { control: false, shift: false, meta: false } } } ]); // wheel await mouseMove(43, 24); await getReports(encoding); // clear reports await wheelUp(); - await pollFor(page, () => getReports(encoding), [{col: 44, row: 25, state: {action: 'up', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 44, row: 25, state: { action: 'up', button: 'wheel', modifier: { control: false, shift: false, meta: false } } }]); await wheelDown(); - await pollFor(page, () => getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 44, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: false, shift: false, meta: false } } }]); // modifiers // CTRL @@ -576,9 +565,9 @@ describe('Mouse Tracking Tests', () => { await wheelDown(); await page.keyboard.up('Control'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: true, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: false}}} + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: true, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'release', button: '', modifier: { control: true, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: true, shift: false, meta: false } } } ]); // ALT @@ -591,9 +580,9 @@ describe('Mouse Tracking Tests', () => { await wheelDown(); await page.keyboard.up('Alt'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: true}}} + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'release', button: '', modifier: { control: false, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: false, shift: false, meta: true } } } ]); // SHIFT @@ -609,13 +598,13 @@ describe('Mouse Tracking Tests', () => { await page.keyboard.up('Shift'); if (noShift) { await pollFor(page, () => getReports(encoding), [ - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: true, meta: false}}} + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: false, shift: true, meta: false } } } ]); } else { await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: true, meta: false}}}, - {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: false, shift: true, meta: false}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: true, meta: false}}} + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: true, meta: false } } }, + { col: 45, row: 25, state: { action: 'release', button: '', modifier: { control: false, shift: true, meta: false } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: false, shift: true, meta: false } } } ]); } @@ -634,9 +623,9 @@ describe('Mouse Tracking Tests', () => { await page.keyboard.up('Alt'); // await page.keyboard.up('Shift'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: true, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: true}}} + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: true, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'release', button: '', modifier: { control: true, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: true, shift: false, meta: true } } } ]); }); it('SGR encoding', async () => { @@ -648,13 +637,13 @@ describe('Mouse Tracking Tests', () => { // test at 0,0 await mouseDown('left'); await pollFor(page, () => getReports(encoding), [ - {col: 1, row: 1, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}} + { col: 1, row: 1, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } } ]); // mouseup should report await mouseUp('left'); await pollFor(page, () => getReports(encoding), [ - {col: 1, row: 1, state: {action: 'release', button: 'left', modifier: {control: false, shift: false, meta: false}}} + { col: 1, row: 1, state: { action: 'release', button: 'left', modifier: { control: false, shift: false, meta: false } } } ]); // mousemove should not report @@ -663,8 +652,8 @@ describe('Mouse Tracking Tests', () => { await mouseDown('left'); await mouseUp('left'); await pollFor(page, () => getReports(encoding), [ - {col: 51, row: 11, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, - {col: 51, row: 11, state: {action: 'release', button: 'left', modifier: {control: false, shift: false, meta: false}}} + { col: 51, row: 11, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }, + { col: 51, row: 11, state: { action: 'release', button: 'left', modifier: { control: false, shift: false, meta: false } } } ]); // test at max rows/cols @@ -672,8 +661,8 @@ describe('Mouse Tracking Tests', () => { await mouseDown('left'); await mouseUp('left'); await pollFor(page, () => getReports(encoding), [ - {col: cols, row: rows, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, - {col: cols, row: rows, state: {action: 'release', button: 'left', modifier: {control: false, shift: false, meta: false}}} + { col: cols, row: rows, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }, + { col: cols, row: rows, state: { action: 'release', button: 'left', modifier: { control: false, shift: false, meta: false } } } ]); // button press/move/release tests @@ -684,8 +673,8 @@ describe('Mouse Tracking Tests', () => { await mouseMove(44, 24); await mouseUp('left'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'release', button: 'left', modifier: {control: false, shift: false, meta: false}}} + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'release', button: 'left', modifier: { control: false, shift: false, meta: false } } } ]); // middle button // bug: default action not cancelled (adds data to getReports from clipboard under X11) @@ -703,17 +692,17 @@ describe('Mouse Tracking Tests', () => { await mouseMove(44, 24); await mouseUp('right'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'right', modifier: {control: false, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'release', button: 'right', modifier: {control: false, shift: false, meta: false}}} + { col: 44, row: 25, state: { action: 'press', button: 'right', modifier: { control: false, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'release', button: 'right', modifier: { control: false, shift: false, meta: false } } } ]); // wheel await mouseMove(43, 24); await getReports(encoding); // clear reports await wheelUp(); - await pollFor(page, () => getReports(encoding), [{col: 44, row: 25, state: {action: 'up', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 44, row: 25, state: { action: 'up', button: 'wheel', modifier: { control: false, shift: false, meta: false } } }]); await wheelDown(); - await pollFor(page, () => getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 44, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: false, shift: false, meta: false } } }]); // modifiers // CTRL @@ -726,9 +715,9 @@ describe('Mouse Tracking Tests', () => { await wheelDown(); await page.keyboard.up('Control'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'release', button: 'left', modifier: {control: true, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: false}}} + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: true, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'release', button: 'left', modifier: { control: true, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: true, shift: false, meta: false } } } ]); // ALT @@ -741,9 +730,9 @@ describe('Mouse Tracking Tests', () => { await wheelDown(); await page.keyboard.up('Alt'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'release', button: 'left', modifier: {control: false, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: true}}} + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'release', button: 'left', modifier: { control: false, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: false, shift: false, meta: true } } } ]); // SHIFT @@ -758,13 +747,13 @@ describe('Mouse Tracking Tests', () => { await page.keyboard.up('Shift'); if (noShift) { await pollFor(page, () => getReports(encoding), [ - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: true, meta: false}}} + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: false, shift: true, meta: false } } } ]); } else { await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: true, meta: false}}}, - {col: 45, row: 25, state: {action: 'release', button: 'left', modifier: {control: false, shift: true, meta: false}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: true, meta: false}}} + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: true, meta: false } } }, + { col: 45, row: 25, state: { action: 'release', button: 'left', modifier: { control: false, shift: true, meta: false } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: false, shift: true, meta: false } } } ]); } @@ -783,9 +772,9 @@ describe('Mouse Tracking Tests', () => { await page.keyboard.up('Alt'); // await page.keyboard.up('Shift'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'release', button: 'left', modifier: {control: true, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: true}}} + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: true, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'release', button: 'left', modifier: { control: true, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: true, shift: false, meta: true } } } ]); }); }); @@ -806,13 +795,13 @@ describe('Mouse Tracking Tests', () => { // test at 0,0 await mouseDown('left'); await pollFor(page, () => getReports(encoding), [ - {col: 1, row: 1, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}} + { col: 1, row: 1, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } } ]); // mouseup should report, encoding cannot report released button await mouseUp('left'); await pollFor(page, () => getReports(encoding), [ - {col: 1, row: 1, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + { col: 1, row: 1, state: { action: 'release', button: '', modifier: { control: false, shift: false, meta: false } } } ]); // mousemove should not report @@ -821,8 +810,8 @@ describe('Mouse Tracking Tests', () => { await mouseDown('left'); await mouseUp('left'); await pollFor(page, () => getReports(encoding), [ - {col: 51, row: 11, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, - {col: 51, row: 11, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + { col: 51, row: 11, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }, + { col: 51, row: 11, state: { action: 'release', button: '', modifier: { control: false, shift: false, meta: false } } } ]); // test at max rows/cols @@ -831,8 +820,8 @@ describe('Mouse Tracking Tests', () => { await mouseDown('left'); await mouseUp('left'); await pollFor(page, () => getReports(encoding), [ - {col: 223, row: rows, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, - {col: 223, row: rows, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + { col: 223, row: rows, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }, + { col: 223, row: rows, state: { action: 'release', button: '', modifier: { control: false, shift: false, meta: false } } } ]); // button press/move/release tests @@ -843,9 +832,9 @@ describe('Mouse Tracking Tests', () => { await mouseMove(44, 24); await mouseUp('left'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: false, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'move', button: 'left', modifier: { control: false, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'release', button: '', modifier: { control: false, shift: false, meta: false } } } ]); // middle button // bug: default action not cancelled (adds data to getReports from clipboard under X11) @@ -863,18 +852,18 @@ describe('Mouse Tracking Tests', () => { await mouseMove(44, 24); await mouseUp('right'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'right', modifier: {control: false, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'move', button: 'right', modifier: {control: false, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + { col: 44, row: 25, state: { action: 'press', button: 'right', modifier: { control: false, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'move', button: 'right', modifier: { control: false, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'release', button: '', modifier: { control: false, shift: false, meta: false } } } ]); // wheel await mouseMove(43, 24); await getReports(encoding); // clear reports await wheelUp(); - await pollFor(page, () => getReports(encoding), [{col: 44, row: 25, state: {action: 'up', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 44, row: 25, state: { action: 'up', button: 'wheel', modifier: { control: false, shift: false, meta: false } } }]); await wheelDown(); - await pollFor(page, () => getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 44, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: false, shift: false, meta: false } } }]); // modifiers // CTRL @@ -887,10 +876,10 @@ describe('Mouse Tracking Tests', () => { await wheelDown(); await page.keyboard.up('Control'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: true, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: true, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: false}}} + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: true, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'move', button: 'left', modifier: { control: true, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'release', button: '', modifier: { control: true, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: true, shift: false, meta: false } } } ]); // ALT @@ -903,10 +892,10 @@ describe('Mouse Tracking Tests', () => { await wheelDown(); await page.keyboard.up('Alt'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: false, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: true}}} + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'move', button: 'left', modifier: { control: false, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'release', button: '', modifier: { control: false, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: false, shift: false, meta: true } } } ]); // SHIFT @@ -921,14 +910,14 @@ describe('Mouse Tracking Tests', () => { await page.keyboard.up('Shift'); if (noShift) { await pollFor(page, () => getReports(encoding), [ - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: true, meta: false}}} + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: false, shift: true, meta: false } } } ]); } else { await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: true, meta: false}}}, - {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: false, shift: true, meta: false}}}, - {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: false, shift: true, meta: false}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: true, meta: false}}} + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: true, meta: false } } }, + { col: 45, row: 25, state: { action: 'move', button: 'left', modifier: { control: false, shift: true, meta: false } } }, + { col: 45, row: 25, state: { action: 'release', button: '', modifier: { control: false, shift: true, meta: false } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: false, shift: true, meta: false } } } ]); } @@ -947,10 +936,10 @@ describe('Mouse Tracking Tests', () => { await page.keyboard.up('Alt'); // await page.keyboard.up('Shift'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: true, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: true, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: true}}} + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: true, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'move', button: 'left', modifier: { control: true, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'release', button: '', modifier: { control: true, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: true, shift: false, meta: true } } } ]); }); it('SGR encoding', async () => { @@ -963,13 +952,13 @@ describe('Mouse Tracking Tests', () => { // bug: release is fired immediately await mouseDown('left'); await pollFor(page, () => getReports(encoding), [ - {col: 1, row: 1, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}} + { col: 1, row: 1, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } } ]); // mouseup should report, encoding cannot report released button await mouseUp('left'); await pollFor(page, () => getReports(encoding), [ - {col: 1, row: 1, state: {action: 'release', button: 'left', modifier: {control: false, shift: false, meta: false}}} + { col: 1, row: 1, state: { action: 'release', button: 'left', modifier: { control: false, shift: false, meta: false } } } ]); // mousemove should not report @@ -978,8 +967,8 @@ describe('Mouse Tracking Tests', () => { await mouseDown('left'); await mouseUp('left'); await pollFor(page, () => getReports(encoding), [ - {col: 51, row: 11, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, - {col: 51, row: 11, state: {action: 'release', button: 'left', modifier: {control: false, shift: false, meta: false}}} + { col: 51, row: 11, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }, + { col: 51, row: 11, state: { action: 'release', button: 'left', modifier: { control: false, shift: false, meta: false } } } ]); // test at max rows/cols @@ -987,8 +976,8 @@ describe('Mouse Tracking Tests', () => { await mouseDown('left'); await mouseUp('left'); await pollFor(page, () => getReports(encoding), [ - {col: cols, row: rows, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, - {col: cols, row: rows, state: {action: 'release', button: 'left', modifier: {control: false, shift: false, meta: false}}} + { col: cols, row: rows, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }, + { col: cols, row: rows, state: { action: 'release', button: 'left', modifier: { control: false, shift: false, meta: false } } } ]); // button press/move/release tests @@ -999,9 +988,9 @@ describe('Mouse Tracking Tests', () => { await mouseMove(44, 24); await mouseUp('left'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: false, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'release', button: 'left', modifier: {control: false, shift: false, meta: false}}} + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'move', button: 'left', modifier: { control: false, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'release', button: 'left', modifier: { control: false, shift: false, meta: false } } } ]); // middle button // bug: default action not cancelled (adds data to getReports from clipboard under X11) @@ -1019,18 +1008,18 @@ describe('Mouse Tracking Tests', () => { await mouseMove(44, 24); await mouseUp('right'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'right', modifier: {control: false, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'move', button: 'right', modifier: {control: false, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'release', button: 'right', modifier: {control: false, shift: false, meta: false}}} + { col: 44, row: 25, state: { action: 'press', button: 'right', modifier: { control: false, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'move', button: 'right', modifier: { control: false, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'release', button: 'right', modifier: { control: false, shift: false, meta: false } } } ]); // wheel await mouseMove(43, 24); await getReports(encoding); // clear reports await wheelUp(); - await pollFor(page, () => getReports(encoding), [{col: 44, row: 25, state: {action: 'up', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 44, row: 25, state: { action: 'up', button: 'wheel', modifier: { control: false, shift: false, meta: false } } }]); await wheelDown(); - await pollFor(page, () => getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 44, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: false, shift: false, meta: false } } }]); // modifiers // CTRL @@ -1043,10 +1032,10 @@ describe('Mouse Tracking Tests', () => { await wheelDown(); await page.keyboard.up('Control'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: true, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'release', button: 'left', modifier: {control: true, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: false}}} + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: true, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'move', button: 'left', modifier: { control: true, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'release', button: 'left', modifier: { control: true, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: true, shift: false, meta: false } } } ]); // ALT @@ -1059,10 +1048,10 @@ describe('Mouse Tracking Tests', () => { await wheelDown(); await page.keyboard.up('Alt'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: false, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'release', button: 'left', modifier: {control: false, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: true}}} + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'move', button: 'left', modifier: { control: false, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'release', button: 'left', modifier: { control: false, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: false, shift: false, meta: true } } } ]); // SHIFT @@ -1077,14 +1066,14 @@ describe('Mouse Tracking Tests', () => { await page.keyboard.up('Shift'); if (noShift) { await pollFor(page, () => getReports(encoding), [ - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: true, meta: false}}} + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: false, shift: true, meta: false } } } ]); } else { await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: true, meta: false}}}, - {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: false, shift: true, meta: false}}}, - {col: 45, row: 25, state: {action: 'release', button: 'left', modifier: {control: false, shift: true, meta: false}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: true, meta: false}}} + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: true, meta: false } } }, + { col: 45, row: 25, state: { action: 'move', button: 'left', modifier: { control: false, shift: true, meta: false } } }, + { col: 45, row: 25, state: { action: 'release', button: 'left', modifier: { control: false, shift: true, meta: false } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: false, shift: true, meta: false } } } ]); } @@ -1103,10 +1092,10 @@ describe('Mouse Tracking Tests', () => { await page.keyboard.up('Alt'); // await page.keyboard.up('Shift'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: true, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'release', button: 'left', modifier: {control: true, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: true}}} + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: true, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'move', button: 'left', modifier: { control: true, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'release', button: 'left', modifier: { control: true, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: true, shift: false, meta: true } } } ]); }); }); @@ -1124,25 +1113,25 @@ describe('Mouse Tracking Tests', () => { // test at 0,0 await mouseDown('left'); await pollFor(page, () => getReports(encoding), [ - {col: 1, row: 1, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}} + { col: 1, row: 1, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } } ]); // mouseup should report, encoding cannot report released button await mouseUp('left'); await pollFor(page, () => getReports(encoding), [ - {col: 1, row: 1, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + { col: 1, row: 1, state: { action: 'release', button: '', modifier: { control: false, shift: false, meta: false } } } ]); // mousemove should report await mouseMove(50, 10); await pollFor(page, () => getReports(encoding), [ - {col: 51, row: 11, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: false}}} + { col: 51, row: 11, state: { action: 'move', button: '', modifier: { control: false, shift: false, meta: false } } } ]); await mouseDown('left'); await mouseUp('left'); await pollFor(page, () => getReports(encoding), [ - {col: 51, row: 11, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, - {col: 51, row: 11, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + { col: 51, row: 11, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }, + { col: 51, row: 11, state: { action: 'release', button: '', modifier: { control: false, shift: false, meta: false } } } ]); // test at max rows/cols @@ -1151,9 +1140,9 @@ describe('Mouse Tracking Tests', () => { await mouseDown('left'); await mouseUp('left'); await pollFor(page, () => getReports(encoding), [ - {col: 223, row: rows, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: false}}}, - {col: 223, row: rows, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, - {col: 223, row: rows, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + { col: 223, row: rows, state: { action: 'move', button: '', modifier: { control: false, shift: false, meta: false } } }, + { col: 223, row: rows, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }, + { col: 223, row: rows, state: { action: 'release', button: '', modifier: { control: false, shift: false, meta: false } } } ]); // button press/move/release tests @@ -1163,10 +1152,10 @@ describe('Mouse Tracking Tests', () => { await mouseMove(44, 24); await mouseUp('left'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: false}}}, - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: false, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + { col: 44, row: 25, state: { action: 'move', button: '', modifier: { control: false, shift: false, meta: false } } }, + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'move', button: 'left', modifier: { control: false, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'release', button: '', modifier: { control: false, shift: false, meta: false } } } ]); // middle button // bug: default action not cancelled (adds data to getReports from clipboard under X11) @@ -1183,19 +1172,19 @@ describe('Mouse Tracking Tests', () => { await mouseMove(44, 24); await mouseUp('right'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: false}}}, - {col: 44, row: 25, state: {action: 'press', button: 'right', modifier: {control: false, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'move', button: 'right', modifier: {control: false, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + { col: 44, row: 25, state: { action: 'move', button: '', modifier: { control: false, shift: false, meta: false } } }, + { col: 44, row: 25, state: { action: 'press', button: 'right', modifier: { control: false, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'move', button: 'right', modifier: { control: false, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'release', button: '', modifier: { control: false, shift: false, meta: false } } } ]); // wheel await mouseMove(43, 24); await getReports(encoding); // clear reports await wheelUp(); - await pollFor(page, () => getReports(encoding), [{col: 44, row: 25, state: {action: 'up', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 44, row: 25, state: { action: 'up', button: 'wheel', modifier: { control: false, shift: false, meta: false } } }]); await wheelDown(); - await pollFor(page, () => getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 44, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: false, shift: false, meta: false } } }]); // modifiers // CTRL @@ -1207,11 +1196,11 @@ describe('Mouse Tracking Tests', () => { await wheelDown(); await page.keyboard.up('Control'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: true, shift: false, meta: false}}}, - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: true, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: true, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: false}}} + { col: 44, row: 25, state: { action: 'move', button: '', modifier: { control: true, shift: false, meta: false } } }, + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: true, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'move', button: 'left', modifier: { control: true, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'release', button: '', modifier: { control: true, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: true, shift: false, meta: false } } } ]); // ALT @@ -1223,11 +1212,11 @@ describe('Mouse Tracking Tests', () => { await wheelDown(); await page.keyboard.up('Alt'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: true}}}, - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: false, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: true}}} + { col: 44, row: 25, state: { action: 'move', button: '', modifier: { control: false, shift: false, meta: true } } }, + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'move', button: 'left', modifier: { control: false, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'release', button: '', modifier: { control: false, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: false, shift: false, meta: true } } } ]); // SHIFT @@ -1241,16 +1230,16 @@ describe('Mouse Tracking Tests', () => { await page.keyboard.up('Shift'); if (noShift) { await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: true, meta: false}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: true, meta: false}}} + { col: 44, row: 25, state: { action: 'move', button: '', modifier: { control: false, shift: true, meta: false } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: false, shift: true, meta: false } } } ]); } else { await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: true, meta: false}}}, - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: true, meta: false}}}, - {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: false, shift: true, meta: false}}}, - {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: false, shift: true, meta: false}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: true, meta: false}}} + { col: 44, row: 25, state: { action: 'move', button: '', modifier: { control: false, shift: true, meta: false } } }, + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: true, meta: false } } }, + { col: 45, row: 25, state: { action: 'move', button: 'left', modifier: { control: false, shift: true, meta: false } } }, + { col: 45, row: 25, state: { action: 'release', button: '', modifier: { control: false, shift: true, meta: false } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: false, shift: true, meta: false } } } ]); } @@ -1268,11 +1257,11 @@ describe('Mouse Tracking Tests', () => { await page.keyboard.up('Alt'); // await page.keyboard.up('Shift'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: true, shift: false, meta: true}}}, - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: true, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: true, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: true}}} + { col: 44, row: 25, state: { action: 'move', button: '', modifier: { control: true, shift: false, meta: true } } }, + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: true, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'move', button: 'left', modifier: { control: true, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'release', button: '', modifier: { control: true, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: true, shift: false, meta: true } } } ]); }); it('SGR encoding', async () => { @@ -1284,25 +1273,25 @@ describe('Mouse Tracking Tests', () => { // test at 0,0 await mouseDown('left'); await pollFor(page, () => getReports(encoding), [ - {col: 1, row: 1, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}} + { col: 1, row: 1, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } } ]); // mouseup should report, encoding cannot report released button await mouseUp('left'); await pollFor(page, () => getReports(encoding), [ - {col: 1, row: 1, state: {action: 'release', button: 'left', modifier: {control: false, shift: false, meta: false}}} + { col: 1, row: 1, state: { action: 'release', button: 'left', modifier: { control: false, shift: false, meta: false } } } ]); // mousemove should report await mouseMove(50, 10); await pollFor(page, () => getReports(encoding), [ - {col: 51, row: 11, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: false}}} + { col: 51, row: 11, state: { action: 'move', button: '', modifier: { control: false, shift: false, meta: false } } } ]); await mouseDown('left'); await mouseUp('left'); await pollFor(page, () => getReports(encoding), [ - {col: 51, row: 11, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, - {col: 51, row: 11, state: {action: 'release', button: 'left', modifier: {control: false, shift: false, meta: false}}} + { col: 51, row: 11, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }, + { col: 51, row: 11, state: { action: 'release', button: 'left', modifier: { control: false, shift: false, meta: false } } } ]); // test at max rows/cols @@ -1312,9 +1301,9 @@ describe('Mouse Tracking Tests', () => { await mouseDown('left'); await mouseUp('left'); await pollFor(page, () => getReports(encoding), [ - {col: cols, row: rows, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: false}}}, - {col: cols, row: rows, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, - {col: cols, row: rows, state: {action: 'release', button: 'left', modifier: {control: false, shift: false, meta: false}}} + { col: cols, row: rows, state: { action: 'move', button: '', modifier: { control: false, shift: false, meta: false } } }, + { col: cols, row: rows, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }, + { col: cols, row: rows, state: { action: 'release', button: 'left', modifier: { control: false, shift: false, meta: false } } } ]); // button press/move/release tests @@ -1324,10 +1313,10 @@ describe('Mouse Tracking Tests', () => { await mouseMove(44, 24); await mouseUp('left'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: false}}}, - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: false, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'release', button: 'left', modifier: {control: false, shift: false, meta: false}}} + { col: 44, row: 25, state: { action: 'move', button: '', modifier: { control: false, shift: false, meta: false } } }, + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'move', button: 'left', modifier: { control: false, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'release', button: 'left', modifier: { control: false, shift: false, meta: false } } } ]); // middle button // bug: default action not cancelled (adds data to getReports from clipboard under X11) @@ -1344,19 +1333,19 @@ describe('Mouse Tracking Tests', () => { await mouseMove(44, 24); await mouseUp('right'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: false}}}, - {col: 44, row: 25, state: {action: 'press', button: 'right', modifier: {control: false, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'move', button: 'right', modifier: {control: false, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'release', button: 'right', modifier: {control: false, shift: false, meta: false}}} + { col: 44, row: 25, state: { action: 'move', button: '', modifier: { control: false, shift: false, meta: false } } }, + { col: 44, row: 25, state: { action: 'press', button: 'right', modifier: { control: false, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'move', button: 'right', modifier: { control: false, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'release', button: 'right', modifier: { control: false, shift: false, meta: false } } } ]); // wheel await mouseMove(43, 24); await getReports(encoding); // clear reports await wheelUp(); - await pollFor(page, () => getReports(encoding), [{col: 44, row: 25, state: {action: 'up', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 44, row: 25, state: { action: 'up', button: 'wheel', modifier: { control: false, shift: false, meta: false } } }]); await wheelDown(); - await pollFor(page, () => getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); + await pollFor(page, () => getReports(encoding), [{ col: 44, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: false, shift: false, meta: false } } }]); // modifiers // CTRL @@ -1368,11 +1357,11 @@ describe('Mouse Tracking Tests', () => { await wheelDown(); await page.keyboard.up('Control'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: true, shift: false, meta: false}}}, - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: true, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'release', button: 'left', modifier: {control: true, shift: false, meta: false}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: false}}} + { col: 44, row: 25, state: { action: 'move', button: '', modifier: { control: true, shift: false, meta: false } } }, + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: true, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'move', button: 'left', modifier: { control: true, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'release', button: 'left', modifier: { control: true, shift: false, meta: false } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: true, shift: false, meta: false } } } ]); // ALT @@ -1384,11 +1373,11 @@ describe('Mouse Tracking Tests', () => { await wheelDown(); await page.keyboard.up('Alt'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: true}}}, - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: false, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'release', button: 'left', modifier: {control: false, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: true}}} + { col: 44, row: 25, state: { action: 'move', button: '', modifier: { control: false, shift: false, meta: true } } }, + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'move', button: 'left', modifier: { control: false, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'release', button: 'left', modifier: { control: false, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: false, shift: false, meta: true } } } ]); // SHIFT @@ -1402,16 +1391,16 @@ describe('Mouse Tracking Tests', () => { await page.keyboard.up('Shift'); if (noShift) { await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: true, meta: false}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: true, meta: false}}} + { col: 44, row: 25, state: { action: 'move', button: '', modifier: { control: false, shift: true, meta: false } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: false, shift: true, meta: false } } } ]); } else { await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: true, meta: false}}}, - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: true, meta: false}}}, - {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: false, shift: true, meta: false}}}, - {col: 45, row: 25, state: {action: 'release', button: 'left', modifier: {control: false, shift: true, meta: false}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: true, meta: false}}} + { col: 44, row: 25, state: { action: 'move', button: '', modifier: { control: false, shift: true, meta: false } } }, + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: false, shift: true, meta: false } } }, + { col: 45, row: 25, state: { action: 'move', button: 'left', modifier: { control: false, shift: true, meta: false } } }, + { col: 45, row: 25, state: { action: 'release', button: 'left', modifier: { control: false, shift: true, meta: false } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: false, shift: true, meta: false } } } ]); } @@ -1429,11 +1418,11 @@ describe('Mouse Tracking Tests', () => { await page.keyboard.up('Alt'); // await page.keyboard.up('Shift'); await pollFor(page, () => getReports(encoding), [ - {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: true, shift: false, meta: true}}}, - {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: true, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'release', button: 'left', modifier: {control: true, shift: false, meta: true}}}, - {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: true}}} + { col: 44, row: 25, state: { action: 'move', button: '', modifier: { control: true, shift: false, meta: true } } }, + { col: 44, row: 25, state: { action: 'press', button: 'left', modifier: { control: true, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'move', button: 'left', modifier: { control: true, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'release', button: 'left', modifier: { control: true, shift: false, meta: true } } }, + { col: 45, row: 25, state: { action: 'down', button: 'wheel', modifier: { control: true, shift: false, meta: true } } } ]); }); }); diff --git a/test/api/Parser.api.ts b/test/api/Parser.api.ts index 72f56799..24922562 100644 --- a/test/api/Parser.api.ts +++ b/test/api/Parser.api.ts @@ -5,8 +5,7 @@ import * as puppeteer from 'puppeteer'; import { assert } from 'chai'; -import { ITerminalOptions } from 'xterm'; -import { writeSync } from './TestUtils'; +import { writeSync, openTerminal } from './TestUtils'; const APP = 'http://127.0.0.1:3000/test'; @@ -24,7 +23,7 @@ describe('Parser Integration Tests', function(): void { page = (await browser.pages())[0]; await page.setViewport({ width, height }); await page.goto(APP); - await openTerminal(); + await openTerminal(page); }); after(async () => browser.close()); @@ -110,13 +109,3 @@ describe('Parser Integration Tests', function(): void { }); }); }); - -async function openTerminal(options: ITerminalOptions = {}): Promise { - await page.evaluate(`window.term = new Terminal(${JSON.stringify(options)})`); - await page.evaluate(`window.term.open(document.querySelector('#terminal-container'))`); - if (options.rendererType === 'dom') { - await page.waitForSelector('.xterm-rows'); - } else { - await page.waitForSelector('.xterm-text-layer'); - } -} diff --git a/test/api/Terminal.api.ts b/test/api/Terminal.api.ts index 36966bfb..21bc0921 100644 --- a/test/api/Terminal.api.ts +++ b/test/api/Terminal.api.ts @@ -5,8 +5,7 @@ import * as puppeteer from 'puppeteer'; import { assert } from 'chai'; -import { ITerminalOptions } from 'xterm'; -import { pollFor, timeout, writeSync } from './TestUtils'; +import { pollFor, timeout, writeSync, openTerminal } from './TestUtils'; const APP = 'http://127.0.0.1:3000/test'; @@ -29,13 +28,13 @@ describe('API Integration Tests', function(): void { beforeEach(async () => page.goto(APP)); it('Default options', async () => { - await openTerminal(); + await openTerminal(page); assert.equal(await page.evaluate(`window.term.cols`), 80); assert.equal(await page.evaluate(`window.term.rows`), 24); }); it('write', async () => { - await openTerminal(); + await openTerminal(page); await page.evaluate(` window.term.write('foo'); window.term.write('bar'); @@ -45,7 +44,7 @@ describe('API Integration Tests', function(): void { }); it('write with callback', async () => { - await openTerminal(); + await openTerminal(page); await page.evaluate(` window.term.write('foo', () => { window.__x = 'a'; }); window.term.write('bar', () => { window.__x += 'b'; }); @@ -56,7 +55,7 @@ describe('API Integration Tests', function(): void { }); it('write - bytes (UTF8)', async () => { - await openTerminal(); + await openTerminal(page); await page.evaluate(` // foo window.term.write(new Uint8Array([102, 111, 111])); @@ -69,7 +68,7 @@ describe('API Integration Tests', function(): void { }); it('write - bytes (UTF8) with callback', async () => { - await openTerminal(); + await openTerminal(page); await page.evaluate(` // foo window.term.write(new Uint8Array([102, 111, 111]), () => { window.__x = 'A'; }); @@ -83,7 +82,7 @@ describe('API Integration Tests', function(): void { }); it('writeln', async () => { - await openTerminal(); + await openTerminal(page); await page.evaluate(` window.term.writeln('foo'); window.term.writeln('bar'); @@ -95,7 +94,7 @@ describe('API Integration Tests', function(): void { }); it('writeln with callback', async () => { - await openTerminal(); + await openTerminal(page); await page.evaluate(` window.term.writeln('foo', () => { window.__x = '1'; }); window.term.writeln('bar', () => { window.__x += '2'; }); @@ -108,7 +107,7 @@ describe('API Integration Tests', function(): void { }); it('writeln - bytes (UTF8)', async () => { - await openTerminal(); + await openTerminal(page); await page.evaluate(` window.term.writeln(new Uint8Array([102, 111, 111])); window.term.writeln(new Uint8Array([98, 97, 114])); @@ -120,7 +119,7 @@ describe('API Integration Tests', function(): void { }); it('paste', async () => { - await openTerminal(); + await openTerminal(page); await page.evaluate(` window.calls = []; window.term.onData(e => calls.push(e)); @@ -134,7 +133,7 @@ describe('API Integration Tests', function(): void { }); it('clear', async () => { - await openTerminal({ rows: 5 }); + await openTerminal(page, { rows: 5 }); await page.evaluate(` window.term.write('test0'); window.parsed = 0; @@ -152,7 +151,7 @@ describe('API Integration Tests', function(): void { }); it('getOption, setOption', async () => { - await openTerminal(); + await openTerminal(page); assert.equal(await page.evaluate(`window.term.getOption('rendererType')`), 'canvas'); await page.evaluate(`window.term.setOption('rendererType', 'dom')`); assert.equal(await page.evaluate(`window.term.getOption('rendererType')`), 'dom'); @@ -160,7 +159,7 @@ describe('API Integration Tests', function(): void { describe('renderer', () => { it('foreground', async () => { - await openTerminal({ rendererType: 'dom' }); + await openTerminal(page, { rendererType: 'dom' }); await writeSync(page, '\\x1b[30m0\\x1b[31m1\\x1b[32m2\\x1b[33m3\\x1b[34m4\\x1b[35m5\\x1b[36m6\\x1b[37m7'); await pollFor(page, `document.querySelectorAll('.xterm-rows > :nth-child(1) > *').length`, 9); assert.deepEqual(await page.evaluate(` @@ -185,7 +184,7 @@ describe('API Integration Tests', function(): void { }); it('background', async () => { - await openTerminal({ rendererType: 'dom' }); + await openTerminal(page, { rendererType: 'dom' }); await writeSync(page, '\\x1b[40m0\\x1b[41m1\\x1b[42m2\\x1b[43m3\\x1b[44m4\\x1b[45m5\\x1b[46m6\\x1b[47m7'); await pollFor(page, `document.querySelectorAll('.xterm-rows > :nth-child(1) > *').length`, 9); assert.deepEqual(await page.evaluate(` @@ -211,7 +210,7 @@ describe('API Integration Tests', function(): void { }); it('selection', async () => { - await openTerminal({ rows: 5, cols: 5 }); + await openTerminal(page, { rows: 5, cols: 5 }); await page.evaluate(`window.term.write('\\n\\nfoo\\n\\n\\rbar\\n\\n\\rbaz')`); assert.equal(await page.evaluate(`window.term.hasSelection()`), false); assert.equal(await page.evaluate(`window.term.getSelection()`), ''); @@ -231,7 +230,7 @@ describe('API Integration Tests', function(): void { }); it('focus, blur', async () => { - await openTerminal(); + await openTerminal(page); assert.equal(await page.evaluate(`document.activeElement.className`), ''); await page.evaluate(`window.term.focus()`); assert.equal(await page.evaluate(`document.activeElement.className`), 'xterm-helper-textarea'); @@ -241,7 +240,7 @@ describe('API Integration Tests', function(): void { describe('loadAddon', () => { it('constructor', async () => { - await openTerminal({ cols: 5 }); + await openTerminal(page, { cols: 5 }); await page.evaluate(` window.cols = 0; window.term.loadAddon({ @@ -253,7 +252,7 @@ describe('API Integration Tests', function(): void { }); it('dispose (addon)', async () => { - await openTerminal(); + await openTerminal(page); await page.evaluate(` window.disposeCalled = false window.addon = { @@ -268,7 +267,7 @@ describe('API Integration Tests', function(): void { }); it('dispose (terminal)', async () => { - await openTerminal(); + await openTerminal(page); await page.evaluate(` window.disposeCalled = false window.term.loadAddon({ @@ -284,7 +283,7 @@ describe('API Integration Tests', function(): void { describe('Events', () => { it('onCursorMove', async () => { - await openTerminal(); + await openTerminal(page); await page.evaluate(` window.callCount = 0; window.term.onCursorMove(e => window.callCount++); @@ -296,7 +295,7 @@ describe('API Integration Tests', function(): void { }); it('onData', async () => { - await openTerminal(); + await openTerminal(page); await page.evaluate(` window.calls = []; window.term.onData(e => calls.push(e)); @@ -306,7 +305,7 @@ describe('API Integration Tests', function(): void { }); it('onKey', async () => { - await openTerminal(); + await openTerminal(page); await page.evaluate(` window.calls = []; window.term.onKey(e => calls.push(e.key)); @@ -316,7 +315,7 @@ describe('API Integration Tests', function(): void { }); it('onLineFeed', async () => { - await openTerminal(); + await openTerminal(page); await page.evaluate(` window.callCount = 0; window.term.onLineFeed(() => callCount++); @@ -328,7 +327,7 @@ describe('API Integration Tests', function(): void { }); it('onScroll', async () => { - await openTerminal({ rows: 5 }); + await openTerminal(page, { rows: 5 }); await page.evaluate(` window.calls = []; window.term.onScroll(e => window.calls.push(e)); @@ -344,7 +343,7 @@ describe('API Integration Tests', function(): void { }); it('onSelectionChange', async () => { - await openTerminal(); + await openTerminal(page); await page.evaluate(` window.callCount = 0; window.term.onSelectionChange(() => window.callCount++); @@ -356,9 +355,9 @@ describe('API Integration Tests', function(): void { await pollFor(page, `window.callCount`, 2); }); - it('onRender', async function (): Promise { + it('onRender', async function(): Promise { this.retries(3); - await openTerminal(); + await openTerminal(page); await timeout(20); // Ensure all init events are fired await page.evaluate(` window.calls = []; @@ -372,7 +371,7 @@ describe('API Integration Tests', function(): void { }); it('onResize', async () => { - await openTerminal(); + await openTerminal(page); await timeout(20); // Ensure all init events are fired await page.evaluate(` window.calls = []; @@ -386,7 +385,7 @@ describe('API Integration Tests', function(): void { }); it('onTitleChange', async () => { - await openTerminal(); + await openTerminal(page); await page.evaluate(` window.calls = []; window.term.onTitleChange(e => window.calls.push(e)); @@ -399,7 +398,7 @@ describe('API Integration Tests', function(): void { describe('buffer', () => { it('cursorX, cursorY', async () => { - await openTerminal({ rows: 5, cols: 5 }); + await openTerminal(page, { rows: 5, cols: 5 }); assert.equal(await page.evaluate(`window.term.buffer.cursorX`), 0); assert.equal(await page.evaluate(`window.term.buffer.cursorY`), 0); await writeSync(page, 'foo'); @@ -420,7 +419,7 @@ describe('API Integration Tests', function(): void { }); it('viewportY', async () => { - await openTerminal({ rows: 5 }); + await openTerminal(page, { rows: 5 }); assert.equal(await page.evaluate(`window.term.buffer.viewportY`), 0); await writeSync(page, '\\n\\n\\n\\n'); assert.equal(await page.evaluate(`window.term.buffer.viewportY`), 0); @@ -435,7 +434,7 @@ describe('API Integration Tests', function(): void { }); it('baseY', async () => { - await openTerminal({ rows: 5 }); + await openTerminal(page, { rows: 5 }); assert.equal(await page.evaluate(`window.term.buffer.baseY`), 0); await writeSync(page, '\\n\\n\\n\\n'); assert.equal(await page.evaluate(`window.term.buffer.baseY`), 0); @@ -450,7 +449,7 @@ describe('API Integration Tests', function(): void { }); it('length', async () => { - await openTerminal({ rows: 5 }); + await openTerminal(page, { rows: 5 }); assert.equal(await page.evaluate(`window.term.buffer.length`), 5); await writeSync(page, '\\n\\n\\n\\n'); assert.equal(await page.evaluate(`window.term.buffer.length`), 5); @@ -462,13 +461,13 @@ describe('API Integration Tests', function(): void { describe('getLine', () => { it('invalid index', async () => { - await openTerminal({ rows: 5 }); + await openTerminal(page, { rows: 5 }); assert.equal(await page.evaluate(`window.term.buffer.getLine(-1)`), undefined); assert.equal(await page.evaluate(`window.term.buffer.getLine(5)`), undefined); }); it('isWrapped', async () => { - await openTerminal({ cols: 5 }); + await openTerminal(page, { cols: 5 }); assert.equal(await page.evaluate(`window.term.buffer.getLine(0).isWrapped`), false); assert.equal(await page.evaluate(`window.term.buffer.getLine(1).isWrapped`), false); await writeSync(page, 'abcde'); @@ -480,7 +479,7 @@ describe('API Integration Tests', function(): void { }); it('translateToString', async () => { - await openTerminal({ cols: 5 }); + await openTerminal(page, { cols: 5 }); assert.equal(await page.evaluate(`window.term.buffer.getLine(0).translateToString()`), ' '); assert.equal(await page.evaluate(`window.term.buffer.getLine(0).translateToString(true)`), ''); await writeSync(page, 'foo'); @@ -495,7 +494,7 @@ describe('API Integration Tests', function(): void { }); it('getCell', async () => { - await openTerminal({ cols: 5 }); + await openTerminal(page, { cols: 5 }); assert.equal(await page.evaluate(`window.term.buffer.getLine(0).getCell(-1)`), undefined); assert.equal(await page.evaluate(`window.term.buffer.getLine(0).getCell(5)`), undefined); assert.equal(await page.evaluate(`window.term.buffer.getLine(0).getCell(0).getChars()`), ''); @@ -520,14 +519,14 @@ describe('API Integration Tests', function(): void { }); it('dispose (opened)', async () => { - await openTerminal(); + await openTerminal(page); await page.evaluate(`window.term.dispose()`); assert.equal(await page.evaluate(`window.term._core._isDisposed`), true); }); describe('registerLinkProvider', () => { it('should fire provideLink when hovering cells', async () => { - await openTerminal({ rendererType: 'dom' }); + await openTerminal(page, { rendererType: 'dom' }); await page.evaluate(` window.calls = []; window.disposable = window.term.registerLinkProvider({ @@ -546,7 +545,7 @@ describe('API Integration Tests', function(): void { }); it('should fire hover and leave events on the link', async () => { - await openTerminal({ rendererType: 'dom' }); + await openTerminal(page, { rendererType: 'dom' }); await writeSync(page, 'foo bar baz'); // Wait for renderer to catch up as links are cleared on render await pollFor(page, `document.querySelector('.xterm-rows').textContent`, 'foo bar baz '); @@ -581,7 +580,7 @@ describe('API Integration Tests', function(): void { }); it('should work fine when hover and leave callbacks are not provided', async () => { - await openTerminal({ rendererType: 'dom' }); + await openTerminal(page, { rendererType: 'dom' }); await writeSync(page, 'foo bar baz'); // Wait for renderer to catch up as links are cleared on render await pollFor(page, `document.querySelector('.xterm-rows').textContent`, 'foo bar baz '); @@ -614,7 +613,7 @@ describe('API Integration Tests', function(): void { }); it('should fire activate events when clicking the link', async () => { - await openTerminal({ rendererType: 'dom' }); + await openTerminal(page, { rendererType: 'dom' }); await writeSync(page, 'a b c'); // Wait for renderer to catch up as links are cleared on render @@ -662,16 +661,6 @@ describe('API Integration Tests', function(): void { }); }); -async function openTerminal(options: ITerminalOptions = {}): Promise { - await page.evaluate(`window.term = new Terminal(${JSON.stringify(options)})`); - await page.evaluate(`window.term.open(document.querySelector('#terminal-container'))`); - if (options.rendererType === 'dom') { - await page.waitForSelector('.xterm-rows'); - } else { - await page.waitForSelector('.xterm-text-layer'); - } -} - interface IDimensions { top: number; left: number; @@ -713,7 +702,7 @@ async function getCellCoordinates(dimensions: IDimensions, col: number, row: num }; } -async function moveMouseCell(page: puppeteer.Page, dimensions: IDimensions, col: number, row: number) { +async function moveMouseCell(page: puppeteer.Page, dimensions: IDimensions, col: number, row: number): Promise { const coords = await getCellCoordinates(dimensions, col, row); await page.mouse.move(coords.x, coords.y); } diff --git a/test/api/TestUtils.ts b/test/api/TestUtils.ts index d3674812..67bc511b 100644 --- a/test/api/TestUtils.ts +++ b/test/api/TestUtils.ts @@ -5,6 +5,7 @@ import * as puppeteer from 'puppeteer'; import deepEqual = require('deep-equal'); +import { ITerminalOptions } from 'xterm'; export async function pollFor(page: puppeteer.Page, evalOrFn: string | (() => Promise), val: T, preFn?: () => Promise): Promise { if (preFn) { @@ -29,3 +30,13 @@ export async function writeSync(page: puppeteer.Page, data: string): Promise { return new Promise(r => setTimeout(r, ms)); } + +export async function openTerminal(page: puppeteer.Page, options: ITerminalOptions = {}): Promise { + await page.evaluate(`window.term = new Terminal(${JSON.stringify(options)})`); + await page.evaluate(`window.term.open(document.querySelector('#terminal-container'))`); + if (options.rendererType === 'dom') { + await page.waitForSelector('.xterm-rows'); + } else { + await page.waitForSelector('.xterm-text-layer'); + } +}