[Pkg-javascript-commits] [pdf.js] 38/106: Clean up the test driver

David Prévot taffit at moszumanska.debian.org
Sat Jun 20 21:33:49 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit d59660cfa6664369e1ffc4c283a3695517a79ceb
Author: Tim van der Meij <timvandermeij at gmail.com>
Date:   Fri May 15 14:24:40 2015 +0200

    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.
---
 test/driver.js | 43 ++++++++++---------------------------------
 1 file changed, 10 insertions(+), 33 deletions(-)

diff --git a/test/driver.js b/test/driver.js
index 2cc69b6..769c1ca 100644
--- a/test/driver.js
+++ b/test/driver.js
@@ -31,9 +31,6 @@ 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('&');
@@ -83,7 +80,7 @@ window.load = function load() {
   }, delay);
 };
 
-function cleanup(callback) {
+function cleanup() {
   // Clear out all the stylesheets since a new one is created for each font.
   while (document.styleSheets.length > 0) {
     var styleSheet = document.styleSheets[0];
@@ -106,11 +103,6 @@ function cleanup(callback) {
       delete manifest[i].pdfDoc;
     }
   }
-  if (letItCooldown) {
-    setTimeout(callback, 500);
-  } else {
-    callback();
-  }
 }
 
 function exceptionToString(e) {
@@ -124,10 +116,8 @@ function exceptionToString(e) {
 }
 
 function nextTask() {
-  cleanup(continueNextTask);
-}
+  cleanup();
 
-function continueNextTask() {
   if (currentTaskIdx === manifest.length) {
     done();
     return;
@@ -177,14 +167,6 @@ function getLastPageNum(task) {
   return lastPageNum;
 }
 
-function isLastPage(task) {
-  return task.pageNum > getLastPageNum(task);
-}
-
-function canvasToDataURL() {
-  return canvas.toDataURL('image/png');
-}
-
 function NullTextLayerBuilder() {
 }
 NullTextLayerBuilder.prototype = {
@@ -239,7 +221,8 @@ function nextPage(task, loadError) {
   var failure = loadError || '';
 
   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');
       ++currentTaskIdx;
       nextTask();
@@ -247,7 +230,7 @@ function nextPage(task, loadError) {
     return;
   }
 
-  if (isLastPage(task)) {
+  if (task.pageNum > getLastPageNum(task)) {
     if (++task.round < task.rounds) {
       log(' Round ' + (1 + task.round) + '\n');
       task.pageNum = task.firstPage || 1;
@@ -337,7 +320,8 @@ function nextPage(task, loadError) {
 function snapshotCurrentPage(task, failure) {
   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');
 
     ++task.pageNum;
@@ -409,11 +393,7 @@ function send(url, message, callback) {
         });
       }
       if (callback) {
-        if (letItCooldown) {
-          setTimeout(callback, 100);
-        } else {
-          callback();
-        }
+        callback();
       }
     }
   };
@@ -433,10 +413,6 @@ function clear(ctx) {
   ctx.clearRect(0, 0, canvas.width, canvas.height);
 }
 
-function scroll() {
-  window.scrollTo(0, document.body.scrollHeight);
-}
-
 function log(str) {
   if (stdout.insertAdjacentHTML) {
     stdout.insertAdjacentHTML('BeforeEnd', str);
@@ -445,7 +421,8 @@ function log(str) {
   }
 
   if (str.lastIndexOf('\n') >= 0) {
-    scroll();
+    // Scroll to the bottom of the page
+    window.scrollTo(0, document.body.scrollHeight);
   }
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list