From 1a2f142a14df452ea5ebc939220c7d9d8b0bb34b Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 21 Sep 2016 13:24:22 +0200 Subject: [PATCH] Prevent errors if the 'resize' event is fired before the `eventBus` has been initialized When opening a PDF file that triggers the browser fallback bar in the Firefox addon/built-in version, e.g. http://web.archive.org/web/20110918100215/http://www.irs.gov/pub/irs-pdf/f1040.pdf (with forms *disabled*), and then reloading the document an error can be thrown. The reason is that displaying the fallback bar triggers 'resize' events, and they can arrive *before* the viewer has had a chance to run all the necessary initialization code. --- web/app.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/web/app.js b/web/app.js index 6e9168669..51d50f666 100644 --- a/web/app.js +++ b/web/app.js @@ -1803,6 +1803,9 @@ function webViewerUpdateViewarea(e) { } window.addEventListener('resize', function webViewerResize(evt) { + if (!PDFViewerApplication.eventBus) { + return; + } PDFViewerApplication.eventBus.dispatch('resize'); });