forked from DevExpress/testcafe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stabilize screenshot tests, Update testcafe-browser-tools (DevExpress…
…#1691) Improve browser manipulations mechanism. Update testcafe-browser-tools (fixes DevExpress#1732, fixes DevExpress#1551)
- Loading branch information
1 parent
3b8b6e2
commit d6501e9
Showing
7 changed files
with
31 additions
and
53 deletions.
There are no files selected for viewing
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
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
53 changes: 14 additions & 39 deletions
53
src/client/driver/command-executors/prepare-browser-manipulation.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,32 @@ | ||
import hammerhead from '../deps/hammerhead'; | ||
import testCafeCore from '../deps/testcafe-core'; | ||
import { transport } from '../deps/hammerhead'; | ||
import { delay } from '../deps/testcafe-core'; | ||
import { hide as hideUI, show as showUI } from '../deps/testcafe-ui'; | ||
import MESSAGE from '../../../test-run/client-messages'; | ||
import DriverStatus from '../status'; | ||
|
||
|
||
var nativeMethods = hammerhead.nativeMethods; | ||
var transport = hammerhead.transport; | ||
var delay = testCafeCore.delay; | ||
const POSSIBLE_RESIZE_ERROR_DELAY = 100; | ||
|
||
const CHECK_TITLE_INTERVAL = 50; | ||
const APPLY_DOCUMENT_TITLE_TIMEOUT = 500; | ||
const RESTORE_DOCUMENT_TITLE_TIMEOUT = 100; | ||
export default function prepareBrowserManipulation () { | ||
var result = null; | ||
|
||
|
||
export default function prepareBrowserManipulation (browserId) { | ||
var savedDocumentTitle = document.title; | ||
var assignedTitle = `[ ${browserId} ]`; | ||
var checkTitleIntervalId = null; | ||
var result = null; | ||
|
||
// NOTE: we should keep the page url in document.title | ||
// while the browser manipulation is in progress. | ||
checkTitleIntervalId = nativeMethods.setInterval.call(window, () => { | ||
if (document.title !== assignedTitle) { | ||
savedDocumentTitle = document.title; | ||
document.title = assignedTitle; | ||
} | ||
}, CHECK_TITLE_INTERVAL); | ||
|
||
document.title = assignedTitle; | ||
var message = { | ||
cmd: MESSAGE.readyForBrowserManipulation, | ||
innerWidth: window.innerWidth, | ||
innerHeight: window.innerHeight, | ||
disableResending: true | ||
}; | ||
|
||
hideUI(); | ||
|
||
return delay(APPLY_DOCUMENT_TITLE_TIMEOUT) | ||
.then(() => { | ||
var message = { | ||
cmd: MESSAGE.readyForBrowserManipulation, | ||
innerWidth: window.innerWidth, | ||
innerHeight: window.innerHeight, | ||
disableResending: true | ||
}; | ||
|
||
return transport.queuedAsyncServiceMsg(message); | ||
}) | ||
return transport | ||
.queuedAsyncServiceMsg(message) | ||
.then(res => { | ||
result = res; | ||
nativeMethods.clearInterval.call(window, checkTitleIntervalId); | ||
document.title = savedDocumentTitle; | ||
|
||
showUI(); | ||
|
||
return delay(RESTORE_DOCUMENT_TITLE_TIMEOUT); | ||
return delay(POSSIBLE_RESIZE_ERROR_DELAY); | ||
}) | ||
.then(() => new DriverStatus({ isCommandResult: true, result })); | ||
} |
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
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
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
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