mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-21 15:48:06 +02:00
Fix re-rendering, using the same canvas, when rendering was previously cancelled (PR 8519 follow-up)
Currently if `RenderTask.cancel` is called *immediately* after rendering was started, then by the time that `InternalRenderTask.initializeGraphics` is called rendering will already have been cancelled. However, we're still inserting the canvas into the `canvasInRendering` map, thus breaking any future attempts at re-rendering using the same canvas. Considering that `InternalRenderTask.cancel` always removes the canvas from the map, I cannot imagine that we'd ever want to re-add it *after* rendering was cancelled (it was likely just a simple oversight in PR 8519). Fixes 9456.
This commit is contained in:
parent
5e40f04153
commit
bf0aca86d7
2 changed files with 35 additions and 6 deletions
|
@ -1253,6 +1253,37 @@ describe('api', function() {
|
|||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('re-render page, using the same canvas, after cancelling rendering',
|
||||
function(done) {
|
||||
if (isNodeJS()) {
|
||||
pending('TODO: Support Canvas testing in Node.js.');
|
||||
}
|
||||
let viewport = page.getViewport(1);
|
||||
let canvasAndCtx = CanvasFactory.create(viewport.width, viewport.height);
|
||||
|
||||
let renderTask = page.render({
|
||||
canvasContext: canvasAndCtx.context,
|
||||
viewport,
|
||||
});
|
||||
renderTask.cancel();
|
||||
|
||||
renderTask.promise.then(() => {
|
||||
throw new Error('shall cancel rendering');
|
||||
}, (reason) => {
|
||||
expect(reason instanceof RenderingCancelledException).toEqual(true);
|
||||
}).then(() => {
|
||||
let reRenderTask = page.render({
|
||||
canvasContext: canvasAndCtx.context,
|
||||
viewport,
|
||||
});
|
||||
return reRenderTask.promise;
|
||||
}).then(() => {
|
||||
CanvasFactory.destroy(canvasAndCtx);
|
||||
done();
|
||||
}, done.fail);
|
||||
});
|
||||
|
||||
it('multiple render() on the same canvas', function(done) {
|
||||
if (isNodeJS()) {
|
||||
pending('TODO: Support Canvas testing in Node.js.');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue