Bug 1525282 - Update pdf.js to version 2.1.243. r=bdahl
authorRyan VanderMeulen <ryanvm@gmail.com>
Tue, 05 Feb 2019 09:47:52 -0500
changeset 456698 7bdde3e00dcdcb65b292acab4dc14c1c2467122f
parent 456697 c4f1b630a4816cf58c997a06dad2696638956989
child 456699 7618517e99624af87ee09d01ef474a47155e95d4
push id111698
push userryanvm@gmail.com
push dateTue, 05 Feb 2019 14:48:35 +0000
treeherdermozilla-inbound@7bdde3e00dcd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbdahl
bugs1525282
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1525282 - Update pdf.js to version 2.1.243. r=bdahl
browser/extensions/pdfjs/README.mozilla
browser/extensions/pdfjs/content/PdfJsDefaultPreferences.jsm
browser/extensions/pdfjs/content/build/pdf.js
browser/extensions/pdfjs/content/build/pdf.worker.js
browser/extensions/pdfjs/content/web/viewer.js
browser/extensions/pdfjs/moz.yaml
--- a/browser/extensions/pdfjs/README.mozilla
+++ b/browser/extensions/pdfjs/README.mozilla
@@ -1,5 +1,5 @@
 This is the PDF.js project output, https://github.com/mozilla/pdf.js
 
-Current extension version is: 2.1.228
+Current extension version is: 2.1.243
 
-Taken from upstream commit: 1f3e7700
+Taken from upstream commit: c0d6e46e
--- a/browser/extensions/pdfjs/content/PdfJsDefaultPreferences.jsm
+++ b/browser/extensions/pdfjs/content/PdfJsDefaultPreferences.jsm
@@ -17,32 +17,30 @@
 
 //
 // THIS FILE IS GENERATED AUTOMATICALLY, DO NOT EDIT MANUALLY!
 //
 
 "use strict";
 var EXPORTED_SYMBOLS = ["PdfJsDefaultPreferences"];
 var PdfJsDefaultPreferences = Object.freeze({
- "showPreviousViewOnLoad": true,
+ "viewOnLoad": 0,
  "defaultZoomValue": "",
- "sidebarViewOnLoad": 0,
+ "sidebarViewOnLoad": -1,
  "cursorToolOnLoad": 0,
  "enableWebGL": false,
  "eventBusDispatchToDOM": false,
  "pdfBugEnabled": false,
  "disableRange": false,
  "disableStream": false,
  "disableAutoFetch": false,
  "disableFontFace": false,
  "textLayerMode": 1,
  "useOnlyCssZoom": false,
  "externalLinkTarget": 0,
  "renderer": "canvas",
  "renderInteractiveForms": false,
  "enablePrintAutoRotate": false,
- "disableOpenActionDestination": true,
- "disablePageMode": false,
  "disablePageLabels": false,
  "historyUpdateUrl": false,
- "scrollModeOnLoad": 0,
- "spreadModeOnLoad": 0
+ "scrollModeOnLoad": -1,
+ "spreadModeOnLoad": -1
 });
--- a/browser/extensions/pdfjs/content/build/pdf.js
+++ b/browser/extensions/pdfjs/content/build/pdf.js
@@ -118,18 +118,18 @@ return /******/ (function(modules) { // 
 /************************************************************************/
 /******/ ([
 /* 0 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
-var pdfjsVersion = '2.1.228';
-var pdfjsBuild = '1f3e7700';
+var pdfjsVersion = '2.1.243';
+var pdfjsBuild = 'c0d6e46e';
 
 var pdfjsSharedUtil = __w_pdfjs_require__(1);
 
 var pdfjsDisplayAPI = __w_pdfjs_require__(6);
 
 var pdfjsDisplayTextLayer = __w_pdfjs_require__(18);
 
 var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(19);
@@ -1095,20 +1095,34 @@ function isArrayBuffer(v) {
   return typeof v === 'object' && v !== null && v.byteLength !== undefined;
 }
 
 function isSpace(ch) {
   return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
 }
 
 function createPromiseCapability() {
-  var capability = {};
+  const capability = Object.create(null);
+  let isSettled = false;
+  Object.defineProperty(capability, 'settled', {
+    get() {
+      return isSettled;
+    }
+
+  });
   capability.promise = new Promise(function (resolve, reject) {
-    capability.resolve = resolve;
-    capability.reject = reject;
+    capability.resolve = function (data) {
+      isSettled = true;
+      resolve(data);
+    };
+
+    capability.reject = function (reason) {
+      isSettled = true;
+      reject(reason);
+    };
   });
   return capability;
 }
 
 var createObjectURL = function createObjectURLClosure() {
   var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
   return function createObjectURL(data, contentType, forceDataSchema = false) {
     if (!forceDataSchema && _url_polyfill.URL.createObjectURL) {
@@ -1392,17 +1406,17 @@ function _fetchDocument(worker, source, 
 
   if (pdfDataRangeTransport) {
     source.length = pdfDataRangeTransport.length;
     source.initialData = pdfDataRangeTransport.initialData;
   }
 
   return worker.messageHandler.sendWithPromise('GetDocRequest', {
     docId,
-    apiVersion: '2.1.228',
+    apiVersion: '2.1.243',
     source: {
       data: source.data,
       url: source.url,
       password: source.password,
       disableAutoFetch: source.disableAutoFetch,
       rangeChunkSize: source.rangeChunkSize,
       length: source.length
     },
@@ -3123,19 +3137,19 @@ const InternalRenderTask = function Inte
       }
     }
 
   }
 
   return InternalRenderTask;
 }();
 
-const version = '2.1.228';
+const version = '2.1.243';
 exports.version = version;
-const build = '1f3e7700';
+const build = 'c0d6e46e';
 exports.build = build;
 
 /***/ }),
 /* 7 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
--- a/browser/extensions/pdfjs/content/build/pdf.worker.js
+++ b/browser/extensions/pdfjs/content/build/pdf.worker.js
@@ -118,18 +118,18 @@ return /******/ (function(modules) { // 
 /************************************************************************/
 /******/ ([
 /* 0 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
-const pdfjsVersion = '2.1.228';
-const pdfjsBuild = '1f3e7700';
+const pdfjsVersion = '2.1.243';
+const pdfjsBuild = 'c0d6e46e';
 
 const pdfjsCoreWorker = __w_pdfjs_require__(1);
 
 exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
 
 /***/ }),
 /* 1 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
@@ -370,17 +370,17 @@ var WorkerMessageHandler = {
   },
 
   createDocumentHandler(docParams, port) {
     var pdfManager;
     var terminated = false;
     var cancelXHRs = null;
     var WorkerTasks = [];
     let apiVersion = docParams.apiVersion;
-    let workerVersion = '2.1.228';
+    let workerVersion = '2.1.243';
 
     if (apiVersion !== workerVersion) {
       throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`);
     }
 
     var docId = docParams.docId;
     var docBaseUrl = docParams.docBaseUrl;
     var workerHandlerName = docParams.docId + '_worker';
@@ -1732,20 +1732,34 @@ function isArrayBuffer(v) {
   return typeof v === 'object' && v !== null && v.byteLength !== undefined;
 }
 
 function isSpace(ch) {
   return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
 }
 
 function createPromiseCapability() {
-  var capability = {};
+  const capability = Object.create(null);
+  let isSettled = false;
+  Object.defineProperty(capability, 'settled', {
+    get() {
+      return isSettled;
+    }
+
+  });
   capability.promise = new Promise(function (resolve, reject) {
-    capability.resolve = resolve;
-    capability.reject = reject;
+    capability.resolve = function (data) {
+      isSettled = true;
+      resolve(data);
+    };
+
+    capability.reject = function (reason) {
+      isSettled = true;
+      reject(reason);
+    };
   });
   return capability;
 }
 
 var createObjectURL = function createObjectURLClosure() {
   var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
   return function createObjectURL(data, contentType, forceDataSchema = false) {
     if (!forceDataSchema && _url_polyfill.URL.createObjectURL) {
@@ -20759,17 +20773,17 @@ var PartialEvaluator = function PartialE
         var font = textState.font;
 
         if (!(font.loadedName in seenStyles)) {
           seenStyles[font.loadedName] = true;
           textContent.styles[font.loadedName] = {
             fontFamily: font.fallbackName,
             ascent: font.ascent,
             descent: font.descent,
-            vertical: font.vertical
+            vertical: !!font.vertical
           };
         }
 
         textContentItem.fontName = font.loadedName;
         var tsm = [textState.fontSize * textState.textHScale, 0, 0, textState.fontSize, 0, textState.textRise];
 
         if (font.isType3Font && textState.fontMatrix !== _util.FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
           var glyphHeight = font.bbox[3] - font.bbox[1];
@@ -20936,18 +20950,22 @@ var PartialEvaluator = function PartialE
         }
       }
 
       function flushTextContentItem() {
         if (!textContentItem.initialized) {
           return;
         }
 
-        textContentItem.width *= textContentItem.textAdvanceScale;
-        textContentItem.height *= textContentItem.textAdvanceScale;
+        if (!textContentItem.vertical) {
+          textContentItem.width *= textContentItem.textAdvanceScale;
+        } else {
+          textContentItem.height *= textContentItem.textAdvanceScale;
+        }
+
         textContent.items.push(runBidiTransform(textContentItem));
         textContentItem.initialized = false;
         textContentItem.str.length = 0;
       }
 
       function enqueueChunk() {
         let length = textContent.items.length;
 
--- a/browser/extensions/pdfjs/content/web/viewer.js
+++ b/browser/extensions/pdfjs/content/web/viewer.js
@@ -319,16 +319,21 @@ var _secondary_toolbar = __webpack_requi
 var _toolbar = __webpack_require__(31);
 
 var _view_history = __webpack_require__(32);
 
 const DEFAULT_SCALE_DELTA = 1.1;
 const DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
 const FORCE_PAGES_LOADED_TIMEOUT = 10000;
 const WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
+const ViewOnLoad = {
+  UNKNOWN: -1,
+  PREVIOUS: 0,
+  INITIAL: 1
+};
 const DefaultExternalServices = {
   updateFindControlState(data) {},
 
   updateFindMatchesCount(data) {},
 
   initPassiveLoading(callbacks) {},
 
   fallback(data, callback) {},
@@ -1014,72 +1019,67 @@ let PDFViewerApplication = {
     pdfViewer.setDocument(pdfDocument);
     let firstPagePromise = pdfViewer.firstPagePromise;
     let pagesPromise = pdfViewer.pagesPromise;
     let onePageRendered = pdfViewer.onePageRendered;
     let pdfThumbnailViewer = this.pdfThumbnailViewer;
     pdfThumbnailViewer.setDocument(pdfDocument);
     firstPagePromise.then(pdfPage => {
       this.loadingBar.setWidth(this.appConfig.viewerContainer);
-
-      if (!_app_options.AppOptions.get('disableHistory') && !this.isViewerEmbedded) {
-        this.pdfHistory.initialize({
-          fingerprint: pdfDocument.fingerprint,
-          resetHistory: !_app_options.AppOptions.get('showPreviousViewOnLoad'),
-          updateUrl: _app_options.AppOptions.get('historyUpdateUrl')
-        });
-
-        if (this.pdfHistory.initialBookmark) {
-          this.initialBookmark = this.pdfHistory.initialBookmark;
-          this.initialRotation = this.pdfHistory.initialRotation;
-        }
-      }
-
-      let storePromise = store.getMultiple({
+      const storePromise = store.getMultiple({
         page: null,
         zoom: _ui_utils.DEFAULT_SCALE_VALUE,
         scrollLeft: '0',
         scrollTop: '0',
         rotation: null,
-        sidebarView: _pdf_sidebar.SidebarView.NONE,
-        scrollMode: null,
-        spreadMode: null
+        sidebarView: _pdf_sidebar.SidebarView.UNKNOWN,
+        scrollMode: _ui_utils.ScrollMode.UNKNOWN,
+        spreadMode: _ui_utils.SpreadMode.UNKNOWN
       }).catch(() => {});
       Promise.all([storePromise, pageModePromise, openActionDestPromise]).then(async ([values = {}, pageMode, openActionDest]) => {
-        if (openActionDest && !this.initialBookmark && !_app_options.AppOptions.get('disableOpenActionDestination')) {
-          this.initialBookmark = JSON.stringify(openActionDest);
-          this.pdfHistory.push({
-            explicitDest: openActionDest,
-            pageNumber: null
-          });
-        }
+        const viewOnLoad = _app_options.AppOptions.get('viewOnLoad');
+
+        this._initializePdfHistory({
+          fingerprint: pdfDocument.fingerprint,
+          viewOnLoad,
+          initialDest: openActionDest
+        });
 
         const initialBookmark = this.initialBookmark;
 
         const zoom = _app_options.AppOptions.get('defaultZoomValue');
 
         let hash = zoom ? `zoom=${zoom}` : null;
         let rotation = null;
 
         let sidebarView = _app_options.AppOptions.get('sidebarViewOnLoad');
 
         let scrollMode = _app_options.AppOptions.get('scrollModeOnLoad');
 
         let spreadMode = _app_options.AppOptions.get('spreadModeOnLoad');
 
-        if (values.page && _app_options.AppOptions.get('showPreviousViewOnLoad')) {
-          hash = 'page=' + values.page + '&zoom=' + (zoom || values.zoom) + ',' + values.scrollLeft + ',' + values.scrollTop;
+        if (values.page && viewOnLoad !== ViewOnLoad.INITIAL) {
+          hash = `page=${values.page}&zoom=${zoom || values.zoom},` + `${values.scrollLeft},${values.scrollTop}`;
           rotation = parseInt(values.rotation, 10);
-          sidebarView = sidebarView || values.sidebarView | 0;
-          scrollMode = scrollMode || values.scrollMode | 0;
-          spreadMode = spreadMode || values.spreadMode | 0;
-        }
-
-        if (pageMode && !_app_options.AppOptions.get('disablePageMode')) {
-          sidebarView = sidebarView || apiPageModeToSidebarView(pageMode);
+
+          if (sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
+            sidebarView = values.sidebarView | 0;
+          }
+
+          if (scrollMode === _ui_utils.ScrollMode.UNKNOWN) {
+            scrollMode = values.scrollMode | 0;
+          }
+
+          if (spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
+            spreadMode = values.spreadMode | 0;
+          }
+        }
+
+        if (pageMode && sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
+          sidebarView = apiPageModeToSidebarView(pageMode);
         }
 
         this.setInitialView(hash, {
           rotation,
           sidebarView,
           scrollMode,
           spreadMode
         });
@@ -1237,41 +1237,70 @@ let PDFViewerApplication = {
         type: 'documentInfo',
         version: versionId,
         generator: generatorId,
         formType
       });
     });
   },
 
+  _initializePdfHistory({
+    fingerprint,
+    viewOnLoad,
+    initialDest = null
+  }) {
+    if (_app_options.AppOptions.get('disableHistory') || this.isViewerEmbedded) {
+      return;
+    }
+
+    this.pdfHistory.initialize({
+      fingerprint,
+      resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
+      updateUrl: _app_options.AppOptions.get('historyUpdateUrl')
+    });
+
+    if (this.pdfHistory.initialBookmark) {
+      this.initialBookmark = this.pdfHistory.initialBookmark;
+      this.initialRotation = this.pdfHistory.initialRotation;
+    }
+
+    if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
+      this.initialBookmark = JSON.stringify(initialDest);
+      this.pdfHistory.push({
+        explicitDest: initialDest,
+        pageNumber: null
+      });
+    }
+  },
+
   setInitialView(storedHash, {
     rotation,
     sidebarView,
     scrollMode,
     spreadMode
   } = {}) {
-    let setRotation = angle => {
+    const setRotation = angle => {
       if ((0, _ui_utils.isValidRotation)(angle)) {
         this.pdfViewer.pagesRotation = angle;
       }
     };
 
-    let setViewerModes = (scroll, spread) => {
-      if (Number.isInteger(scroll)) {
+    const setViewerModes = (scroll, spread) => {
+      if ((0, _ui_utils.isValidScrollMode)(scroll)) {
         this.pdfViewer.scrollMode = scroll;
       }
 
-      if (Number.isInteger(spread)) {
+      if ((0, _ui_utils.isValidSpreadMode)(spread)) {
         this.pdfViewer.spreadMode = spread;
       }
     };
 
-    setViewerModes(scrollMode, spreadMode);
     this.isInitialViewSet = true;
     this.pdfSidebar.setInitialView(sidebarView);
+    setViewerModes(scrollMode, spreadMode);
 
     if (this.initialBookmark) {
       setRotation(this.initialRotation);
       delete this.initialRotation;
       this.pdfLinkService.setHash(this.initialBookmark);
       this.initialBookmark = null;
     } else if (storedHash) {
       setRotation(rotation);
@@ -2332,16 +2361,18 @@ exports.PDFPrintServiceFactory = PDFPrin
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.isValidRotation = isValidRotation;
+exports.isValidScrollMode = isValidScrollMode;
+exports.isValidSpreadMode = isValidSpreadMode;
 exports.isPortraitOrientation = isPortraitOrientation;
 exports.getGlobalEventBus = getGlobalEventBus;
 exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
 exports.noContextMenuHandler = noContextMenuHandler;
 exports.parseQueryString = parseQueryString;
 exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
 exports.getVisibleElements = getVisibleElements;
 exports.roundToDivide = roundToDivide;
@@ -2349,17 +2380,17 @@ exports.getPageSizeInches = getPageSizeI
 exports.approximateFraction = approximateFraction;
 exports.getOutputScale = getOutputScale;
 exports.scrollIntoView = scrollIntoView;
 exports.watchScroll = watchScroll;
 exports.binarySearchFirstItem = binarySearchFirstItem;
 exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
 exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
 exports.moveToEndOfArray = moveToEndOfArray;
-exports.WaitOnType = exports.animationStarted = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.TextLayerMode = exports.RendererType = exports.PresentationModeState = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = void 0;
+exports.WaitOnType = exports.animationStarted = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.SpreadMode = exports.ScrollMode = exports.TextLayerMode = exports.RendererType = exports.PresentationModeState = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = void 0;
 const CSS_UNITS = 96.0 / 72.0;
 exports.CSS_UNITS = CSS_UNITS;
 const DEFAULT_SCALE_VALUE = 'auto';
 exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
 const DEFAULT_SCALE = 1.0;
 exports.DEFAULT_SCALE = DEFAULT_SCALE;
 const MIN_SCALE = 0.10;
 exports.MIN_SCALE = MIN_SCALE;
@@ -2386,16 +2417,30 @@ const RendererType = {
 };
 exports.RendererType = RendererType;
 const TextLayerMode = {
   DISABLE: 0,
   ENABLE: 1,
   ENABLE_ENHANCE: 2
 };
 exports.TextLayerMode = TextLayerMode;
+const ScrollMode = {
+  UNKNOWN: -1,
+  VERTICAL: 0,
+  HORIZONTAL: 1,
+  WRAPPED: 2
+};
+exports.ScrollMode = ScrollMode;
+const SpreadMode = {
+  UNKNOWN: -1,
+  NONE: 0,
+  ODD: 1,
+  EVEN: 2
+};
+exports.SpreadMode = SpreadMode;
 
 function formatL10nValue(text, args) {
   if (!args) {
     return text;
   }
 
   return text.replace(/\{\{\s*(\w+)\s*\}\}/g, (all, name) => {
     return name in args ? args[name] : '{{' + name + '}}';
@@ -2793,16 +2838,24 @@ function normalizeWheelEventDelta(evt) {
 
   return delta;
 }
 
 function isValidRotation(angle) {
   return Number.isInteger(angle) && angle % 90 === 0;
 }
 
+function isValidScrollMode(mode) {
+  return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
+}
+
+function isValidSpreadMode(mode) {
+  return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
+}
+
 function isPortraitOrientation(size) {
   return size.width <= size.height;
 }
 
 const WaitOnType = {
   EVENT: 'event',
   TIMEOUT: 'timeout'
 };
@@ -3496,20 +3549,22 @@ Object.defineProperty(exports, "__esModu
 exports.PDFSidebar = exports.SidebarView = void 0;
 
 var _ui_utils = __webpack_require__(2);
 
 var _pdf_rendering_queue = __webpack_require__(6);
 
 const UI_NOTIFICATION_CLASS = 'pdfSidebarNotification';
 const SidebarView = {
+  UNKNOWN: -1,
   NONE: 0,
   THUMBS: 1,
   OUTLINE: 2,
-  ATTACHMENTS: 3
+  ATTACHMENTS: 3,
+  LAYERS: 4
 };
 exports.SidebarView = SidebarView;
 
 class PDFSidebar {
   constructor(options, eventBus, l10n = _ui_utils.NullL10n) {
     this.isOpen = false;
     this.active = SidebarView.THUMBS;
     this.isInitialViewSet = false;
@@ -3560,40 +3615,44 @@ class PDFSidebar {
 
   setInitialView(view = SidebarView.NONE) {
     if (this.isInitialViewSet) {
       return;
     }
 
     this.isInitialViewSet = true;
 
-    if (this.isOpen && view === SidebarView.NONE) {
+    if (view === SidebarView.NONE || view === SidebarView.UNKNOWN) {
       this._dispatchEvent();
 
       return;
     }
 
-    let isViewPreserved = view === this.visibleView;
-    this.switchView(view, true);
-
-    if (isViewPreserved) {
+    if (!this._switchView(view, true)) {
       this._dispatchEvent();
     }
   }
 
   switchView(view, forceOpen = false) {
-    if (view === SidebarView.NONE) {
-      this.close();
-      return;
-    }
-
-    let isViewChanged = view !== this.active;
+    this._switchView(view, forceOpen);
+  }
+
+  _switchView(view, forceOpen = false) {
+    const isViewChanged = view !== this.active;
     let shouldForceRendering = false;
 
     switch (view) {
+      case SidebarView.NONE:
+        if (this.isOpen) {
+          this.close();
+          return true;
+        }
+
+        return false;
+
       case SidebarView.THUMBS:
         this.thumbnailButton.classList.add('toggled');
         this.outlineButton.classList.remove('toggled');
         this.attachmentsButton.classList.remove('toggled');
         this.thumbnailView.classList.remove('hidden');
         this.outlineView.classList.add('hidden');
         this.attachmentsView.classList.add('hidden');
 
@@ -3602,61 +3661,63 @@ class PDFSidebar {
 
           shouldForceRendering = true;
         }
 
         break;
 
       case SidebarView.OUTLINE:
         if (this.outlineButton.disabled) {
-          return;
+          return false;
         }
 
         this.thumbnailButton.classList.remove('toggled');
         this.outlineButton.classList.add('toggled');
         this.attachmentsButton.classList.remove('toggled');
         this.thumbnailView.classList.add('hidden');
         this.outlineView.classList.remove('hidden');
         this.attachmentsView.classList.add('hidden');
         break;
 
       case SidebarView.ATTACHMENTS:
         if (this.attachmentsButton.disabled) {
-          return;
+          return false;
         }
 
         this.thumbnailButton.classList.remove('toggled');
         this.outlineButton.classList.remove('toggled');
         this.attachmentsButton.classList.add('toggled');
         this.thumbnailView.classList.add('hidden');
         this.outlineView.classList.add('hidden');
         this.attachmentsView.classList.remove('hidden');
         break;
 
       default:
-        console.error('PDFSidebar_switchView: "' + view + '" is an unsupported value.');
-        return;
+        console.error(`PDFSidebar._switchView: "${view}" is not a valid view.`);
+        return false;
     }
 
     this.active = view | 0;
 
     if (forceOpen && !this.isOpen) {
       this.open();
-      return;
+      return true;
     }
 
     if (shouldForceRendering) {
       this._forceRendering();
     }
 
     if (isViewChanged) {
       this._dispatchEvent();
     }
 
     this._hideUINotification(this.active);
+
+    return isViewChanged;
   }
 
   open() {
     if (this.isOpen) {
       return;
     }
 
     this.isOpen = true;
@@ -3892,28 +3953,20 @@ const defaultOptions = {
   defaultZoomValue: {
     value: '',
     kind: OptionKind.VIEWER
   },
   disableHistory: {
     value: false,
     kind: OptionKind.VIEWER
   },
-  disableOpenActionDestination: {
-    value: true,
-    kind: OptionKind.VIEWER
-  },
   disablePageLabels: {
     value: false,
     kind: OptionKind.VIEWER
   },
-  disablePageMode: {
-    value: false,
-    kind: OptionKind.VIEWER
-  },
   enablePrintAutoRotate: {
     value: false,
     kind: OptionKind.VIEWER
   },
   enableWebGL: {
     value: false,
     kind: OptionKind.VIEWER
   },
@@ -3933,69 +3986,71 @@ const defaultOptions = {
     value: false,
     kind: OptionKind.VIEWER
   },
   imageResourcesPath: {
     value: './images/',
     kind: OptionKind.VIEWER
   },
   maxCanvasPixels: {
-    value: _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216,
+    value: 16777216,
+    compatibility: _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels,
     kind: OptionKind.VIEWER
   },
   pdfBugEnabled: {
     value: false,
     kind: OptionKind.VIEWER
   },
   renderer: {
     value: 'canvas',
     kind: OptionKind.VIEWER
   },
   renderInteractiveForms: {
     value: false,
     kind: OptionKind.VIEWER
   },
-  showPreviousViewOnLoad: {
-    value: true,
-    kind: OptionKind.VIEWER
-  },
   sidebarViewOnLoad: {
-    value: 0,
+    value: -1,
     kind: OptionKind.VIEWER
   },
   scrollModeOnLoad: {
-    value: 0,
+    value: -1,
     kind: OptionKind.VIEWER
   },
   spreadModeOnLoad: {
-    value: 0,
+    value: -1,
     kind: OptionKind.VIEWER
   },
   textLayerMode: {
     value: 1,
     kind: OptionKind.VIEWER
   },
   useOnlyCssZoom: {
     value: false,
     kind: OptionKind.VIEWER
   },
+  viewOnLoad: {
+    value: 0,
+    kind: OptionKind.VIEWER
+  },
   cMapPacked: {
     value: true,
     kind: OptionKind.API
   },
   cMapUrl: {
     value: '../web/cmaps/',
     kind: OptionKind.API
   },
   disableAutoFetch: {
     value: false,
     kind: OptionKind.API
   },
   disableCreateObjectURL: {
-    value: _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL || false,
+    value: false,
+    compatibility: _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL,
     kind: OptionKind.API
   },
   disableFontFace: {
     value: false,
     kind: OptionKind.API
   },
   disableRange: {
     value: false,
@@ -4038,38 +4093,43 @@ const defaultOptions = {
 const userOptions = Object.create(null);
 
 class AppOptions {
   constructor() {
     throw new Error('Cannot initialize AppOptions.');
   }
 
   static get(name) {
-    let defaultOption = defaultOptions[name],
-        userOption = userOptions[name];
+    const userOption = userOptions[name];
 
     if (userOption !== undefined) {
       return userOption;
     }
 
-    return defaultOption !== undefined ? defaultOption.value : undefined;
+    const defaultOption = defaultOptions[name];
+
+    if (defaultOption !== undefined) {
+      return defaultOption.compatibility || defaultOption.value;
+    }
+
+    return undefined;
   }
 
   static getAll(kind = null) {
-    let options = Object.create(null);
-
-    for (let name in defaultOptions) {
-      let defaultOption = defaultOptions[name],
-          userOption = userOptions[name];
-
-      if (kind && defaultOption.kind !== kind) {
+    const options = Object.create(null);
+
+    for (const name in defaultOptions) {
+      const defaultOption = defaultOptions[name];
+
+      if (kind && kind !== defaultOption.kind) {
         continue;
       }
 
-      options[name] = userOption !== undefined ? userOption : defaultOption.value;
+      const userOption = userOptions[name];
+      options[name] = userOption !== undefined ? userOption : defaultOption.compatibility || defaultOption.value;
     }
 
     return options;
   }
 
   static set(name, value) {
     userOptions[name] = value;
   }
@@ -8206,45 +8266,33 @@ exports.PDFViewer = PDFViewer;
 /***/ (function(module, exports, __webpack_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
-exports.SpreadMode = exports.ScrollMode = exports.BaseViewer = void 0;
+exports.BaseViewer = void 0;
 
 var _ui_utils = __webpack_require__(2);
 
 var _pdf_rendering_queue = __webpack_require__(6);
 
 var _annotation_layer_builder = __webpack_require__(26);
 
 var _pdfjsLib = __webpack_require__(3);
 
 var _pdf_page_view = __webpack_require__(27);
 
 var _pdf_link_service = __webpack_require__(18);
 
 var _text_layer_builder = __webpack_require__(28);
 
 const DEFAULT_CACHE_SIZE = 10;
-const ScrollMode = {
-  VERTICAL: 0,
-  HORIZONTAL: 1,
-  WRAPPED: 2
-};
-exports.ScrollMode = ScrollMode;
-const SpreadMode = {
-  NONE: 0,
-  ODD: 1,
-  EVEN: 2
-};
-exports.SpreadMode = SpreadMode;
 
 function PDFPageViewBuffer(size) {
   let data = [];
 
   this.push = function (view) {
     let i = data.indexOf(view);
 
     if (i >= 0) {
@@ -8514,28 +8562,26 @@ class BaseViewer {
     this.pagesPromise = pagesCapability.promise;
     pagesCapability.promise.then(() => {
       this._pageViewsReady = true;
       this.eventBus.dispatch('pagesloaded', {
         source: this,
         pagesCount
       });
     });
-    let isOnePageRenderedResolved = false;
-    let onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
+    const onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
     this.onePageRendered = onePageRenderedCapability.promise;
 
     let bindOnAfterAndBeforeDraw = pageView => {
       pageView.onBeforeDraw = () => {
         this._buffer.push(pageView);
       };
 
       pageView.onAfterDraw = () => {
-        if (!isOnePageRenderedResolved) {
-          isOnePageRenderedResolved = true;
+        if (!onePageRenderedCapability.settled) {
           onePageRenderedCapability.resolve();
         }
       };
     };
 
     let firstPagePromise = pdfDocument.getPage(1);
     this.firstPagePromise = firstPagePromise;
     firstPagePromise.then(pdfPage => {
@@ -8569,17 +8615,17 @@ class BaseViewer {
           maxCanvasPixels: this.maxCanvasPixels,
           l10n: this.l10n
         });
         bindOnAfterAndBeforeDraw(pageView);
 
         this._pages.push(pageView);
       }
 
-      if (this._spreadMode !== SpreadMode.NONE) {
+      if (this._spreadMode !== _ui_utils.SpreadMode.NONE) {
         this._updateSpreadMode();
       }
 
       onePageRenderedCapability.promise.then(() => {
         if (pdfDocument.loadingParams['disableAutoFetch']) {
           pagesCapability.resolve();
           return;
         }
@@ -8651,18 +8697,18 @@ class BaseViewer {
     this._currentScale = _ui_utils.UNKNOWN_SCALE;
     this._currentScaleValue = null;
     this._pageLabels = null;
     this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
     this._location = null;
     this._pagesRotation = 0;
     this._pagesRequests = [];
     this._pageViewsReady = false;
-    this._scrollMode = ScrollMode.VERTICAL;
-    this._spreadMode = SpreadMode.NONE;
+    this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
+    this._spreadMode = _ui_utils.SpreadMode.NONE;
     this.viewer.textContent = '';
 
     this._updateScrollMode();
   }
 
   _scrollUpdate() {
     if (this.pagesCount === 0) {
       return;
@@ -8970,17 +9016,17 @@ class BaseViewer {
     return this.container.contains(element);
   }
 
   focus() {
     this.container.focus();
   }
 
   get _isScrollModeHorizontal() {
-    return this.isInPresentationMode ? false : this._scrollMode === ScrollMode.HORIZONTAL;
+    return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
   }
 
   get isInPresentationMode() {
     return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
   }
 
   get isChangingPresentationMode() {
     return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
@@ -9165,34 +9211,34 @@ class BaseViewer {
     return this._scrollMode;
   }
 
   set scrollMode(mode) {
     if (this._scrollMode === mode) {
       return;
     }
 
-    if (!Number.isInteger(mode) || !Object.values(ScrollMode).includes(mode)) {
+    if (!(0, _ui_utils.isValidScrollMode)(mode)) {
       throw new Error(`Invalid scroll mode: ${mode}`);
     }
 
     this._scrollMode = mode;
     this.eventBus.dispatch('scrollmodechanged', {
       source: this,
       mode
     });
 
     this._updateScrollMode(this._currentPageNumber);
   }
 
   _updateScrollMode(pageNumber = null) {
     const scrollMode = this._scrollMode,
           viewer = this.viewer;
-    viewer.classList.toggle('scrollHorizontal', scrollMode === ScrollMode.HORIZONTAL);
-    viewer.classList.toggle('scrollWrapped', scrollMode === ScrollMode.WRAPPED);
+    viewer.classList.toggle('scrollHorizontal', scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
+    viewer.classList.toggle('scrollWrapped', scrollMode === _ui_utils.ScrollMode.WRAPPED);
 
     if (!this.pdfDocument || !pageNumber) {
       return;
     }
 
     if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
       this._setScale(this._currentScaleValue, true);
     }
@@ -9206,17 +9252,17 @@ class BaseViewer {
     return this._spreadMode;
   }
 
   set spreadMode(mode) {
     if (this._spreadMode === mode) {
       return;
     }
 
-    if (!Number.isInteger(mode) || !Object.values(SpreadMode).includes(mode)) {
+    if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
       throw new Error(`Invalid spread mode: ${mode}`);
     }
 
     this._spreadMode = mode;
     this.eventBus.dispatch('spreadmodechanged', {
       source: this,
       mode
     });
@@ -9228,17 +9274,17 @@ class BaseViewer {
     if (!this.pdfDocument) {
       return;
     }
 
     const viewer = this.viewer,
           pages = this._pages;
     viewer.textContent = '';
 
-    if (this._spreadMode === SpreadMode.NONE) {
+    if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
       for (let i = 0, iMax = pages.length; i < iMax; ++i) {
         viewer.appendChild(pages[i].div);
       }
     } else {
       const parity = this._spreadMode - 1;
       let spread = null;
 
       for (let i = 0, iMax = pages.length; i < iMax; ++i) {
@@ -10340,24 +10386,22 @@ exports.DefaultTextLayerFactory = Defaul
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.SecondaryToolbar = void 0;
 
-var _base_viewer = __webpack_require__(25);
+var _ui_utils = __webpack_require__(2);
 
 var _pdf_cursor_tools = __webpack_require__(4);
 
 var _pdf_single_page_viewer = __webpack_require__(30);
 
-var _ui_utils = __webpack_require__(2);
-
 class SecondaryToolbar {
   constructor(options, mainContainer, eventBus) {
     this.toolbar = options.toolbar;
     this.toggleButton = options.toggleButton;
     this.toolbarButtonContainer = options.toolbarButtonContainer;
     this.buttons = [{
       element: options.presentationModeButton,
       eventName: 'presentationmode',
@@ -10407,52 +10451,52 @@ class SecondaryToolbar {
       eventDetails: {
         tool: _pdf_cursor_tools.CursorTool.HAND
       },
       close: true
     }, {
       element: options.scrollVerticalButton,
       eventName: 'switchscrollmode',
       eventDetails: {
-        mode: _base_viewer.ScrollMode.VERTICAL
+        mode: _ui_utils.ScrollMode.VERTICAL
       },
       close: true
     }, {
       element: options.scrollHorizontalButton,
       eventName: 'switchscrollmode',
       eventDetails: {
-        mode: _base_viewer.ScrollMode.HORIZONTAL
+        mode: _ui_utils.ScrollMode.HORIZONTAL
       },
       close: true
     }, {
       element: options.scrollWrappedButton,
       eventName: 'switchscrollmode',
       eventDetails: {
-        mode: _base_viewer.ScrollMode.WRAPPED
+        mode: _ui_utils.ScrollMode.WRAPPED
       },
       close: true
     }, {
       element: options.spreadNoneButton,
       eventName: 'switchspreadmode',
       eventDetails: {
-        mode: _base_viewer.SpreadMode.NONE
+        mode: _ui_utils.SpreadMode.NONE
       },
       close: true
     }, {
       element: options.spreadOddButton,
       eventName: 'switchspreadmode',
       eventDetails: {
-        mode: _base_viewer.SpreadMode.ODD
+        mode: _ui_utils.SpreadMode.ODD
       },
       close: true
     }, {
       element: options.spreadEvenButton,
       eventName: 'switchspreadmode',
       eventDetails: {
-        mode: _base_viewer.SpreadMode.EVEN
+        mode: _ui_utils.SpreadMode.EVEN
       },
       close: true
     }, {
       element: options.documentPropertiesButton,
       eventName: 'documentproperties',
       close: true
     }];
     this.items = {
@@ -10569,71 +10613,71 @@ class SecondaryToolbar {
 
   _bindScrollModeListener(buttons) {
     function scrollModeChanged(evt) {
       buttons.scrollVerticalButton.classList.remove('toggled');
       buttons.scrollHorizontalButton.classList.remove('toggled');
       buttons.scrollWrappedButton.classList.remove('toggled');
 
       switch (evt.mode) {
-        case _base_viewer.ScrollMode.VERTICAL:
+        case _ui_utils.ScrollMode.VERTICAL:
           buttons.scrollVerticalButton.classList.add('toggled');
           break;
 
-        case _base_viewer.ScrollMode.HORIZONTAL:
+        case _ui_utils.ScrollMode.HORIZONTAL:
           buttons.scrollHorizontalButton.classList.add('toggled');
           break;
 
-        case _base_viewer.ScrollMode.WRAPPED:
+        case _ui_utils.ScrollMode.WRAPPED:
           buttons.scrollWrappedButton.classList.add('toggled');
           break;
       }
 
-      const isScrollModeHorizontal = evt.mode === _base_viewer.ScrollMode.HORIZONTAL;
+      const isScrollModeHorizontal = evt.mode === _ui_utils.ScrollMode.HORIZONTAL;
       buttons.spreadNoneButton.disabled = isScrollModeHorizontal;
       buttons.spreadOddButton.disabled = isScrollModeHorizontal;
       buttons.spreadEvenButton.disabled = isScrollModeHorizontal;
     }
 
     this.eventBus.on('scrollmodechanged', scrollModeChanged);
     this.eventBus.on('secondarytoolbarreset', evt => {
       if (evt.source === this) {
         scrollModeChanged({
-          mode: _base_viewer.ScrollMode.VERTICAL
+          mode: _ui_utils.ScrollMode.VERTICAL
         });
       }
     });
   }
 
   _bindSpreadModeListener(buttons) {
     function spreadModeChanged(evt) {
       buttons.spreadNoneButton.classList.remove('toggled');
       buttons.spreadOddButton.classList.remove('toggled');
       buttons.spreadEvenButton.classList.remove('toggled');
 
       switch (evt.mode) {
-        case _base_viewer.SpreadMode.NONE:
+        case _ui_utils.SpreadMode.NONE:
           buttons.spreadNoneButton.classList.add('toggled');
           break;
 
-        case _base_viewer.SpreadMode.ODD:
+        case _ui_utils.SpreadMode.ODD:
           buttons.spreadOddButton.classList.add('toggled');
           break;
 
-        case _base_viewer.SpreadMode.EVEN:
+        case _ui_utils.SpreadMode.EVEN:
           buttons.spreadEvenButton.classList.add('toggled');
           break;
       }
     }
 
     this.eventBus.on('spreadmodechanged', spreadModeChanged);
     this.eventBus.on('secondarytoolbarreset', evt => {
       if (evt.source === this) {
         spreadModeChanged({
-          mode: _base_viewer.SpreadMode.NONE
+          mode: _ui_utils.SpreadMode.NONE
         });
       }
     });
   }
 
   open() {
     if (this.opened) {
       return;
@@ -11588,39 +11632,37 @@ Object.defineProperty(exports, "__esModu
   value: true
 });
 exports.BasePreferences = void 0;
 let defaultPreferences = null;
 
 function getDefaultPreferences() {
   if (!defaultPreferences) {
     defaultPreferences = Promise.resolve({
-      "showPreviousViewOnLoad": true,
+      "viewOnLoad": 0,
       "defaultZoomValue": "",
-      "sidebarViewOnLoad": 0,
+      "sidebarViewOnLoad": -1,
       "cursorToolOnLoad": 0,
       "enableWebGL": false,
       "eventBusDispatchToDOM": false,
       "pdfBugEnabled": false,
       "disableRange": false,
       "disableStream": false,
       "disableAutoFetch": false,
       "disableFontFace": false,
       "textLayerMode": 1,
       "useOnlyCssZoom": false,
       "externalLinkTarget": 0,
       "renderer": "canvas",
       "renderInteractiveForms": false,
       "enablePrintAutoRotate": false,
-      "disableOpenActionDestination": true,
-      "disablePageMode": false,
       "disablePageLabels": false,
       "historyUpdateUrl": false,
-      "scrollModeOnLoad": 0,
-      "spreadModeOnLoad": 0
+      "scrollModeOnLoad": -1,
+      "spreadModeOnLoad": -1
     });
   }
 
   return defaultPreferences;
 }
 
 class BasePreferences {
   constructor() {
--- a/browser/extensions/pdfjs/moz.yaml
+++ b/browser/extensions/pdfjs/moz.yaml
@@ -15,15 +15,15 @@ origin:
   description: Portable Document Format (PDF) viewer that is built with HTML5
 
   # Full URL for the package's homepage/etc
   # Usually different from repository url
   url: https://github.com/mozilla/pdf.js
 
   # Human-readable identifier for this version/release
   # Generally "version NNN", "tag SSS", "bookmark SSS"
-  release: version 2.1.228
+  release: version 2.1.243
 
   # The package's license, where possible using the mnemonic from
   # https://spdx.org/licenses/
   # Multiple licenses can be specified (as a YAML list)
   # A "LICENSE" file must exist containing the full license text
   license: Apache-2.0