Return a mock object in paintOnSvg when SVG rendering is not supported, to prevent TypeErrors in the addons

Currently if you try to enable SVG rendering in the addons, a `TypeError` is thrown by the browser since we have code that depends on what `paintOnCanvas`/`paintOnSvg` (should) return.
This commit is contained in:
Jonas Jenwald 2016-11-19 13:32:17 +01:00
parent 9c3419de94
commit 9872660a95

View File

@ -612,7 +612,13 @@ var PDFPageView = (function PDFPageViewClosure() {
paintOnSvg: function PDFPageView_paintOnSvg(wrapper) {
if (typeof PDFJSDev !== 'undefined' &&
PDFJSDev.test('FIREFOX || MOZCENTRAL || CHROME')) {
return Promise.resolve('SVG rendering is not supported.');
// Return a mock object, to prevent errors such as e.g.
// "TypeError: paintTask.promise is undefined".
return {
promise: Promise.reject(new Error('SVG rendering is not supported.')),
onRenderContinue: function (cont) { },
cancel: function () { },
};
} else {
var cancelled = false;
var ensureNotCancelled = function () {