Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

event should not work on iframe content (closes #1791, closes #1822 in testcafe) #1789

Merged
merged 6 commits into from Oct 15, 2018

Conversation

AlexKamaev
Copy link
Contributor

No description provided.

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit aa68f5e have failed. See details.

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit b4d81fa have failed. See details.

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit a6e2559 have failed. See details.

@AlexKamaev
Copy link
Contributor Author

@testcafe-build-bot retest

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit a6e2559 have failed. See details.

@AlexKamaev
Copy link
Contributor Author

@testcafe-build-bot retest

@AlexKamaev AlexKamaev changed the title [WIP]event should not work on iframe content (closes #1822) [WIP]event should not work on iframe content (closes #1822 in testcafe) Oct 12, 2018
@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit a6e2559 have failed. See details.

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit b310334 have passed. See details.

@AlexKamaev AlexKamaev changed the title [WIP]event should not work on iframe content (closes #1822 in testcafe) [WIP]event should not work on iframe content (closes #1791, closes #1822 in testcafe) Oct 12, 2018
@AlexKamaev AlexKamaev changed the title [WIP]event should not work on iframe content (closes #1791, closes #1822 in testcafe) event should not work on iframe content (closes #1791, closes #1822 in testcafe) Oct 12, 2018
asyncTest('hover style in iframe', function () {
return createTestIframe()
.then(function (iframe) {
var $style = $('<style>').appendTo('body');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use jquery for elements and property manipulation.

@@ -226,6 +226,19 @@ export function getElementRectangle (el) {
return rectangle;
}

export function isPositionInsideElement (el, x, y) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export function shouldRaiseMouseoverInsideIframe (iframe, { x, y })

@@ -56,6 +58,14 @@ export default class HoverSandbox extends SandboxBase {
return jointParent;
}

_onHover ({ target, clientX, clientY }) {
const isIframeContent = domUtils.getTagName(target) === 'iframe' && positionUtils.isPositionInsideElement(target, clientX, clientY);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1)Convert expression
domUtils.getTagName(target) === 'iframe' && positionUtils.isPositionInsideElement(target, clientX, clientY)
to utility function isPositionInsideIframe(el, {x, y}) and move this to the src/client/utils/position.js file.

2)Merge onHover and _hover function together. And rewrite using fast forward paradigm

_hover() {
 const isPositionIsInIframe = postionUtils.isInIframe(el, x, y);
 const shouldMarkElement = browserUtils.isIE && isPositionIsInIframe;

if (!shouldMarkElement)
  return;

....
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. ok
  2. I've separated them intentionally, because _onHover method takes x,y params while _hover is just api method without any extra params. Besides _hover is used in our tests


const left = rect.left + borders.left + padding.left;
const top = rect.top + borders.top + padding.top;
const right = rect.left + rect.width - borders.right - padding.right;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment for this line

@@ -314,6 +315,15 @@ test('should not wrap invalid event handlers (GH-1251)', function () {
});

strictEqual(listeningCtx.getEventCtx(target, 'click').wrappers.length, storedHandlerWrappersCount);

handlers.forEach(function (handler) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a try/catch statement?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a test for invalid event handlers. See the line above: var handlers = [void 0, 1, null, 'str', {}];. The test adds some wrong event handlers, but does not remove them, so it leads to problems with next texts. I've added code which removes handlers in the same manner as code which adds handlers

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit 1352847 have passed. See details.

@@ -529,6 +529,9 @@ export default class EventSimulator {
}

_dispatchMouseRelatedEvents (el, args, dataTransfer) {
if (shouldIgnoreMouseEventInsideIframe(el, args.clientX, args.clientY) && args.type !== 'mouseover' && args.type !== 'mouseenter')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the type conditions should be the first for performance improvement.

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit b2775b9 have passed. See details.

@miherlosev miherlosev merged commit 903de3e into DevExpress:master Oct 15, 2018
AndreyBelym pushed a commit to AndreyBelym/testcafe-hammerhead that referenced this pull request Feb 28, 2019
DevExpress#1822 in testcafe) (DevExpress#1789)

* event should not work on iframe content (closes DevExpress#1822)

* fix test

* fix safari tests

* focus should work while click should not

* changes

* improve
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants