Browse Source

Ensure that `test/driver.js` actually takes the same `Annotation` code-path as the viewer when running `forms` tests (PR 7633 follow-up)

Unfortunately PR 7633 missed, and I didn't catch it during review, to update `test/driver.js` such that the `forms` tests takes the correct code-path.
This resultet in the `forms` reference test images looking better than they should, and more problematicly differing from the rendering in the viewer.

With this patch, the tests now correctly skip over any `Appearance` streams.
The `forms` tests now highlights quite clearly (e.g. look at `annotation-tx2.pdf`/`annotation-tx3.pdf`) that we cannot just skip the `Appearance` streams when rendering forms. Hence we're going to have to find a way to fix that *before* enabling forms by default, since both display *and* print would look completely wrong otherwise.
Finally, this patch also uncovers one more existing bug that still needs to be fixed, since the current `rasterizeAnnotationLayer` in `test/driver.js` isn't able to handle the contents of e.g. `<input>` and `<textarea>`.
Jonas Jenwald 9 years ago
parent
commit
3a105e37f4
  1. 15
      test/driver.js

15
test/driver.js

@ -459,6 +459,9 @@ var Driver = (function DriverClosure() {
self.canvas.height = viewport.height; self.canvas.height = viewport.height;
self._clearCanvas(); self._clearCanvas();
// Initialize various `eq` test subtypes, see comment below.
var renderAnnotations = false, renderForms = false;
var textLayerCanvas, annotationLayerCanvas; var textLayerCanvas, annotationLayerCanvas;
var initPromise; var initPromise;
if (task.type === 'text') { if (task.type === 'text') {
@ -483,9 +486,13 @@ var Driver = (function DriverClosure() {
}); });
} else { } else {
textLayerCanvas = null; textLayerCanvas = null;
// We fetch the `eq` specific test subtypes here, to avoid
// accidentally changing the behaviour for other types of tests.
renderAnnotations = !!task.annotations;
renderForms = !!task.forms;
// Render the annotation layer if necessary. // Render the annotation layer if necessary.
if (task.annotations || task.forms) { if (renderAnnotations || renderForms) {
// Create a dummy canvas for the drawing operations. // Create a dummy canvas for the drawing operations.
annotationLayerCanvas = self.annotationLayerCanvas; annotationLayerCanvas = self.annotationLayerCanvas;
if (!annotationLayerCanvas) { if (!annotationLayerCanvas) {
@ -503,10 +510,9 @@ var Driver = (function DriverClosure() {
initPromise = initPromise =
page.getAnnotations({ intent: 'display' }).then( page.getAnnotations({ intent: 'display' }).then(
function(annotations) { function(annotations) {
var forms = task.forms || false;
return rasterizeAnnotationLayer(annotationLayerContext, return rasterizeAnnotationLayer(annotationLayerContext,
viewport, annotations, viewport, annotations,
page, forms); page, renderForms);
}); });
} else { } else {
annotationLayerCanvas = null; annotationLayerCanvas = null;
@ -516,7 +522,8 @@ var Driver = (function DriverClosure() {
var renderContext = { var renderContext = {
canvasContext: ctx, canvasContext: ctx,
viewport: viewport viewport: viewport,
renderInteractiveForms: renderForms,
}; };
var completeRender = (function(error) { var completeRender = (function(error) {
// if text layer is present, compose it on top of the page // if text layer is present, compose it on top of the page

Loading…
Cancel
Save