Created
April 29, 2016 13:51
-
-
Save AlexanderMoskovkin/d94a79f3966c56533a848da5178a27f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function waitForIframeReloaded (iframe) { | |
return new Promise(function (resolve) { | |
iframe.contentWindow.addEventListener('unload', resolve); | |
}) | |
.then(function () { | |
return window.QUnitGlobals.waitForIframe(iframe); | |
}); | |
} | |
function wait (ms) { | |
return new Promise(function (resolve) { | |
window.setTimeout(resolve, ms); | |
}); | |
} | |
asyncTest('B253200 - TestCafe doesn\'t emulate browsers behavior for press "enter" key on the focused HyperLink editor (link with href)', function () { | |
var iFrameSrc = window.QUnitGlobals.getResourceUrl('../../../data/runner/iframe.html', 'runner-iframe.html'); | |
var linkHref = window.QUnitGlobals.getResourceUrl('../../../data/focus-blur-change/iframe.html', 'focus-iframe.html'); | |
var link = $('<a>Link</a>').attr('href', linkHref).addClass(TEST_ELEMENT_CLASS)[0]; | |
var iframe = createIFrame(iFrameSrc); | |
var clicked = false; | |
link.onclick = function () { | |
clicked = true; | |
}; | |
window.QUnitGlobals | |
.waitForIframe(iframe) | |
.then(function () { | |
equal(iframe.contentWindow.location.pathname, '/sessionId!i/https://example.com/test-resource/runner-iframe.html', 'path is correct before click on link'); | |
iframe.contentDocument.body.appendChild(link); | |
link.focus(); | |
// NOTE: we need setTimeout to wait for focus in IE | |
return wait(browserUtils.isIE ? 3000 : 0); | |
}) | |
.then(function () { | |
equal(domUtils.getActiveElement(), iframe); | |
equal(domUtils.getActiveElement(iframe.contentDocument), link); | |
actionsAPI.press('enter'); | |
return waitForIframeReloaded(iframe); | |
}) | |
.then(function () { | |
equal(iframe.contentWindow.location.pathname, '/sessionId/https://example.com/test-resource/focus-iframe.html', 'path is correct before click on link'); | |
ok(clicked); | |
start(); | |
}); | |
document.body.appendChild(iframe); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment