From 4d3b15a4868c05296943c77b7fcbeaf3d5250cbe Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Mon, 31 Mar 2014 07:46:11 -0500 Subject: [PATCH] Cools down Chrome/Windows during testing --- test/driver.js | 20 +++++++++++++++++--- test/webserver.js | 4 ++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/test/driver.js b/test/driver.js index 6602f14ba..f171c3614 100644 --- a/test/driver.js +++ b/test/driver.js @@ -35,6 +35,9 @@ var appPath, masterMode, browser, canvas, dummyCanvas, currentTaskIdx, manifest, stdout; var inFlightRequests = 0; +// Chrome for Windows locks during testing on low end machines +var letItCooldown = /Windows.*?Chrom/i.test(navigator.userAgent); + function queryParams() { var qs = window.location.search.substring(1); var kvs = qs.split('&'); @@ -84,7 +87,7 @@ window.load = function load() { }, delay); }; -function cleanup() { +function cleanup(callback) { // Clear out all the stylesheets since a new one is created for each font. while (document.styleSheets.length > 0) { var styleSheet = document.styleSheets[0]; @@ -107,6 +110,11 @@ function cleanup() { delete manifest[i].pdfDoc; } } + if (letItCooldown) { + setTimeout(callback, 500); + } else { + callback(); + } } function exceptionToString(e) { @@ -120,8 +128,10 @@ function exceptionToString(e) { } function nextTask() { - cleanup(); + cleanup(continueNextTask); +} +function continueNextTask() { if (currentTaskIdx == manifest.length) { done(); return; @@ -401,7 +411,11 @@ function send(url, message, callback) { }); } if (callback) { - callback(); + if (letItCooldown) { + setTimeout(callback, 100); + } else { + callback(); + } } } }; diff --git a/test/webserver.js b/test/webserver.js index b854619ee..5ffeaba78 100644 --- a/test/webserver.js +++ b/test/webserver.js @@ -47,6 +47,7 @@ function WebServer() { this.port = 8000; this.server = null; this.verbose = false; + this.disableRangeRequests = false; this.hooks = { 'GET': [], 'POST': [] @@ -89,8 +90,7 @@ WebServer.prototype = { return; } - // disables range requests for chrome windows -- locks during testing - var disableRangeRequests = /Windows.*?Chrom/i.test(agent); + var disableRangeRequests = this.disableRangeRequests; var filePath; fs.realpath(path.join(this.root, pathPart), checkFile);