Skip to content

Commit

Permalink
refactor: removed IE leftovers from test\client (DevExpress#7964)
Browse files Browse the repository at this point in the history
<!--
Thank you for your contribution.

Before making a PR, please read our contributing guidelines at

https://github.com/DevExpress/testcafe/blob/master/CONTRIBUTING.md#code-contribution

We recommend creating a *draft* PR, so that you can mark it as 'ready
for review' when you are done.
-->

## Purpose
_Describe the problem you want to address or the feature you want to
implement._

## Approach
_Describe how your changes address the issue or implement the desired
functionality in as much detail as possible._

## References
_Provide a link to the existing issue(s), if any._

## Pre-Merge TODO
- [ ] Write tests for your proposed changes
- [ ] Make sure that existing tests do not fail
  • Loading branch information
Aleksey28 authored Aug 22, 2023
1 parent 5c58735 commit 0bdd78a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 39 deletions.
25 changes: 3 additions & 22 deletions test/client/before-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
}

//Hammerhead setup
const hammerhead = getTestCafeModule('hammerhead');
const INSTRUCTION = hammerhead.PROCESSING_INSTRUCTIONS.dom.script;
const location = 'http://localhost/sessionId/https://example.com';
const browserUtils = hammerhead.utils.browser;
const hammerhead = getTestCafeModule('hammerhead');
const INSTRUCTION = hammerhead.PROCESSING_INSTRUCTIONS.dom.script;
const location = 'http://localhost/sessionId/https://example.com';

hammerhead.utils.destLocation.forceLocation(location);

Expand Down Expand Up @@ -73,24 +72,6 @@

sandboxedJQuery.init(window);

// NOTE: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/17477979/
window.DIRECTION_ALWAYS_IS_FORWARD = false;

if (browserUtils.isMSEdge && browserUtils.version >= 17) {
$(function () {
const nativeMethods = hammerhead.nativeMethods;
const input = nativeMethods.createElement.call(document, 'input');

nativeMethods.appendChild.call(document.body, input);
nativeMethods.inputValueSetter.call(input, 'text');
nativeMethods.setSelectionRange.call(input, 0, 2, 'backward');

window.DIRECTION_ALWAYS_IS_FORWARD = input.selectionDirection === 'forward';

nativeMethods.removeChild.call(document.body, input);
});
}

//Tests API
window.getTestCafeModule = getTestCafeModule;
window.getProperty = window[INSTRUCTION.getProperty];
Expand Down
4 changes: 1 addition & 3 deletions test/client/fixtures/automation/automations-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,7 @@ $(document).ready(function () {
equal(domUtils.getActiveElement(), el, 'selected element is active');
equal(textSelection.getSelectionStart(el), start, 'start selection correct');
equal(textSelection.getSelectionEnd(el), end, 'end selection correct');

if (!window.DIRECTION_ALWAYS_IS_FORWARD)
equal(textSelection.hasInverseSelection(el), inverse, 'selection direction correct');
equal(textSelection.hasInverseSelection(el), inverse, 'selection direction correct');
};

const preventDefault = function (e) {
Expand Down
3 changes: 1 addition & 2 deletions test/client/fixtures/automation/press-shortcuts-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ $(document).ready(function () {
equal(textSelection.getSelectionStart(activeElement), selectionStart, 'active element selection start are correct');
equal(textSelection.getSelectionEnd(activeElement), selectionEnd, 'active element selection end are correct');

if (!window.DIRECTION_ALWAYS_IS_FORWARD)
ok(inverseSelection === (typeof inverse === 'undefined' ? false : inverse));
ok(inverseSelection === (typeof inverse === 'undefined' ? false : inverse));
};

const runPressAutomation = function (keySequence, callback) {
Expand Down
4 changes: 1 addition & 3 deletions test/client/fixtures/automation/regression-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -734,9 +734,7 @@ $(document).ready(function () {
.then(function () {
equal(textSelection.getSelectionStart(input), startPos, 'start selection correct');
equal(textSelection.getSelectionEnd(input), endPos, 'end selection correct');

if (!window.DIRECTION_ALWAYS_IS_FORWARD)
equal(textSelection.hasInverseSelection(input), backward, 'selection direction correct');
equal(textSelection.hasInverseSelection(input), backward, 'selection direction correct');

startNext();
});
Expand Down
16 changes: 7 additions & 9 deletions test/client/fixtures/automation/select-test/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ $(document).ready(function () {
equal(domUtils.getActiveElement(), el, 'selected element is active');
equal(textSelection.getSelectionStart(el), start, 'start selection correct');
equal(textSelection.getSelectionEnd(el), end, 'end selection correct');

if (!window.DIRECTION_ALWAYS_IS_FORWARD)
equal(textSelection.hasInverseSelection(el), inverse || false, 'selection direction correct');
equal(textSelection.hasInverseSelection(el), inverse || false, 'selection direction correct');
}

function restorePageState () {
Expand Down Expand Up @@ -300,7 +298,7 @@ $(document).ready(function () {
if (checkScrollAfterSelect)
ok(style.getElementScroll(input).left > 0);

expect((checkScrollAfterSelect ? 9 : 7) - Number(window.DIRECTION_ALWAYS_IS_FORWARD));
expect(checkScrollAfterSelect ? 9 : 7);

startNext();
});
Expand Down Expand Up @@ -345,7 +343,7 @@ $(document).ready(function () {
if (checkScrollAfterSelect)
ok(style.getElementScroll(input).left < oldScroll);

expect((checkScrollAfterSelect ? 9 : 6) - Number(window.DIRECTION_ALWAYS_IS_FORWARD));
expect(checkScrollAfterSelect ? 9 : 6);

startNext();
});
Expand Down Expand Up @@ -393,7 +391,7 @@ $(document).ready(function () {
if (checkScrollAfterSelect)
ok(style.getElementScroll(textarea).top > 0);

expect((checkScrollAfterSelect ? 9 : 7) - Number(window.DIRECTION_ALWAYS_IS_FORWARD));
expect(checkScrollAfterSelect ? 9 : 7);

startNext();
});
Expand Down Expand Up @@ -439,7 +437,7 @@ $(document).ready(function () {
if (checkScrollAfterSelect)
ok(style.getElementScroll(textarea).top > 0);

expect((checkScrollAfterSelect ? 9 : 7) - Number(window.DIRECTION_ALWAYS_IS_FORWARD));
expect(checkScrollAfterSelect ? 9 : 7);

startNext();
});
Expand Down Expand Up @@ -488,7 +486,7 @@ $(document).ready(function () {
if (checkScrollAfterSelect)
ok(style.getElementScroll(textarea).top < oldScroll);

expect((checkScrollAfterSelect ? 9 : 6) - Number(window.DIRECTION_ALWAYS_IS_FORWARD));
expect(checkScrollAfterSelect ? 9 : 6);

startNext();
});
Expand Down Expand Up @@ -537,7 +535,7 @@ $(document).ready(function () {
if (checkScrollAfterSelect)
ok(style.getElementScroll(textarea).top < oldScroll);

expect((checkScrollAfterSelect ? 9 : 6) - Number(window.DIRECTION_ALWAYS_IS_FORWARD));
expect(checkScrollAfterSelect ? 9 : 6);

startNext();
});
Expand Down

0 comments on commit 0bdd78a

Please sign in to comment.