Merge pull request #313 from kkujala/30ecf43676dbc448f04ba66341889b0e1085b55f
Correct the coding style according to gjslint for driver.js.
This commit is contained in:
commit
75b8fa56ee
@ -11,10 +11,10 @@ var appPath, browser, canvas, currentTaskIdx, manifest, stdout;
|
|||||||
|
|
||||||
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('&');
|
||||||
var params = { };
|
var params = { };
|
||||||
for (var i = 0; i < kvs.length; ++i) {
|
for (var i = 0; i < kvs.length; ++i) {
|
||||||
var kv = kvs[i].split("=");
|
var kv = kvs[i].split('=');
|
||||||
params[unescape(kv[0])] = unescape(kv[1]);
|
params[unescape(kv[0])] = unescape(kv[1]);
|
||||||
}
|
}
|
||||||
return params;
|
return params;
|
||||||
@ -26,20 +26,20 @@ function load() {
|
|||||||
var manifestFile = params.manifestFile;
|
var manifestFile = params.manifestFile;
|
||||||
appPath = params.path;
|
appPath = params.path;
|
||||||
|
|
||||||
canvas = document.createElement("canvas");
|
canvas = document.createElement('canvas');
|
||||||
canvas.mozOpaque = true;
|
canvas.mozOpaque = true;
|
||||||
stdout = document.getElementById("stdout");
|
stdout = document.getElementById('stdout');
|
||||||
|
|
||||||
log("load...\n");
|
log('load...\n');
|
||||||
|
|
||||||
log("Harness thinks this browser is '"+ browser + "' with path " + appPath + "\n");
|
log('Harness thinks this browser is "' + browser + '" with path "' + appPath + '"\n');
|
||||||
log("Fetching manifest "+ manifestFile +"...");
|
log('Fetching manifest "' + manifestFile + '"... ');
|
||||||
|
|
||||||
var r = new XMLHttpRequest();
|
var r = new XMLHttpRequest();
|
||||||
r.open("GET", manifestFile, false);
|
r.open('GET', manifestFile, false);
|
||||||
r.onreadystatechange = function(e) {
|
r.onreadystatechange = function(e) {
|
||||||
if (r.readyState == 4) {
|
if (r.readyState == 4) {
|
||||||
log("done\n");
|
log('done\n');
|
||||||
manifest = JSON.parse(r.responseText);
|
manifest = JSON.parse(r.responseText);
|
||||||
currentTaskIdx = 0, nextTask();
|
currentTaskIdx = 0, nextTask();
|
||||||
}
|
}
|
||||||
@ -55,11 +55,11 @@ function nextTask() {
|
|||||||
var task = manifest[currentTaskIdx];
|
var task = manifest[currentTaskIdx];
|
||||||
task.round = 0;
|
task.round = 0;
|
||||||
|
|
||||||
log("Loading file "+ task.file +"\n");
|
log('Loading file "' + task.file + '"\n');
|
||||||
|
|
||||||
var r = new XMLHttpRequest();
|
var r = new XMLHttpRequest();
|
||||||
r.open("GET", task.file);
|
r.open('GET', task.file);
|
||||||
r.mozResponseType = r.responseType = "arraybuffer";
|
r.mozResponseType = r.responseType = 'arraybuffer';
|
||||||
r.onreadystatechange = function() {
|
r.onreadystatechange = function() {
|
||||||
var failure;
|
var failure;
|
||||||
if (r.readyState == 4) {
|
if (r.readyState == 4) {
|
||||||
@ -68,8 +68,8 @@ function nextTask() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
task.pdfDoc = new PDFDoc(new Stream(data));
|
task.pdfDoc = new PDFDoc(new Stream(data));
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
failure = 'load PDF doc: '+ e.toString();
|
failure = 'load PDF doc : ' + e.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
task.pageNum = 1, nextPage(task, failure);
|
task.pageNum = 1, nextPage(task, failure);
|
||||||
@ -84,12 +84,12 @@ function isLastPage(task) {
|
|||||||
|
|
||||||
function nextPage(task, loadError) {
|
function nextPage(task, loadError) {
|
||||||
if (isLastPage(task)) {
|
if (isLastPage(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 = 1;
|
task.pageNum = 1;
|
||||||
} else {
|
} else {
|
||||||
++currentTaskIdx, nextTask();
|
++currentTaskIdx, nextTask();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,8 +99,8 @@ function nextPage(task, loadError) {
|
|||||||
var page = null;
|
var page = null;
|
||||||
if (!failure) {
|
if (!failure) {
|
||||||
try {
|
try {
|
||||||
log(" loading page "+ task.pageNum +"/"+ task.pdfDoc.numPages +"... ");
|
log(' loading page ' + task.pageNum + '/' + task.pdfDoc.numPages + '... ');
|
||||||
ctx = canvas.getContext("2d");
|
ctx = canvas.getContext('2d');
|
||||||
page = task.pdfDoc.getPage(task.pageNum);
|
page = task.pdfDoc.getPage(task.pageNum);
|
||||||
|
|
||||||
var pdfToCssUnitsCoef = 96.0 / 72.0;
|
var pdfToCssUnitsCoef = 96.0 / 72.0;
|
||||||
@ -115,10 +115,10 @@ function nextPage(task, loadError) {
|
|||||||
ctx,
|
ctx,
|
||||||
function(e) {
|
function(e) {
|
||||||
snapshotCurrentPage(page, task,
|
snapshotCurrentPage(page, task,
|
||||||
(!failure && e) ? ('render: '+ e) : failure);
|
(!failure && e) ? ('render : ' + e) : failure);
|
||||||
});
|
});
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
failure = 'page setup: '+ e.toString();
|
failure = 'page setup : ' + e.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,10 +130,10 @@ function nextPage(task, loadError) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function snapshotCurrentPage(page, task, failure) {
|
function snapshotCurrentPage(page, task, failure) {
|
||||||
log("done, snapshotting... ");
|
log('done, snapshotting... ');
|
||||||
|
|
||||||
sendTaskResult(canvas.toDataURL("image/png"), task, failure);
|
sendTaskResult(canvas.toDataURL('image/png'), task, failure);
|
||||||
log("done"+ (failure ? " (failed!: "+ failure +")" : "") +"\n");
|
log('done' + (failure ? ' (failed !: ' + failure + ')' : '') + '\n');
|
||||||
|
|
||||||
// Set up the next request
|
// Set up the next request
|
||||||
var backoff = (inFlightRequests > 0) ? inFlightRequests * 10 : 0;
|
var backoff = (inFlightRequests > 0) ? inFlightRequests * 10 : 0;
|
||||||
@ -146,13 +146,13 @@ function snapshotCurrentPage(page, task, failure) {
|
|||||||
|
|
||||||
function sendQuitRequest() {
|
function sendQuitRequest() {
|
||||||
var r = new XMLHttpRequest();
|
var r = new XMLHttpRequest();
|
||||||
r.open("POST", "/tellMeToQuit?path=" + escape(appPath), false);
|
r.open('POST', '/tellMeToQuit?path = ' + escape(appPath), false);
|
||||||
r.send("");
|
r.send('');
|
||||||
}
|
}
|
||||||
|
|
||||||
function quitApp() {
|
function quitApp() {
|
||||||
log("Done!");
|
log('Done !');
|
||||||
document.body.innerHTML = "Tests are finished. <h1>CLOSE ME!</h1>";
|
document.body.innerHTML = 'Tests are finished. <h1>CLOSE ME!</h1>';
|
||||||
if (window.SpecialPowers) {
|
if (window.SpecialPowers) {
|
||||||
SpecialPowers.quitApplication();
|
SpecialPowers.quitApplication();
|
||||||
} else {
|
} else {
|
||||||
@ -163,7 +163,7 @@ function quitApp() {
|
|||||||
|
|
||||||
function done() {
|
function done() {
|
||||||
if (inFlightRequests > 0) {
|
if (inFlightRequests > 0) {
|
||||||
document.getElementById("inFlightCount").innerHTML = inFlightRequests;
|
document.getElementById('inFlightCount').innerHTML = inFlightRequests;
|
||||||
setTimeout(done, 100);
|
setTimeout(done, 100);
|
||||||
} else {
|
} else {
|
||||||
setTimeout(quitApp, 100);
|
setTimeout(quitApp, 100);
|
||||||
@ -183,20 +183,20 @@ function sendTaskResult(snapshot, task, failure) {
|
|||||||
|
|
||||||
var r = new XMLHttpRequest();
|
var r = new XMLHttpRequest();
|
||||||
// (The POST URI is ignored atm.)
|
// (The POST URI is ignored atm.)
|
||||||
r.open("POST", "/submit_task_results", true);
|
r.open('POST', '/submit_task_results', true);
|
||||||
r.setRequestHeader("Content-Type", "application/json");
|
r.setRequestHeader('Content-Type', 'application/json');
|
||||||
r.onreadystatechange = function(e) {
|
r.onreadystatechange = function(e) {
|
||||||
if (r.readyState == 4) {
|
if (r.readyState == 4) {
|
||||||
inFlightRequests--;
|
inFlightRequests--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
document.getElementById("inFlightCount").innerHTML = inFlightRequests++;
|
document.getElementById('inFlightCount').innerHTML = inFlightRequests++;
|
||||||
r.send(JSON.stringify(result));
|
r.send(JSON.stringify(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
function clear(ctx) {
|
function clear(ctx) {
|
||||||
ctx.save();
|
ctx.save();
|
||||||
ctx.fillStyle = "rgb(255, 255, 255)";
|
ctx.fillStyle = 'rgb(255, 255, 255)';
|
||||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user