diff --git a/appveyor.yml b/appveyor.yml index ce40ca49d4b..328638b5c7f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,7 +14,7 @@ install: choco install GoogleChrome - choco install Firefox --version 57.0.1 + choco install Firefox - cmd: >- node --version diff --git a/src/browser/connection/gateway.js b/src/browser/connection/gateway.js index 2b2f0a19334..46ed445e65c 100644 --- a/src/browser/connection/gateway.js +++ b/src/browser/connection/gateway.js @@ -38,6 +38,7 @@ export default class BrowserConnectionGateway { this._dispatch('/browser/heartbeat/{id}', proxy, BrowserConnectionGateway.onHeartbeat); this._dispatch('/browser/idle/{id}', proxy, BrowserConnectionGateway.onIdle); this._dispatch('/browser/status/{id}', proxy, BrowserConnectionGateway.onStatusRequest); + this._dispatch('/browser/status-done/{id}', proxy, BrowserConnectionGateway.onStatusRequestOnTestDone); this._dispatch('/browser/init-script/{id}', proxy, BrowserConnectionGateway.onInitScriptRequest); this._dispatch('/browser/init-script/{id}', proxy, BrowserConnectionGateway.onInitScriptResponse, 'POST'); @@ -87,8 +88,16 @@ export default class BrowserConnectionGateway { } static async onStatusRequest (req, res, connection) { + return BrowserConnectionGateway._onStatusRequestCore(req, res, connection, false); + } + + static async onStatusRequestOnTestDone (req, res, connection) { + return BrowserConnectionGateway._onStatusRequestCore(req, res, connection, true); + } + + static async _onStatusRequestCore (req, res, connection, isTestDone) { if (BrowserConnectionGateway.ensureConnectionReady(res, connection)) { - var status = await connection.getStatus(); + var status = await connection.getStatus(isTestDone); respondWithJSON(res, status); } diff --git a/src/browser/connection/index.js b/src/browser/connection/index.js index cf47ac7baf4..3a307e39ab0 100644 --- a/src/browser/connection/index.js +++ b/src/browser/connection/index.js @@ -36,19 +36,20 @@ export default class BrowserConnection extends EventEmitter { this.provider = browserInfo.provider; - this.permanent = permanent; - this.closing = false; - this.closed = false; - this.ready = false; - this.opened = false; - this.idle = true; - this.switchingToIdle = false; - this.heartbeatTimeout = null; + this.permanent = permanent; + this.closing = false; + this.closed = false; + this.ready = false; + this.opened = false; + this.idle = true; + this.heartbeatTimeout = null; + this.pendingTestRunUrl = null; this.url = `${gateway.domain}/browser/connect/${this.id}`; this.heartbeatUrl = `${gateway.domain}/browser/heartbeat/${this.id}`; this.idleUrl = `${gateway.domain}/browser/idle/${this.id}`; this.statusUrl = `${gateway.domain}/browser/status/${this.id}`; + this.statusDoneUrl = `${gateway.domain}/browser/status-done/${this.id}`; this.initScriptUrl = `${gateway.domain}/browser/init-script/${this.id}`; this.on('error', () => { @@ -115,6 +116,13 @@ export default class BrowserConnection extends EventEmitter { }, this.HEARTBEAT_TIMEOUT); } + async _getTestRunUrl (isTestDone) { + if (isTestDone || !this.pendingTestRunUrl) + this.pendingTestRunUrl = await this._popNextTestRunUrl(); + + return this.pendingTestRunUrl; + } + async _popNextTestRunUrl () { while (this.hasQueuedJobs && !this.currentJob.hasQueuedTestRuns) this.jobQueue.shift(); @@ -230,15 +238,14 @@ export default class BrowserConnection extends EventEmitter { await this.provider.reportJobResult(this.id, status, data); } - async getStatus () { - if (this.switchingToIdle) { - this.switchingToIdle = false; - this.idle = true; + async getStatus (isTestDone) { + if (!this.idle && !isTestDone) { + this.idle = true; this.emit('idle'); } if (this.opened) { - var testRunUrl = await this._popNextTestRunUrl(); + var testRunUrl = await this._getTestRunUrl(isTestDone); if (testRunUrl) { this.idle = false; @@ -246,9 +253,6 @@ export default class BrowserConnection extends EventEmitter { } } - if (!this.idle) - this.switchingToIdle = true; - return { cmd: COMMAND.idle, url: this.idleUrl }; } } diff --git a/src/client/driver/driver.js b/src/client/driver/driver.js index 69195e6d0c4..190cffe84a3 100644 --- a/src/client/driver/driver.js +++ b/src/client/driver/driver.js @@ -83,17 +83,18 @@ export default class Driver { this.COMMAND_EXECUTING_FLAG = 'testcafe|driver|command-executing-flag'; this.EXECUTING_IN_IFRAME_FLAG = 'testcafe|driver|executing-in-iframe-flag'; - this.testRunId = testRunId; - this.heartbeatUrl = communicationUrls.heartbeat; - this.browserStatusUrl = communicationUrls.status; - this.userAgent = runInfo.userAgent; - this.fixtureName = runInfo.fixtureName; - this.testName = runInfo.testName; - this.selectorTimeout = options.selectorTimeout; - this.pageLoadTimeout = options.pageLoadTimeout; - this.initialSpeed = options.speed; - this.skipJsErrors = options.skipJsErrors; - this.dialogHandler = options.dialogHandler; + this.testRunId = testRunId; + this.heartbeatUrl = communicationUrls.heartbeat; + this.browserStatusUrl = communicationUrls.status; + this.browserStatusDoneUrl = communicationUrls.statusDone; + this.userAgent = runInfo.userAgent; + this.fixtureName = runInfo.fixtureName; + this.testName = runInfo.testName; + this.selectorTimeout = options.selectorTimeout; + this.pageLoadTimeout = options.pageLoadTimeout; + this.initialSpeed = options.speed; + this.skipJsErrors = options.skipJsErrors; + this.dialogHandler = options.dialogHandler; this.customCommandHandlers = {}; @@ -478,7 +479,7 @@ export default class Driver { this ._sendStatus(status) - .then(() => browser.checkStatus(this.browserStatusUrl, hammerhead.createNativeXHR)); + .then(() => browser.checkStatus(this.browserStatusDoneUrl, hammerhead.createNativeXHR)); } _onBackupStoragesCommand () { diff --git a/src/client/test-run/index.js.mustache b/src/client/test-run/index.js.mustache index 510486e2eef..5047624f2c9 100644 --- a/src/client/test-run/index.js.mustache +++ b/src/client/test-run/index.js.mustache @@ -2,22 +2,23 @@ if (window !== window.top) return; - var testRunId = {{{testRunId}}}; - var browserId = {{{browserId}}}; - var selectorTimeout = {{{selectorTimeout}}}; - var pageLoadTimeout = {{{pageLoadTimeout}}}; - var speed = {{{speed}}}; - var browserHeartbeatUrl = {{{browserHeartbeatUrl}}}; - var browserStatusUrl = {{{browserStatusUrl}}}; - var skipJsErrors = {{{skipJsErrors}}}; - var dialogHandler = {{{dialogHandler}}}; - var userAgent = {{{userAgent}}}; - var fixtureName = {{{fixtureName}}}; - var testName = {{{testName}}}; + var testRunId = {{{testRunId}}}; + var browserId = {{{browserId}}}; + var selectorTimeout = {{{selectorTimeout}}}; + var pageLoadTimeout = {{{pageLoadTimeout}}}; + var speed = {{{speed}}}; + var browserHeartbeatUrl = {{{browserHeartbeatUrl}}}; + var browserStatusUrl = {{{browserStatusUrl}}}; + var browserStatusDoneUrl = {{{browserStatusDoneUrl}}}; + var skipJsErrors = {{{skipJsErrors}}}; + var dialogHandler = {{{dialogHandler}}}; + var userAgent = {{{userAgent}}}; + var fixtureName = {{{fixtureName}}}; + var testName = {{{testName}}}; var ClientDriver = window['%testCafeDriver%']; var driver = new ClientDriver(testRunId, - { heartbeat: browserHeartbeatUrl, status: browserStatusUrl }, + { heartbeat: browserHeartbeatUrl, status: browserStatusUrl, statusDone: browserStatusDoneUrl }, { userAgent: userAgent, fixtureName: fixtureName, testName: testName }, { selectorTimeout: selectorTimeout, diff --git a/src/test-run/index.js b/src/test-run/index.js index bfda826e96e..52b9e92695c 100644 --- a/src/test-run/index.js +++ b/src/test-run/index.js @@ -116,18 +116,19 @@ export default class TestRun extends Session { this.resolveWaitForFileDownloadingPromise = null; return Mustache.render(TEST_RUN_TEMPLATE, { - testRunId: JSON.stringify(this.id), - browserId: JSON.stringify(this.browserConnection.id), - browserHeartbeatUrl: JSON.stringify(this.browserConnection.heartbeatUrl), - browserStatusUrl: JSON.stringify(this.browserConnection.statusUrl), - userAgent: JSON.stringify(this.browserConnection.userAgent), - testName: JSON.stringify(this.test.name), - fixtureName: JSON.stringify(this.test.fixture.name), - selectorTimeout: this.opts.selectorTimeout, - pageLoadTimeout: this.pageLoadTimeout, - skipJsErrors: this.opts.skipJsErrors, - speed: this.speed, - dialogHandler: JSON.stringify(this.activeDialogHandler) + testRunId: JSON.stringify(this.id), + browserId: JSON.stringify(this.browserConnection.id), + browserHeartbeatUrl: JSON.stringify(this.browserConnection.heartbeatUrl), + browserStatusUrl: JSON.stringify(this.browserConnection.statusUrl), + browserStatusDoneUrl: JSON.stringify(this.browserConnection.statusDoneUrl), + userAgent: JSON.stringify(this.browserConnection.userAgent), + testName: JSON.stringify(this.test.name), + fixtureName: JSON.stringify(this.test.fixture.name), + selectorTimeout: this.opts.selectorTimeout, + pageLoadTimeout: this.pageLoadTimeout, + skipJsErrors: this.opts.skipJsErrors, + speed: this.speed, + dialogHandler: JSON.stringify(this.activeDialogHandler) }); } diff --git a/test/functional/config.js b/test/functional/config.js index d4aafa4af22..d6c6f936a3a 100644 --- a/test/functional/config.js +++ b/test/functional/config.js @@ -44,7 +44,6 @@ testingEnvironments[testingEnvironmentNames.osXDesktopAndMSEdgeBrowsers] = { os: 'OS X', osVersion: 'Sierra', name: 'firefox', - version: '57.0', alias: 'firefox-osx' }, { @@ -106,7 +105,6 @@ testingEnvironments[testingEnvironmentNames.localBrowsers] = { { platform: 'Windows 10', browserName: 'firefox', - version: '57.0', alias: 'firefox' } ] diff --git a/test/server/browser-connection-test.js b/test/server/browser-connection-test.js index d511ab8a0b0..3f0c9580564 100644 --- a/test/server/browser-connection-test.js +++ b/test/server/browser-connection-test.js @@ -145,7 +145,7 @@ describe('Browser connection', function () { connection.addJob(createBrowserJobMock(['3'])); function queryStatus () { - return promisedRequest(connection.statusUrl); + return promisedRequest(connection.statusDoneUrl); } return promisedRequest(connection.url)