WebKit Bugzilla
Attachment 357756 Details for
Bug 192897
: [iOS] Interpret text key commands on keydown and app key commands on keypress
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Layout test (once we fix bug #192898)
text-key-commands-prevent-default.html (text/html), 2.50 KB, created by
Daniel Bates
on 2018-12-19 16:52:11 PST
(
hide
)
Description:
Layout test (once we fix bug #192898)
Filename:
MIME Type:
Creator:
Daniel Bates
Created:
2018-12-19 16:52:11 PST
Size:
2.50 KB
patch
obsolete
><!DOCTYPE html> ><html> ><head> ><script src="../../../resources/js-test.js"></script> ><script src="../../../resources/ui-helper.js"></script> ></head> ><body onload="runTest()"> ><input type="text" id="input" value="Hello from Cupertino!" size="30"> ><script> >window.jsTestIsAsync = true; > >let inputElement; > >let tests = [ > testPreventKeyDownAndMoveToEndOfLine, > testPreventKeyPressAndMoveToEndOfLine, >]; > >let currentTest = 0; > >function runNextTest() >{ > if (currentTest >= tests.length) { > done(); > return; > } > tests[currentTest++](); >} > >function testPreventKeyDownAndMoveToEndOfLine() >{ > debug("Test: Prevent default on key down and move to the end of the line:"); > function checkResult() { > shouldBeZero("inputElement.selectionStart"); > shouldBeZero("inputElement.selectionEnd"); > runNextTest(); > } > inputElement.onkeydown = (event) => { > if (event.key == "Control") > return; > event.preventDefault(); > inputElement.addEventListener("keyup", checkResult, { once: true }); > inputElement.onkeydown = null; > }; > if (window.testRunner) > UIHelper.keyDown("e", ["ctrlKey"]); >} > >function testPreventKeyPressAndMoveToEndOfLine() >{ > debug("<br>Test: Prevent default on key press and move to the end of the line:"); > function checkResult() { > inputElement.onkeypress = null; > shouldBeNonZero("inputElement.selectionStart"); > shouldBeNonZero("inputElement.selectionEnd"); > runNextTest(); > } > inputElement.onkeypress = (event) => event.preventDefault(); > inputElement.onkeydown = (event) => { > if (event.key == "Control") > return; > inputElement.addEventListener("keyup", checkResult, { once: true }); > inputElement.onkeydown = null; > }; > if (window.testRunner) > UIHelper.keyDown("e", ["ctrlKey"]); >} > >function done() >{ > if (window.testRunner) > document.body.removeChild(inputElement); > finishJSTest(); >} > >function runTest() >{ > inputElement = document.getElementById("input"); > function handleFocus() { > // Ensure that the insertion point is at the start of the field. > inputElement.setSelectionRange(0, 0); > runNextTest(); > } > inputElement.addEventListener("focus", handleFocus, { once: true }); > if (window.testRunner) > UIHelper.activateElement(inputElement); > else > inputElement.focus(); >} > >description("Tests that text key commands can be prevented in keydown and not in keypress."); ></script> ></body> ></html>
<!DOCTYPE html> <html> <head> <script src="../../../resources/js-test.js"></script> <script src="../../../resources/ui-helper.js"></script> </head> <body onload="runTest()"> <input type="text" id="input" value="Hello from Cupertino!" size="30"> <script> window.jsTestIsAsync = true; let inputElement; let tests = [ testPreventKeyDownAndMoveToEndOfLine, testPreventKeyPressAndMoveToEndOfLine, ]; let currentTest = 0; function runNextTest() { if (currentTest >= tests.length) { done(); return; } tests[currentTest++](); } function testPreventKeyDownAndMoveToEndOfLine() { debug("Test: Prevent default on key down and move to the end of the line:"); function checkResult() { shouldBeZero("inputElement.selectionStart"); shouldBeZero("inputElement.selectionEnd"); runNextTest(); } inputElement.onkeydown = (event) => { if (event.key == "Control") return; event.preventDefault(); inputElement.addEventListener("keyup", checkResult, { once: true }); inputElement.onkeydown = null; }; if (window.testRunner) UIHelper.keyDown("e", ["ctrlKey"]); } function testPreventKeyPressAndMoveToEndOfLine() { debug("<br>Test: Prevent default on key press and move to the end of the line:"); function checkResult() { inputElement.onkeypress = null; shouldBeNonZero("inputElement.selectionStart"); shouldBeNonZero("inputElement.selectionEnd"); runNextTest(); } inputElement.onkeypress = (event) => event.preventDefault(); inputElement.onkeydown = (event) => { if (event.key == "Control") return; inputElement.addEventListener("keyup", checkResult, { once: true }); inputElement.onkeydown = null; }; if (window.testRunner) UIHelper.keyDown("e", ["ctrlKey"]); } function done() { if (window.testRunner) document.body.removeChild(inputElement); finishJSTest(); } function runTest() { inputElement = document.getElementById("input"); function handleFocus() { // Ensure that the insertion point is at the start of the field. inputElement.setSelectionRange(0, 0); runNextTest(); } inputElement.addEventListener("focus", handleFocus, { once: true }); if (window.testRunner) UIHelper.activateElement(inputElement); else inputElement.focus(); } description("Tests that text key commands can be prevented in keydown and not in keypress."); </script> </body> </html>
View Attachment As Raw
Actions:
View
Attachments on
bug 192897
:
357755
| 357756 |
358656