Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKamaev committed Apr 17, 2018
1 parent 17b3c67 commit 98b99a6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
5 changes: 4 additions & 1 deletion src/client/automation/playback/type/type-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,11 @@ function _excludeInvisibleSymbolsFromSelection (selection) {
}

// NOTE: typing can be prevented in Chrome/Edge but can not be prevented in IE11 or Firefox
// Firefox does not support TextInput event
// Safari support TextInput event but adds e.data to node value. So let's ignore it
function simulateTextInput (element, text) {
const isInputEventRequired = eventSimulator.textInput(element, text);
const isTextInputIgnoredByBrowser = [ browserUtils.isFirefox, browserUtils.isSafari ].some(browser => browser);
const isInputEventRequired = isTextInputIgnoredByBrowser || eventSimulator.textInput(element, text);

return isInputEventRequired || browserUtils.isIE11 || browserUtils.isFirefox;
}
Expand Down
44 changes: 22 additions & 22 deletions test/functional/fixtures/regression/gh-1956/test.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,16 @@
var expect = require('chai').expect;

describe('Should support TextInput event[Regression](GH-1956)', function () {
it('Modify text node of ContentEditable div on TextInput event and prevent Input event', function () {
return runTests('testcafe-fixtures/index.js',
'Modify text node of ContentEditable div on TextInput event and prevent Input event',
{ skip: [ 'firefox', 'ie' ] });
});

it('Type to ContentEditable div when selected node was replaced on TextInput event', function () {
return runTests('testcafe-fixtures/index.js',
'Type to ContentEditable div when selected node was replaced on TextInput event',
{ skip: [ 'firefox', 'ie' ] });
});

it('Prevent Input event on TextInput when type to element node', function () {
return runTests('testcafe-fixtures/index.js',
'Prevent Input event on TextInput when type to element node',
{ skip: [ 'firefox', 'ie' ] });
});

it('Prevent Input event on TextInput when type to input element', function () {
return runTests('testcafe-fixtures/index.js',
'Prevent Input event on TextInput when type to input element',
{ skip: [ 'ie', 'firefox' ] });
{ skip: [ 'ie', 'safari', 'firefox', 'firefox-osx' ] });
});

it('Prevent Input event on TextInput when type to input element IE11/Firefox', function () {
return runTests('testcafe-fixtures/index.js',
'Prevent Input event on TextInput when type to input element IE11/Firefox',
{ only: [ 'ie', 'firefox' ], shouldFail: true })
{ only: [ 'ie', 'firefox', 'firefox-osx' ], shouldFail: true })
.catch(function (errs) {
expect(errs['ie'][0]).contains('Input event has raised');
expect(errs['firefox'][0]).contains('Input event has raised');
Expand All @@ -38,7 +20,7 @@ describe('Should support TextInput event[Regression](GH-1956)', function () {
it('Prevent Input event on TextInput when type to ContentEditable div', function () {
return runTests('testcafe-fixtures/index.js',
'Prevent Input event on TextInput when type to ContentEditable div',
{ skip: [ 'ie', 'firefox' ] });
{ skip: [ 'ie', 'safari', 'firefox', 'firefox-osx' ] });
});

it('Prevent Input event on TextInput when type to ContentEditable div IE11', function () {
Expand All @@ -50,9 +32,27 @@ describe('Should support TextInput event[Regression](GH-1956)', function () {
it('Prevent Input event on TextInput when type to ContentEditable div Firefox', function () {
return runTests('testcafe-fixtures/index.js',
'Prevent Input event on TextInput when type to ContentEditable div IE11/Firefox',
{ only: [ 'firefox' ], shouldFail: true })
{ only: [ 'firefox', 'firefox-osx' ], shouldFail: true })
.catch(function (errs) {
expect(errs[0]).contains('Input event has raised');
});
});

it('Modify text node of ContentEditable div on TextInput event and prevent Input event', function () {
return runTests('testcafe-fixtures/index.js',
'Modify text node of ContentEditable div on TextInput event and prevent Input event',
{ skip: [ 'ie', 'safari', 'firefox', 'firefox-osx' ] });
});

it('Type to ContentEditable div when selected node was replaced on TextInput event', function () {
return runTests('testcafe-fixtures/index.js',
'Type to ContentEditable div when selected node was replaced on TextInput event',
{ skip: [ 'ie', 'safari', 'firefox', 'firefox-osx' ] });
});

it('Prevent Input event on TextInput when type to element node', function () {
return runTests('testcafe-fixtures/index.js',
'Prevent Input event on TextInput when type to element node',
{ skip: [ 'ie', 'safari', 'firefox', 'firefox-osx' ] });
});
});

0 comments on commit 98b99a6

Please sign in to comment.