Skip to content

Commit

Permalink
Add delay when starting multiple Chrome instances on Mac (closes #2035)…
Browse files Browse the repository at this point in the history
… (#2036)
  • Loading branch information
AndreyBelym authored and AlexanderMoskovkin committed Jan 12, 2018
1 parent b474763 commit 5fd428a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/browser/provider/built-in/chrome/local-chrome.js
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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 }) {
Expand Down

0 comments on commit 5fd428a

Please sign in to comment.