diff --git a/src/lib/viewers/doc/DocBaseViewer.js b/src/lib/viewers/doc/DocBaseViewer.js index 16da9e823..04b79df22 100644 --- a/src/lib/viewers/doc/DocBaseViewer.js +++ b/src/lib/viewers/doc/DocBaseViewer.js @@ -111,7 +111,10 @@ class DocBaseViewer extends BaseViewer { // Clean up print blob this.printBlob = null; - URL.revokeObjectURL(this.printURL); + + if (this.printURL) { + URL.revokeObjectURL(this.printURL); + } if (this.pageControls) { this.pageControls.removeListener('pagechange', this.setPage); diff --git a/src/lib/viewers/doc/__tests__/DocBaseViewer-test.js b/src/lib/viewers/doc/__tests__/DocBaseViewer-test.js index a1dacbb73..1c53a39d2 100644 --- a/src/lib/viewers/doc/__tests__/DocBaseViewer-test.js +++ b/src/lib/viewers/doc/__tests__/DocBaseViewer-test.js @@ -101,12 +101,13 @@ describe('src/lib/viewers/doc/DocBaseViewer', () => { describe('destroy()', () => { it('should unbind listeners and clear the print blob', () => { const unbindDOMListenersStub = sandbox.stub(docBase, 'unbindDOMListeners'); + docBase.printURL = 'someblob'; sandbox.stub(URL, 'revokeObjectURL'); docBase.destroy(); expect(unbindDOMListenersStub).to.be.called; expect(docBase.printBlob).to.equal(null); - expect(URL.revokeObjectURL).to.be.calledWith(docBase.printUrl); + expect(URL.revokeObjectURL).to.be.calledWith(docBase.printURL); }); it('should destroy the controls', () => {