From 5fd428a866a3d211915fb746bb72f2090e3db3bd Mon Sep 17 00:00:00 2001 From: Andrey Belym Date: Fri, 12 Jan 2018 18:41:20 +0300 Subject: [PATCH] Add delay when starting multiple Chrome instances on Mac (closes #2035) (#2036) --- .../provider/built-in/chrome/local-chrome.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/browser/provider/built-in/chrome/local-chrome.js b/src/browser/provider/built-in/chrome/local-chrome.js index 2cd314d7b0f..08caf94d623 100644 --- a/src/browser/provider/built-in/chrome/local-chrome.js +++ b/src/browser/provider/built-in/chrome/local-chrome.js @@ -1,7 +1,14 @@ +import OS from 'os-family'; +import Promise from 'pinkie'; import browserTools from 'testcafe-browser-tools'; import killBrowserProcess from '../../utils/kill-browser-process'; +import delay from '../../../../utils/delay'; +const MACOS_PROCESS_THROTTLING = 500; + +var throttlingPromise = Promise.resolve(); + function buildChromeArgs (config, cdpPort, platformArgs, profileDir) { return [] .concat( @@ -20,7 +27,13 @@ export async function start (pageUrl, { browserName, config, cdpPort, tempProfil chromeOpenParameters.cmd = buildChromeArgs(config, cdpPort, chromeOpenParameters.cmd, tempProfileDir); - await browserTools.open(chromeOpenParameters, pageUrl); + var currentThrottlingPromise = throttlingPromise; + + if (OS.mac) + throttlingPromise = throttlingPromise.then(() => delay(MACOS_PROCESS_THROTTLING)); + + await currentThrottlingPromise + .then(() => browserTools.open(chromeOpenParameters, pageUrl)); } export async function stop ({ browserId }) {