forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[headless] Added input field clipboard tests.
Test covers select all, copy and paste operations which seem to get broken every now and then for headless. Bug: 1170634 Change-Id: Icb9e93843eafd15a64a5100c30934c62d0d99c1b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2860613 Commit-Queue: Peter Kvitek <kvitekp@chromium.org> Reviewed-by: Andrey Kosyakov <caseq@chromium.org> Cr-Commit-Position: refs/heads/master@{#877725}
- Loading branch information
Peter Kvitek
authored and
Chromium LUCI CQ
committed
Apr 30, 2021
1 parent
bac6fba
commit 185fc1b
Showing
4 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
headless/test/data/protocol/input/input-clipboard-ops-expected.txt
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,4 @@ | ||
Tests input field clipboard operations. | ||
input: input_value | ||
input: abc | ||
input: input_value |
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,52 @@ | ||
// Copyright 2021 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
(async function(testRunner) { | ||
const {page, session, dp} = await testRunner.startBlank( | ||
`Tests input field clipboard operations.`); | ||
|
||
await dp.Page.enable(); | ||
dp.Page.navigate({url: testRunner.url('/resources/input.html')}); | ||
await dp.Page.onceLoadEventFired(); | ||
|
||
async function logElementValue(id) { | ||
const value = await session.evaluate(` | ||
document.getElementById("${id}").value; | ||
`); | ||
testRunner.log(`${id}: ${value}`); | ||
} | ||
|
||
async function sendKey(text, nativeVirtualKeyCode, | ||
modifiers = 0, commands = []) { | ||
await dp.Input.dispatchKeyEvent({ | ||
type: 'keyDown', | ||
modifiers: modifiers, | ||
text: text, | ||
nativeVirtualKeyCode: nativeVirtualKeyCode, | ||
commands: commands | ||
}); | ||
|
||
await dp.Input.dispatchKeyEvent({ | ||
type: 'keyUp', | ||
modifiers: modifiers, | ||
nativeVirtualKeyCode: nativeVirtualKeyCode | ||
}); | ||
} | ||
|
||
await logElementValue("input"); | ||
await sendKey('a', 65, 2, ["selectAll"]); | ||
await sendKey('c', 67, 2, ["copy"]); | ||
|
||
await sendKey('a', 65); | ||
await sendKey('b', 66); | ||
await sendKey('c', 67); | ||
await logElementValue("input"); | ||
|
||
await sendKey('a', 65, 2, ["selectAll"]); | ||
await sendKey('c', 67, 2, ["paste"]); | ||
await logElementValue("input"); | ||
|
||
testRunner.completeTest(); | ||
}) | ||
|
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,3 @@ | ||
<html> <body> | ||
<input type="text" id="input" value="input_value" autofocus> | ||
</body></html> |
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