-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2109 from Tyriar/2107_cursor_report
Fix status reporting
- Loading branch information
Showing
2 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/** | ||
* Copyright (c) 2019 The xterm.js authors. All rights reserved. | ||
* @license MIT | ||
*/ | ||
|
||
import * as puppeteer from 'puppeteer'; | ||
import { assert } from 'chai'; | ||
import { ITerminalOptions } from './Types'; | ||
|
||
const APP = 'http://127.0.0.1:3000/test'; | ||
|
||
let browser: puppeteer.Browser; | ||
let page: puppeteer.Page; | ||
const width = 800; | ||
const height = 600; | ||
|
||
describe('InputHandler Integration Tests', () => { | ||
before(async function(): Promise<any> { | ||
this.timeout(10000); | ||
browser = await puppeteer.launch({ | ||
headless: process.argv.indexOf('--headless') !== -1, | ||
slowMo: 80, | ||
args: [`--window-size=${width},${height}`] | ||
}); | ||
page = (await browser.pages())[0]; | ||
await page.setViewport({ width, height }); | ||
}); | ||
|
||
after(() => { | ||
browser.close(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
await page.goto(APP); | ||
}); | ||
|
||
describe('Device Status Report (DSR)', () => { | ||
it('Status Report - CSI 5 n', async function(): Promise<any> { | ||
this.timeout(10000); | ||
await openTerminal(); | ||
await page.evaluate(` | ||
window.term.onData(e => window.result = e); | ||
window.term.write('\\x1b[5n'); | ||
`); | ||
assert.equal(await page.evaluate(`window.result`), '\x1b[0n'); | ||
}); | ||
|
||
it('Report Cursor Position (CPR) - CSI 6 n', async function(): Promise<any> { | ||
this.timeout(10000); | ||
await openTerminal(); | ||
await page.evaluate(`window.term.write('\\n\\nfoo')`); | ||
assert.deepEqual(await page.evaluate(` | ||
[window.term.buffer.cursorY, window.term.buffer.cursorX] | ||
`), [2, 3]); | ||
await page.evaluate(` | ||
window.term.onData(e => window.result = e); | ||
window.term.write('\\x1b[6n'); | ||
`); | ||
assert.equal(await page.evaluate(`window.result`), '\x1b[3;4R'); | ||
}); | ||
|
||
it('Report Cursor Position (DECXCPR) - CSI ? 6 n', async function(): Promise<any> { | ||
this.timeout(10000); | ||
await openTerminal(); | ||
await page.evaluate(`window.term.write('\\n\\nfoo')`); | ||
assert.deepEqual(await page.evaluate(` | ||
[window.term.buffer.cursorY, window.term.buffer.cursorX] | ||
`), [2, 3]); | ||
await page.evaluate(` | ||
window.term.onData(e => window.result = e); | ||
window.term.write('\\x1b[?6n'); | ||
`); | ||
assert.equal(await page.evaluate(`window.result`), '\x1b[?3;4R'); | ||
}); | ||
}); | ||
}); | ||
|
||
async function openTerminal(options: ITerminalOptions = {}): Promise<void> { | ||
await page.evaluate(`window.term = new Terminal(${JSON.stringify(options)})`); | ||
await page.evaluate(`window.term.open(document.querySelector('#terminal-container'))`); | ||
if (options.rendererType === 'dom') { | ||
await page.waitForSelector('.xterm-rows'); | ||
} else { | ||
await page.waitForSelector('.xterm-text-layer'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters