Clean up the test driver
- Remove a hack for Chrome on Windows because we do not run Chrome on the Windows bot anymore, so it added unneeded complexity. - Merge nextTask and continueNextTask functions. nextTask did nothing more than calling cleanup. This change also allows us to remove the callback for that function. - Remove unnecessary one-line functions.
This commit is contained in:
parent
58769fd3b9
commit
d59660cfa6
@ -31,9 +31,6 @@ var appPath, masterMode, browser, canvas, dummyCanvas, currentTaskIdx,
|
|||||||
manifest, stdout;
|
manifest, stdout;
|
||||||
var inFlightRequests = 0;
|
var inFlightRequests = 0;
|
||||||
|
|
||||||
// Chrome for Windows locks during testing on low end machines
|
|
||||||
var letItCooldown = /Windows.*?Chrom/i.test(navigator.userAgent);
|
|
||||||
|
|
||||||
function queryParams() {
|
function queryParams() {
|
||||||
var qs = window.location.search.substring(1);
|
var qs = window.location.search.substring(1);
|
||||||
var kvs = qs.split('&');
|
var kvs = qs.split('&');
|
||||||
@ -83,7 +80,7 @@ window.load = function load() {
|
|||||||
}, delay);
|
}, delay);
|
||||||
};
|
};
|
||||||
|
|
||||||
function cleanup(callback) {
|
function cleanup() {
|
||||||
// Clear out all the stylesheets since a new one is created for each font.
|
// Clear out all the stylesheets since a new one is created for each font.
|
||||||
while (document.styleSheets.length > 0) {
|
while (document.styleSheets.length > 0) {
|
||||||
var styleSheet = document.styleSheets[0];
|
var styleSheet = document.styleSheets[0];
|
||||||
@ -106,11 +103,6 @@ function cleanup(callback) {
|
|||||||
delete manifest[i].pdfDoc;
|
delete manifest[i].pdfDoc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (letItCooldown) {
|
|
||||||
setTimeout(callback, 500);
|
|
||||||
} else {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function exceptionToString(e) {
|
function exceptionToString(e) {
|
||||||
@ -124,10 +116,8 @@ function exceptionToString(e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function nextTask() {
|
function nextTask() {
|
||||||
cleanup(continueNextTask);
|
cleanup();
|
||||||
}
|
|
||||||
|
|
||||||
function continueNextTask() {
|
|
||||||
if (currentTaskIdx === manifest.length) {
|
if (currentTaskIdx === manifest.length) {
|
||||||
done();
|
done();
|
||||||
return;
|
return;
|
||||||
@ -177,14 +167,6 @@ function getLastPageNum(task) {
|
|||||||
return lastPageNum;
|
return lastPageNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isLastPage(task) {
|
|
||||||
return task.pageNum > getLastPageNum(task);
|
|
||||||
}
|
|
||||||
|
|
||||||
function canvasToDataURL() {
|
|
||||||
return canvas.toDataURL('image/png');
|
|
||||||
}
|
|
||||||
|
|
||||||
function NullTextLayerBuilder() {
|
function NullTextLayerBuilder() {
|
||||||
}
|
}
|
||||||
NullTextLayerBuilder.prototype = {
|
NullTextLayerBuilder.prototype = {
|
||||||
@ -239,7 +221,8 @@ function nextPage(task, loadError) {
|
|||||||
var failure = loadError || '';
|
var failure = loadError || '';
|
||||||
|
|
||||||
if (!task.pdfDoc) {
|
if (!task.pdfDoc) {
|
||||||
sendTaskResult(canvasToDataURL(), task, failure, function () {
|
var dataUrl = canvas.toDataURL('image/png');
|
||||||
|
sendTaskResult(dataUrl, task, failure, function () {
|
||||||
log('done' + (failure ? ' (failed !: ' + failure + ')' : '') + '\n');
|
log('done' + (failure ? ' (failed !: ' + failure + ')' : '') + '\n');
|
||||||
++currentTaskIdx;
|
++currentTaskIdx;
|
||||||
nextTask();
|
nextTask();
|
||||||
@ -247,7 +230,7 @@ function nextPage(task, loadError) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLastPage(task)) {
|
if (task.pageNum > getLastPageNum(task)) {
|
||||||
if (++task.round < task.rounds) {
|
if (++task.round < task.rounds) {
|
||||||
log(' Round ' + (1 + task.round) + '\n');
|
log(' Round ' + (1 + task.round) + '\n');
|
||||||
task.pageNum = task.firstPage || 1;
|
task.pageNum = task.firstPage || 1;
|
||||||
@ -337,7 +320,8 @@ function nextPage(task, loadError) {
|
|||||||
function snapshotCurrentPage(task, failure) {
|
function snapshotCurrentPage(task, failure) {
|
||||||
log('done, snapshotting... ');
|
log('done, snapshotting... ');
|
||||||
|
|
||||||
sendTaskResult(canvasToDataURL(), task, failure, function () {
|
var dataUrl = canvas.toDataURL('image/png');
|
||||||
|
sendTaskResult(dataUrl, task, failure, function () {
|
||||||
log('done' + (failure ? ' (failed !: ' + failure + ')' : '') + '\n');
|
log('done' + (failure ? ' (failed !: ' + failure + ')' : '') + '\n');
|
||||||
|
|
||||||
++task.pageNum;
|
++task.pageNum;
|
||||||
@ -409,11 +393,7 @@ function send(url, message, callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (callback) {
|
if (callback) {
|
||||||
if (letItCooldown) {
|
callback();
|
||||||
setTimeout(callback, 100);
|
|
||||||
} else {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -433,10 +413,6 @@ function clear(ctx) {
|
|||||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
function scroll() {
|
|
||||||
window.scrollTo(0, document.body.scrollHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
function log(str) {
|
function log(str) {
|
||||||
if (stdout.insertAdjacentHTML) {
|
if (stdout.insertAdjacentHTML) {
|
||||||
stdout.insertAdjacentHTML('BeforeEnd', str);
|
stdout.insertAdjacentHTML('BeforeEnd', str);
|
||||||
@ -445,7 +421,8 @@ function log(str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (str.lastIndexOf('\n') >= 0) {
|
if (str.lastIndexOf('\n') >= 0) {
|
||||||
scroll();
|
// Scroll to the bottom of the page
|
||||||
|
window.scrollTo(0, document.body.scrollHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user