chore: update Bidi key values (#10466)

This commit is contained in:
jrandolf 2023-06-29 09:31:49 +02:00 committed by GitHub
parent 1175fe98c1
commit 1c80ebe846
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 237 additions and 75 deletions

16
package-lock.json generated
View File

@ -3020,9 +3020,9 @@
}
},
"node_modules/chromium-bidi": {
"version": "0.4.15",
"resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.4.15.tgz",
"integrity": "sha512-uvWG7BrvxEqQDRCMET5FsgpoyGEqebCOL1jPbnH9rxaCFHPKd2Z8lQVnhz8ZwFfwYyQYm212xLjmrVlTIxsSVA==",
"version": "0.4.16",
"resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.4.16.tgz",
"integrity": "sha512-7ZbXdWERxRxSwo3txsBjjmc/NLxqb1Bk30mRb0BMS4YIaiV6zvKZqL/UAH+DdqcDYayDWk2n/y8klkBDODrPvA==",
"dependencies": {
"mitt": "3.0.0"
},
@ -10109,7 +10109,7 @@
"license": "Apache-2.0",
"dependencies": {
"@puppeteer/browsers": "1.4.2",
"chromium-bidi": "0.4.15",
"chromium-bidi": "0.4.16",
"cross-fetch": "3.1.6",
"debug": "4.3.4",
"devtools-protocol": "0.0.1135028",
@ -12230,9 +12230,9 @@
}
},
"chromium-bidi": {
"version": "0.4.15",
"resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.4.15.tgz",
"integrity": "sha512-uvWG7BrvxEqQDRCMET5FsgpoyGEqebCOL1jPbnH9rxaCFHPKd2Z8lQVnhz8ZwFfwYyQYm212xLjmrVlTIxsSVA==",
"version": "0.4.16",
"resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.4.16.tgz",
"integrity": "sha512-7ZbXdWERxRxSwo3txsBjjmc/NLxqb1Bk30mRb0BMS4YIaiV6zvKZqL/UAH+DdqcDYayDWk2n/y8klkBDODrPvA==",
"requires": {
"mitt": "3.0.0"
}
@ -15653,7 +15653,7 @@
"version": "file:packages/puppeteer-core",
"requires": {
"@puppeteer/browsers": "1.4.2",
"chromium-bidi": "0.4.15",
"chromium-bidi": "0.4.16",
"cross-fetch": "3.1.6",
"debug": "4.3.4",
"devtools-protocol": "0.0.1135028",

View File

@ -141,7 +141,7 @@
"author": "The Chromium Authors",
"license": "Apache-2.0",
"dependencies": {
"chromium-bidi": "0.4.15",
"chromium-bidi": "0.4.16",
"cross-fetch": "3.1.6",
"debug": "4.3.4",
"devtools-protocol": "0.0.1135028",

View File

@ -41,8 +41,9 @@ const enum InputId {
Finger = '__puppeteer_finger',
}
const getBidiKeyValue = (key: string) => {
const getBidiKeyValue = (key: KeyInput) => {
switch (key) {
case '\r':
case '\n':
key = 'Enter';
break;
@ -52,8 +53,6 @@ const getBidiKeyValue = (key: string) => {
return key;
}
switch (key) {
case 'Unidentified':
return '\uE000';
case 'Cancel':
return '\uE001';
case 'Help':
@ -64,22 +63,21 @@ const getBidiKeyValue = (key: string) => {
return '\uE004';
case 'Clear':
return '\uE005';
case 'Return':
return '\uE006';
case 'Enter':
return '\uE007';
case 'Shift':
case 'ShiftLeft':
return '\uE008';
case 'Control':
case 'ControlLeft':
return '\uE009';
case 'Alt':
case 'AltLeft':
return '\uE00A';
case 'Pause':
return '\uE00B';
case 'Escape':
return '\uE00C';
case ' ':
return '\uE00D';
case 'PageUp':
return '\uE00E';
case 'PageDown':
@ -100,41 +98,37 @@ const getBidiKeyValue = (key: string) => {
return '\uE016';
case 'Delete':
return '\uE017';
case ';':
return '\uE018';
case '=':
case 'NumpadEqual':
return '\uE019';
case '0':
case 'Numpad0':
return '\uE01A';
case '1':
case 'Numpad1':
return '\uE01B';
case '2':
case 'Numpad2':
return '\uE01C';
case '3':
case 'Numpad3':
return '\uE01D';
case '4':
case 'Numpad4':
return '\uE01E';
case '5':
case 'Numpad5':
return '\uE01F';
case '6':
case 'Numpad6':
return '\uE020';
case '7':
case 'Numpad7':
return '\uE021';
case '8':
case 'Numpad8':
return '\uE022';
case '9':
case 'Numpad9':
return '\uE023';
case '*':
case 'NumpadMultiply':
return '\uE024';
case '+':
case 'NumpadAdd':
return '\uE025';
case ',':
return '\uE026';
case '-':
case 'NumpadSubtract':
return '\uE027';
case '.':
case 'NumpadDecimal':
return '\uE028';
case '/':
case 'NumpadDivide':
return '\uE029';
case 'F1':
return '\uE031';
@ -161,9 +155,110 @@ const getBidiKeyValue = (key: string) => {
case 'F12':
return '\uE03C';
case 'Meta':
case 'MetaLeft':
return '\uE03D';
case 'ZenkakuHankaku':
return '\uE040';
case 'ShiftRight':
return '\uE050';
case 'ControlRight':
return '\uE051';
case 'AltRight':
return '\uE052';
case 'MetaRight':
return '\uE053';
case 'Digit0':
return '0';
case 'Digit1':
return '1';
case 'Digit2':
return '2';
case 'Digit3':
return '3';
case 'Digit4':
return '4';
case 'Digit5':
return '5';
case 'Digit6':
return '6';
case 'Digit7':
return '7';
case 'Digit8':
return '8';
case 'Digit9':
return '9';
case 'KeyA':
return 'a';
case 'KeyB':
return 'b';
case 'KeyC':
return 'c';
case 'KeyD':
return 'd';
case 'KeyE':
return 'e';
case 'KeyF':
return 'f';
case 'KeyG':
return 'g';
case 'KeyH':
return 'h';
case 'KeyI':
return 'i';
case 'KeyJ':
return 'j';
case 'KeyK':
return 'k';
case 'KeyL':
return 'l';
case 'KeyM':
return 'm';
case 'KeyN':
return 'n';
case 'KeyO':
return 'o';
case 'KeyP':
return 'p';
case 'KeyQ':
return 'q';
case 'KeyR':
return 'r';
case 'KeyS':
return 's';
case 'KeyT':
return 't';
case 'KeyU':
return 'u';
case 'KeyV':
return 'v';
case 'KeyW':
return 'w';
case 'KeyX':
return 'x';
case 'KeyY':
return 'y';
case 'KeyZ':
return 'z';
case 'Semicolon':
return ';';
case 'Equal':
return '=';
case 'Comma':
return ',';
case 'Minus':
return '-';
case 'Period':
return '.';
case 'Slash':
return '/';
case 'Backquote':
return '`';
case 'BracketLeft':
return '[';
case 'Backslash':
return '\\';
case 'BracketRight':
return ']';
case 'Quote':
return '"';
default:
throw new Error(`Unknown key: "${key}"`);
}
@ -185,11 +280,8 @@ export class Keyboard extends BaseKeyboard {
override async down(
key: KeyInput,
options?: Readonly<KeyDownOptions>
_options?: Readonly<KeyDownOptions>
): Promise<void> {
if (options) {
throw new Error('KeyDownOptions are not supported');
}
await this.#context.connection.send('input.performActions', {
context: this.#context.id,
actions: [
@ -265,7 +357,7 @@ export class Keyboard extends BaseKeyboard {
const {delay = 0} = options;
// This spread separates the characters into code points rather than UTF-16
// code units.
const values = [...text].map(getBidiKeyValue);
const values = ([...text] as KeyInput[]).map(getBidiKeyValue);
const actions: Bidi.Input.KeySourceAction[] = [];
if (delay <= 0) {
for (const value of values) {

View File

@ -65,6 +65,18 @@
"parameters": ["webDriverBiDi"],
"expectations": ["PASS"]
},
{
"testIdPattern": "[function.spec] Function interpolateFunction should work",
"platforms": ["darwin", "linux", "win32"],
"parameters": [],
"expectations": ["PASS"]
},
{
"testIdPattern": "[function.spec] Function interpolateFunction should work inlined",
"platforms": ["darwin", "linux", "win32"],
"parameters": [],
"expectations": ["PASS"]
},
{
"testIdPattern": "[jshandle.spec] *",
"platforms": ["darwin", "linux", "win32"],
@ -445,16 +457,10 @@
},
{
"testIdPattern": "[click.spec] Page.click should select the text by triple clicking",
"platforms": ["linux", "win32"],
"platforms": ["darwin", "linux", "win32"],
"parameters": ["webDriverBiDi"],
"expectations": ["PASS"]
},
{
"testIdPattern": "[click.spec] Page.click should select the text by triple clicking",
"platforms": ["darwin"],
"parameters": ["webDriverBiDi"],
"expectations": ["FAIL"]
},
{
"testIdPattern": "[Connection.spec] WebDriver BiDi Connection should work",
"platforms": ["darwin", "linux", "win32"],
@ -683,6 +689,12 @@
"parameters": ["webDriverBiDi"],
"expectations": ["FAIL", "PASS"]
},
{
"testIdPattern": "[keyboard.spec] Keyboard ElementHandle.press should not support |text| option",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["webDriverBiDi"],
"expectations": ["PASS"]
},
{
"testIdPattern": "[keyboard.spec] Keyboard should move with the arrow keys",
"platforms": ["darwin", "linux", "win32"],
@ -725,12 +737,36 @@
"parameters": ["webDriverBiDi"],
"expectations": ["PASS"]
},
{
"testIdPattern": "[keyboard.spec] Keyboard should specify location",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["webDriverBiDi"],
"expectations": ["PASS"]
},
{
"testIdPattern": "[keyboard.spec] Keyboard should specify repeat property",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["webDriverBiDi"],
"expectations": ["PASS"]
},
{
"testIdPattern": "[keyboard.spec] Keyboard should throw on unknown keys",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["webDriverBiDi"],
"expectations": ["PASS"]
},
{
"testIdPattern": "[keyboard.spec] Keyboard should trigger commands of keyboard shortcuts",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["webDriverBiDi"],
"expectations": ["PASS"]
},
{
"testIdPattern": "[keyboard.spec] Keyboard should type all kinds of characters",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["webDriverBiDi"],
"expectations": ["PASS"]
},
{
"testIdPattern": "[keyboard.spec] Keyboard should type emoji",
"platforms": ["darwin", "linux", "win32"],
@ -755,6 +791,12 @@
"parameters": ["webDriverBiDi"],
"expectations": ["FAIL", "PASS"]
},
{
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.connect should support targetFilter option",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["chrome", "webDriverBiDi"],
"expectations": ["PASS"]
},
{
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.executablePath returns executablePath for channel",
"platforms": ["darwin", "linux", "win32"],
@ -2081,6 +2123,12 @@
"parameters": ["firefox", "webDriverBiDi"],
"expectations": ["FAIL"]
},
{
"testIdPattern": "[keyboard.spec] Keyboard ElementHandle.press should not support |text| option",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["cdp", "chrome"],
"expectations": ["FAIL"]
},
{
"testIdPattern": "[keyboard.spec] Keyboard ElementHandle.press should support |text| option",
"platforms": ["darwin", "linux", "win32"],
@ -2123,6 +2171,18 @@
"parameters": ["firefox", "webDriverBiDi"],
"expectations": ["PASS"]
},
{
"testIdPattern": "[keyboard.spec] Keyboard should report multiple modifiers",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["chrome", "webDriverBiDi"],
"expectations": ["PASS"]
},
{
"testIdPattern": "[keyboard.spec] Keyboard should report shiftKey",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["chrome", "webDriverBiDi"],
"expectations": ["PASS"]
},
{
"testIdPattern": "[keyboard.spec] Keyboard should report shiftKey",
"platforms": ["darwin"],
@ -2153,12 +2213,6 @@
"parameters": ["cdp", "firefox"],
"expectations": ["FAIL"]
},
{
"testIdPattern": "[keyboard.spec] Keyboard should trigger commands of keyboard shortcuts",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["cdp", "firefox"],
"expectations": ["FAIL"]
},
{
"testIdPattern": "[keyboard.spec] Keyboard should type all kinds of characters",
"platforms": ["darwin", "linux", "win32"],
@ -2195,6 +2249,24 @@
"parameters": ["cdp", "firefox"],
"expectations": ["SKIP"]
},
{
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.connect should be able to close remote browser",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["chrome", "webDriverBiDi"],
"expectations": ["PASS"]
},
{
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.connect should be able to connect multiple times to the same browser",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["chrome", "webDriverBiDi"],
"expectations": ["PASS"]
},
{
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.connect should be able to connect to a browser with no page targets",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["chrome", "webDriverBiDi"],
"expectations": ["PASS"]
},
{
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.connect should be able to connect to a browser with no page targets",
"platforms": ["darwin", "linux", "win32"],
@ -2213,6 +2285,12 @@
"parameters": ["cdp", "firefox"],
"expectations": ["SKIP"]
},
{
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.connect should support ignoreHTTPSErrors option",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["chrome", "webDriverBiDi"],
"expectations": ["PASS"]
},
{
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.connect should support targetFilter option",
"platforms": ["darwin", "linux", "win32"],
@ -2325,7 +2403,7 @@
"testIdPattern": "[mouse.spec] Mouse should select the text with mouse",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["chrome", "webDriverBiDi"],
"expectations": ["PASS"]
"expectations": ["FAIL", "PASS"]
},
{
"testIdPattern": "[mouse.spec] Mouse should send mouse wheel events",
@ -2333,6 +2411,12 @@
"parameters": ["cdp", "firefox"],
"expectations": ["FAIL"]
},
{
"testIdPattern": "[mouse.spec] Mouse should set modifier keys on click",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["chrome", "webDriverBiDi"],
"expectations": ["PASS"]
},
{
"testIdPattern": "[mouse.spec] Mouse should trigger hover state",
"platforms": ["darwin", "linux", "win32"],

View File

@ -88,7 +88,7 @@ describe('Keyboard', function () {
// @see https://github.com/puppeteer/puppeteer/issues/1313
it('should trigger commands of keyboard shortcuts', async () => {
const {page, server} = await getTestState();
const cmdKey = os.platform() !== 'darwin' ? 'Meta' : 'Control';
const cmdKey = os.platform() === 'darwin' ? 'Meta' : 'Control';
await page.goto(server.PREFIX + '/input/textarea.html');
await page.type('textarea', 'hello');
@ -104,8 +104,6 @@ describe('Keyboard', function () {
await page.keyboard.down(cmdKey);
await page.keyboard.press('v', {commands: ['Paste']});
await page.keyboard.up(cmdKey);
await page.keyboard.down(cmdKey);
await page.keyboard.press('v', {commands: ['Paste']});
await page.keyboard.up(cmdKey);
@ -144,7 +142,7 @@ describe('Keyboard', function () {
})
).toBe('a');
});
it('ElementHandle.press should support |text| option', async () => {
it('ElementHandle.press should not support |text| option', async () => {
const {page, server} = await getTestState();
await page.goto(server.PREFIX + '/input/textarea.html');
@ -154,7 +152,7 @@ describe('Keyboard', function () {
await page.evaluate(() => {
return document.querySelector('textarea')!.value;
})
).toBe('ё');
).toBe('a');
});
it('should send a character with sendCharacter', async () => {
const {page, server} = await getTestState();
@ -461,25 +459,13 @@ describe('Keyboard', function () {
it('should throw on unknown keys', async () => {
const {page} = await getTestState();
let error = await page.keyboard
const error = await page.keyboard
// @ts-expect-error bad input
.press('NotARealKey')
.catch(error_ => {
return error_;
});
expect(error.message).toBe('Unknown key: "NotARealKey"');
// @ts-expect-error bad input
error = await page.keyboard.press('ё').catch(error_ => {
return error_;
});
expect(error && error.message).toBe('Unknown key: "ё"');
// @ts-expect-error bad input
error = await page.keyboard.press('😊').catch(error_ => {
return error_;
});
expect(error && error.message).toBe('Unknown key: "😊"');
});
it('should type emoji', async () => {
const {page, server} = await getTestState();