diff --git a/src/client/automation/playback/type/type-text.js b/src/client/automation/playback/type/type-text.js index 4da58ca14bf..de0702be916 100644 --- a/src/client/automation/playback/type/type-text.js +++ b/src/client/automation/playback/type/type-text.js @@ -145,6 +145,9 @@ function _typeTextToContentEditable (element, text) { var endNode = currentSelection.endPos.node; var needProcessInput = true; var needRaiseInputEvent = true; + var textInputData = text; + + text = text === ' ' ? String.fromCharCode(160) : text; // NOTE: some browsers raise the 'input' event after the element // content is changed, but in others we should do it manually. @@ -156,7 +159,7 @@ function _typeTextToContentEditable (element, text) { // NOTE: IE11 does not raise input event when type to contenteditable var beforeContentChanged = () => { - needProcessInput = simulateTextInput(element, text); + needProcessInput = simulateTextInput(element, textInputData); needRaiseInputEvent = needProcessInput && !browserUtils.isIE11; }; @@ -251,7 +254,7 @@ function _typeTextToNonTextEditable (element, text, caretPos) { export default function (element, text, caretPos) { if (domUtils.isContentEditableElement(element)) - _typeTextToContentEditable(element, text === ' ' ? String.fromCharCode(160) : text); + _typeTextToContentEditable(element, text); if (!domUtils.isElementReadOnly(element)) { if (domUtils.isTextEditableElement(element)) diff --git a/test/client/fixtures/automation/content-editable/regression-test/index-test.js b/test/client/fixtures/automation/content-editable/regression-test/index-test.js index 12800b7ee18..0d5137a303b 100644 --- a/test/client/fixtures/automation/content-editable/regression-test/index-test.js +++ b/test/client/fixtures/automation/content-editable/regression-test/index-test.js @@ -18,8 +18,6 @@ $(document).ready(function () { var secondElementInnerHTML = null; var thirdElementInnerHTML = null; - $('body').css('height', 1500).attr('contenteditable', 'true'); - var startNext = function () { if (browserUtils.isIE) { removeTestElements(); @@ -91,6 +89,7 @@ $(document).ready(function () { var nodeValue = node.nodeValue; var typingText = '123 test'; + $body.css('height', 1500).attr('contenteditable', 'true'); $body.focus(); equal(document.activeElement, $body[0]); @@ -107,7 +106,39 @@ $(document).ready(function () { nodeValue + typingText.replace(' ', String.fromCharCode(160)), 'typing must be in the end of element from a parameter of act.type'); + $body.attr('contenteditable', 'false'); + startNext(); }); }); + + if (!browserUtils.isFirefox) { + asyncTest('textInput eventArgs.data should contain space but not  )', function () { + var editor = document.createElement('div'); + var text = ' '; + var type = new TypeAutomation(editor, text, {}); + + editor.className = TEST_ELEMENT_CLASS; + editor.contentEditable = true; + + document.body.appendChild(editor); + + var onTextInput = function (e) { + equal(e.data, text); + + document.removeEventListener('textInput', onTextInput, true); + document.removeEventListener('textinput', onTextInput, true); + }; + + document.addEventListener('textInput', onTextInput, true); + document.addEventListener('textinput', onTextInput, true); + + type + .run() + .then(function () { + startNext(); + }); + }); + } + });