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>`.
This commit is contained in:
Jonas Jenwald 2016-09-18 22:36:40 +02:00
parent ded01356c7
commit 3a105e37f4

View File

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