Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Unified Diff: third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-execcommand.html

Issue 2074423004: [InputEvent] Dispatch 'input' event for ContentEditable and typing on Input element (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tkent's review Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-execcommand.html
diff --git a/third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-execcommand.html b/third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-execcommand.html
new file mode 100644
index 0000000000000000000000000000000000000000..c1b23b230ffb4ccbc959c4c59253e3170624936c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-execcommand.html
@@ -0,0 +1,60 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>InputEvent: execCommand test</title>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+</head>
+<body>
+<p id="txt" contenteditable></p>
+<script>
+test(function() {
+ var lastBeforeInputType = '';
+ var lastInputType = '';
+ var txt = document.getElementById('txt');
+ txt.addEventListener('beforeinput', function(event) {
+ assert_true(event instanceof InputEvent);
+ assert_false(event.isComposing);
+ lastBeforeInputType = event.inputType;
+ });
+ txt.addEventListener('input', function(event) {
+ assert_true(event instanceof InputEvent);
+ assert_false(event.isComposing);
+ lastInputType = event.inputType;
+ });
+ if (!window.eventSender) {
+ document.write('This test requires eventSender');
+ } else {
+ var kNoInputEventFired = 'noInputEventFired';
+ function testExecCommandInputType(command, args, inputType) {
+ lastBeforeInputType = kNoInputEventFired;
+ lastInputType = kNoInputEventFired;
+ document.execCommand(command, false, args);
+ assert_equals(lastBeforeInputType, kNoInputEventFired, `execCommand(${command}, false, ${args}) shouldn't fire beforeinput`);
+ assert_equals(lastInputType, inputType, `execCommand(${command}, false, ${args}) should produce inputType: ${inputType}`);
+ }
+
+ txt.focus();
+ // InsertText
+ testExecCommandInputType('insertText', 'a', 'insertText');
+ testExecCommandInputType('insertText', 'bc', 'insertText');
+ assert_equals('abc', txt.innerHTML);
+
+ // Styling
+ var selection = window.getSelection();
+ selection.collapse(txt, 0);
+ selection.extend(txt, 1);
+ // TODO(chongz): Add |inputType| for 'bold'.
+ testExecCommandInputType('bold', 'bc', '');
+ assert_equals('<b>abc</b>', txt.innerHTML);
+
+ // Copy shouldn't fire 'input'.
+ testExecCommandInputType('copy', null, kNoInputEventFired);
+ // Paste should fire 'input'.
+ // TODO(chongz): Add |inputType| for 'paste'.
+ testExecCommandInputType('paste', null, '');
+ }
+}, 'Testing input with execCommand');
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698