Skip to content

Commit

Permalink
Fix: Don't revoke print URL if it doesn't exist (#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyjin authored Oct 19, 2017
1 parent 0ae1c47 commit 9f06212
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/lib/viewers/doc/DocBaseViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/lib/viewers/doc/__tests__/DocBaseViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 9f06212

Please sign in to comment.