Skip to content

Commit

Permalink
update hammerhead (DevExpress#2368)
Browse files Browse the repository at this point in the history
* update hammerhead

* bump version

* Downgrade Edge version in client tests

* renaming
  • Loading branch information
LavrovArtem authored and miherlosev committed May 4, 2018
1 parent b2fad22 commit 58e3624
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 50 deletions.
3 changes: 2 additions & 1 deletion Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ var CLIENT_TESTS_LEGACY_SETTINGS = assignIn({}, CLIENT_TESTS_SETTINGS_BASE, { ba
var CLIENT_TESTS_DESKTOP_BROWSERS = [
{
platform: 'Windows 10',
browserName: 'microsoftedge'
browserName: 'microsoftedge',
version: '16.16299'
},
{
platform: 'Windows 10',
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "testcafe",
"description": "Automated browser testing for the modern web development stack.",
"license": "MIT",
"version": "0.20.0-alpha.2",
"version": "0.20.0-alpha.3",
"author": {
"name": "Developer Express Inc.",
"url": "https://www.devexpress.com/"
Expand Down Expand Up @@ -104,7 +104,7 @@
"source-map-support": "^0.4.0",
"strip-bom": "^2.0.0",
"testcafe-browser-tools": "1.5.1",
"testcafe-hammerhead": "13.4.2",
"testcafe-hammerhead": "13.4.3",
"testcafe-legacy-api": "3.1.7",
"testcafe-reporter-json": "^2.1.0",
"testcafe-reporter-list": "^2.1.0",
Expand All @@ -130,7 +130,7 @@
"cross-spawn": "^4.0.0",
"del": "^2.2.0",
"dom-walk": "^0.1.1",
"eslint-plugin-hammerhead": "0.1.8",
"eslint-plugin-hammerhead": "0.1.9",
"express": "^4.13.3",
"express-ntlm": "^2.1.5",
"gulp": "^3.9.0",
Expand Down
8 changes: 5 additions & 3 deletions src/client/automation/get-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import cursor from './cursor';

var browserUtils = hammerhead.utils.browser;
var Promise = hammerhead.Promise;
var nativeMethods = hammerhead.nativeMethods;
var positionUtils = testCafeCore.positionUtils;
var domUtils = testCafeCore.domUtils;

Expand All @@ -29,7 +30,8 @@ function ensureImageMap (imgElement, areaElement) {

function findElementOrNonEmptyChildFromPoint (x, y, element) {
var topElement = positionUtils.getElementFromPoint(x, y);
var isNonEmptyChild = domUtils.containsElement(element, topElement) && topElement.textContent.length;
var isNonEmptyChild = domUtils.containsElement(element, topElement) &&
nativeMethods.nodeTextContentGetter.call(topElement).length;

if (topElement && topElement === element || isNonEmptyChild)
return topElement;
Expand Down Expand Up @@ -64,10 +66,10 @@ function correctTopElementByExpectedElement (topElement, expectedElement) {

var isTopElementChildOfLink = isLinkOrChildExpected &&
domUtils.containsElement(expectedElement, topElement) &&
topElement.textContent.length;
nativeMethods.nodeTextContentGetter.call(topElement).length;

var shouldSearchForMultilineLink = isLinkOrChildExpected && !isTopElementChildOfLink &&
expectedElement.textContent.length;
nativeMethods.nodeTextContentGetter.call(expectedElement).length;

if (!shouldSearchForMultilineLink)
return topElement;
Expand Down
3 changes: 2 additions & 1 deletion src/client/automation/playback/move/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,10 +443,11 @@ export default class MoveAutomation {
var srcAttr = isLink ? 'href' : 'src';
var parsedUrl = urlUtils.parseProxyUrl(this.dragElement[srcAttr]);
var src = parsedUrl ? parsedUrl.destUrl : this.dragElement[srcAttr];
var outerHTML = htmlUtils.cleanUpHtml(nativeMethods.elementOuterHTMLGetter.call(this.dragElement));

this.dragAndDropState.dataTransfer.setData('text/plain', src);
this.dragAndDropState.dataTransfer.setData('text/uri-list', src);
this.dragAndDropState.dataTransfer.setData('text/html', htmlUtils.cleanUpHtml(this.dragElement.outerHTML));
this.dragAndDropState.dataTransfer.setData('text/html', outerHTML);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/client/automation/playback/select/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function createFakeDiv (element) {
height: element.scrollHeight + 'px'
});

fakeDiv.textContent = domUtils.getElementValue(element) + ' ';
hammerhead.nativeMethods.nodeTextContentSetter.call(fakeDiv, domUtils.getElementValue(element) + ' ');

body.appendChild(fakeDiv);

Expand Down
21 changes: 10 additions & 11 deletions src/client/automation/playback/type/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var SPECIAL_KEYS = testCafeCore.KEY_MAPS.specialKeys;
export default class TypeAutomation {
constructor (element, text, typeOptions) {
this.element = TypeAutomation.findTextEditableChild(element) || element;
this.text = text.toString();
this.typingText = text.toString();

this.modifiers = typeOptions.modifiers;
this.caretPos = typeOptions.caretPos;
Expand Down Expand Up @@ -171,14 +171,14 @@ export default class TypeAutomation {
}

_isTypingFinished () {
return this.currentPos === this.text.length;
return this.currentPos === this.typingText.length;
}

_typingStep () {
var char = this.text.charAt(this.currentPos);
var char = this.typingText.charAt(this.currentPos);

this.currentKeyCode = getKeyCode(char);
this.currentCharCode = this.text.charCodeAt(this.currentPos);
this.currentCharCode = this.typingText.charCodeAt(this.currentPos);
this.currentKey = this.currentKeyCode === SPECIAL_KEYS['enter'] ? 'Enter' : char;
this.currentKeyIdentifier = getKeyIdentifier(this.currentKey);

Expand Down Expand Up @@ -222,7 +222,7 @@ export default class TypeAutomation {
eventSimulator.keyup(this.eventArgs.element, this.eventArgs.options);

if (shouldTypeAllText)
this.currentPos = this.text.length;
this.currentPos = this.typingText.length;
else
this.currentPos++;
});
Expand All @@ -237,16 +237,15 @@ export default class TypeAutomation {
return delay(this.automationSettings.keyActionStepDelay);
}

var currentChar = this.text.charAt(this.currentPos);
var currentChar = this.typingText.charAt(this.currentPos);
var isDigit = /^\d$/.test(currentChar);
var prevChar = this.currentPos === 0 ? null : this.text.charAt(this.currentPos - 1);
var isInputTypeNumber = domUtils.isInputElement(element) &&
element.type === 'number';
var prevChar = this.currentPos === 0 ? null : this.typingText.charAt(this.currentPos - 1);
var isInputTypeNumber = domUtils.isInputElement(element) && element.type === 'number';

if (isInputTypeNumber) {
var selectionStart = textSelection.getSelectionStart(element);
var valueLength = domUtils.getInputValue(element).length;
var textHasDigits = /^\d/.test(this.text);
var textHasDigits = /^\d/.test(this.typingText);
var isPermissibleSymbol = currentChar === '.' || currentChar === '-' && valueLength;

if (!isDigit && (textHasDigits || !isPermissibleSymbol || selectionStart !== 0))
Expand All @@ -264,7 +263,7 @@ export default class TypeAutomation {
}

_typeAllText (element) {
typeText(element, this.text, this.caretPos);
typeText(element, this.typingText, this.caretPos);
return delay(this.automationSettings.keyActionStepDelay);
}

Expand Down
3 changes: 2 additions & 1 deletion src/client/browser/idle-page/status-indicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ export default class StatusIndicator {
static _createStatusMessage (connected) {
var statusSpan = StatusIndicator._getStatusElementSpan();

statusSpan.className = connected ? CONNECTED_CLASS_NAME : DISCONNECTED_CLASS_NAME;
// eslint-disable-next-line no-restricted-properties
statusSpan.textContent = connected ? CONNECTED_TEXT : DISCONNECTED_TEXT;
statusSpan.className = connected ? CONNECTED_CLASS_NAME : DISCONNECTED_CLASS_NAME;
}

static _alignContainerVertically () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@ import {
ELEMENT_SNAPSHOT_PROPERTIES
} from '../../../../../client-functions/selectors/snapshot-properties';

import {
getAttrs,
getTextContent,
getClassName,
getInnerText
} from './sandboxed-node-properties';
import { getAttrs } from './sandboxed-node-properties';


// Node
var nodeSnapshotPropertyInitializers = {
textContent: getTextContent,
// eslint-disable-next-line no-restricted-properties
textContent: node => node.textContent,
childNodeCount: node => node.childNodes.length,
hasChildNodes: node => !!nodeSnapshotPropertyInitializers.childNodeCount(node),

Expand Down Expand Up @@ -92,7 +88,7 @@ var elementSnapshotPropertyInitializers = {
},

classNames: element => {
var className = getClassName(element);
var className = element.className;

className = typeof className.animVal === 'string' ? className.animVal : className;

Expand All @@ -114,7 +110,8 @@ var elementSnapshotPropertyInitializers = {
return result;
},

innerText: getInnerText
// eslint-disable-next-line no-restricted-properties
innerText: element => element.innerText
};

export class ElementSnapshot extends NodeSnapshot {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,4 @@ function sandboxed (fn) {
return evalFunction(code, null);
}

export var getAttrs = sandboxed(element => element.attributes);
export var getTextContent = sandboxed(node => node.textContent);
export var getClassName = sandboxed(element => element.className);
export var getInnerText = sandboxed(element => element.innerText);
export var getAttrs = sandboxed(element => element.attributes);
1 change: 1 addition & 0 deletions src/client/driver/command-executors/execute-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ class ActionExecutor {
return new DragToElementAutomation(this.elements[0], this.elements[1], this.command.options);

case COMMAND_TYPE.typeText:
// eslint-disable-next-line no-restricted-properties
return new TypeAutomation(this.elements[0], this.command.text, this.command.options);

case COMMAND_TYPE.selectText:
Expand Down
1 change: 1 addition & 0 deletions src/client/driver/native-dialog-tracker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default class NativeDialogTracker {
var msg = e.message;

if (msg.type === MESSAGE_TYPE.appearedDialog)
// eslint-disable-next-line no-restricted-properties
this._addAppearedDialogs(msg.dialogType, msg.text, msg.url);

else if (msg.type === MESSAGE_TYPE.unexpectedDialog && !this.unexpectedDialog)
Expand Down
5 changes: 3 additions & 2 deletions src/client/ui/modal-background.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ function createBackground () {
root.appendChild(backgroundDiv);
shadowUI.addClass(backgroundDiv, BACKGROUND_CLASS);

loadingTextDiv = document.createElement('div');
loadingTextDiv.textContent = LOADING_TEXT;
loadingTextDiv = document.createElement('div');

nativeMethods.nodeTextContentSetter.call(loadingTextDiv, LOADING_TEXT);
root.appendChild(loadingTextDiv);
shadowUI.addClass(loadingTextDiv, LOADING_TEXT_CLASS);

Expand Down
2 changes: 1 addition & 1 deletion src/client/ui/progress-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export default class ProgressPanel {
this.startTime = Date.now();
this.maxTimeout = timeout;

this.titleDiv.textContent = text;
nativeMethods.nodeTextContentSetter.call(this.titleDiv, text);
this._setSuccess(false);

this.openingTimeout = nativeMethods.setTimeout.call(window, () => {
Expand Down
5 changes: 3 additions & 2 deletions src/client/ui/select-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ function createOption (realOption, parent) {
var isOptionDisabled = realOption.disabled || domUtils.getTagName(realOption.parentElement) === 'optgroup' &&
realOption.parentElement.disabled;

option.textContent = realOption.text;
// eslint-disable-next-line no-restricted-properties
nativeMethods.nodeTextContentSetter.call(option, realOption.text);

parent.appendChild(option);
shadowUI.addClass(option, OPTION_CLASS);
Expand All @@ -110,7 +111,7 @@ function createOption (realOption, parent) {
function createGroup (realGroup, parent) {
var group = document.createElement('div');

group.textContent = realGroup.label || ' ';
nativeMethods.nodeTextContentSetter.call(group, realGroup.label || ' ');
parent.appendChild(group);

shadowUI.addClass(group, OPTION_GROUP_CLASS);
Expand Down
25 changes: 14 additions & 11 deletions src/client/ui/status-bar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ export default class StatusBar extends serviceUtils.EventEmitter {

var fixtureDiv = document.createElement('div');

fixtureDiv.textContent = `${this.fixtureName} - ${this.testName}`;
nativeMethods.nodeTextContentSetter.call(fixtureDiv, `${this.fixtureName} - ${this.testName}`);
shadowUI.addClass(fixtureDiv, FIXTURE_DIV_CLASS);
this.fixtureContainer.appendChild(fixtureDiv);

var userAgentDiv = document.createElement('div');

userAgentDiv.textContent = this.userAgent;
nativeMethods.nodeTextContentSetter.call(userAgentDiv, this.userAgent);
shadowUI.addClass(userAgentDiv, USER_AGENT_DIV_CLASS);
this.fixtureContainer.appendChild(userAgentDiv);
}
Expand All @@ -139,7 +139,7 @@ export default class StatusBar extends serviceUtils.EventEmitter {
var iconSeparator = document.createElement('div');
var unlockText = document.createElement('span');

unlockText.textContent = UNLOCK_PAGE_TEXT;
nativeMethods.nodeTextContentSetter.call(unlockText, UNLOCK_PAGE_TEXT);

shadowUI.addClass(unlockPageArea, UNLOCK_PAGE_AREA_CLASS);
shadowUI.addClass(unlockPageContainer, UNLOCK_PAGE_CONTAINER_CLASS);
Expand All @@ -164,7 +164,7 @@ export default class StatusBar extends serviceUtils.EventEmitter {
this._bindClickOnce([unlockPageContainer], () => {
shadowUI.removeClass(unlockPageContainer, LOCKED_CLASS);
shadowUI.addClass(unlockPageContainer, UNLOCKED_CLASS);
unlockText.textContent = PAGE_UNLOCKED_TEXT;
nativeMethods.nodeTextContentSetter.call(unlockText, PAGE_UNLOCKED_TEXT);

this.emit(this.UNLOCK_PAGE_BTN_CLICK, {});
});
Expand All @@ -180,8 +180,9 @@ export default class StatusBar extends serviceUtils.EventEmitter {
shadowUI.addClass(statusContainer, STATUS_CONTAINER_CLASS);
this.container.appendChild(statusContainer);

this.statusDiv = document.createElement('div');
this.statusDiv.textContent = LOADING_PAGE_TEXT;
this.statusDiv = document.createElement('div');

nativeMethods.nodeTextContentSetter.call(this.statusDiv, LOADING_PAGE_TEXT);

shadowUI.addClass(this.statusDiv, STATUS_DIV_CLASS);

Expand Down Expand Up @@ -210,7 +211,7 @@ export default class StatusBar extends serviceUtils.EventEmitter {
var icon = document.createElement('div');
var span = document.createElement('span');

span.textContent = text;
nativeMethods.nodeTextContentSetter.call(span, text);

shadowUI.addClass(button, 'button');
shadowUI.addClass(button, className);
Expand Down Expand Up @@ -466,12 +467,14 @@ export default class StatusBar extends serviceUtils.EventEmitter {
this.buttons.style.display = 'none';
this.unlockPageArea.style.display = 'none';

this.statusDiv.textContent = '';
nativeMethods.nodeTextContentSetter.call(this.statusDiv, '');
this.progressBar.hide();
}

_showWaitingStatus () {
this.statusDiv.textContent = this.state.assertionRetries ? WAITING_FOR_ASSERTION_EXECUTION_TEXT : WAITING_FOR_ELEMENT_TEXT;
var waitingStatusText = this.state.assertionRetries ? WAITING_FOR_ASSERTION_EXECUTION_TEXT : WAITING_FOR_ELEMENT_TEXT;

nativeMethods.nodeTextContentSetter.call(this.statusDiv, waitingStatusText);
this._setStatusDivLeftMargin();
this.progressBar.show();
}
Expand Down Expand Up @@ -504,12 +507,12 @@ export default class StatusBar extends serviceUtils.EventEmitter {
this.buttons.removeChild(this.resumeButton);
this.buttons.appendChild(this.finishButton);

this.statusDiv.textContent = TEST_FAILED_TEXT;
nativeMethods.nodeTextContentSetter.call(this.statusDiv, TEST_FAILED_TEXT);
shadowUI.removeClass(this.statusBar, WAITING_SUCCESS_CLASS);
shadowUI.addClass(this.statusBar, WAITING_FAILED_CLASS);
}
else
this.statusDiv.textContent = DEBUGGING_TEXT;
nativeMethods.nodeTextContentSetter.call(this.statusDiv, DEBUGGING_TEXT);

this.buttons.style.display = '';
this.unlockPageArea.style.display = '';
Expand Down

0 comments on commit 58e3624

Please sign in to comment.