summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/uievents/textInput/support/no-textInput.sub.js
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/uievents/textInput/support/no-textInput.sub.js')
-rw-r--r--testing/web-platform/tests/uievents/textInput/support/no-textInput.sub.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/testing/web-platform/tests/uievents/textInput/support/no-textInput.sub.js b/testing/web-platform/tests/uievents/textInput/support/no-textInput.sub.js
new file mode 100644
index 0000000000..332cbf08f2
--- /dev/null
+++ b/testing/web-platform/tests/uievents/textInput/support/no-textInput.sub.js
@@ -0,0 +1,29 @@
+const els = document.querySelectorAll('.test-el');
+const key = "{{GET[key]}}";
+const keyRaw = keyMapping[key] || key;
+const expectedData = key === "Enter" ? "\n" : key;
+const selectionStart = {{GET[selectionStart]}};
+const selectionEnd = {{GET[selectionEnd]}};
+const expectedValue = "{{GET[expectedValue]}}";
+
+for (const el of els) {
+ promise_test(t => {
+ return new Promise((resolve, reject) => {
+ el.addEventListener('textInput', reject);
+ el.addEventListener('keyup', t.step_func(e => {
+ if (e.key !== key) {
+ return;
+ }
+ assert_equals(getValue(el), expectedValue);
+ resolve();
+ }));
+ el.onfocus = t.step_func(e => {
+ if (window.test_driver) {
+ test_driver.send_keys(el, keyRaw);
+ }
+ });
+ el.focus();
+ setSelection(el, selectionStart, selectionEnd);
+ });
+ }, `${document.title}, ${elDesc(el)}`);
+}