Bug 1546108 - Update pdf.js to version 2.2.154. r=bdahl
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 22 Apr 2019 10:35:08 -0400
changeset 470333 06eb1ecb4aed1e84554693ceeebddc93c5f4f686
parent 470332 ab1da7fa2ad0aa1c9d6d0a9e2f63e6492cd1b712
child 470350 b4b482a09cf0f1c7f31ee8d08266108f5d07d27e
push id112864
push userryanvm@gmail.com
push dateMon, 22 Apr 2019 14:35:41 +0000
treeherdermozilla-inbound@06eb1ecb4aed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbdahl
bugs1546108
milestone68.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 1546108 - Update pdf.js to version 2.2.154. r=bdahl
browser/extensions/pdfjs/README.mozilla
browser/extensions/pdfjs/content/build/pdf.js
browser/extensions/pdfjs/content/build/pdf.worker.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.2.145
+Current extension version is: 2.2.154
 
-Taken from upstream commit: 8bbae798
+Taken from upstream commit: 762c58e0
--- 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.2.145';
-var pdfjsBuild = '8bbae798';
+var pdfjsVersion = '2.2.154';
+var pdfjsBuild = '762c58e0';
 
 var pdfjsSharedUtil = __w_pdfjs_require__(1);
 
 var pdfjsDisplayAPI = __w_pdfjs_require__(6);
 
 var pdfjsDisplayTextLayer = __w_pdfjs_require__(18);
 
 var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(19);
@@ -1298,17 +1298,17 @@ function _fetchDocument(worker, source, 
   if (pdfDataRangeTransport) {
     source.length = pdfDataRangeTransport.length;
     source.initialData = pdfDataRangeTransport.initialData;
     source.progressiveDone = pdfDataRangeTransport.progressiveDone;
   }
 
   return worker.messageHandler.sendWithPromise('GetDocRequest', {
     docId,
-    apiVersion: '2.2.145',
+    apiVersion: '2.2.154',
     source: {
       data: source.data,
       url: source.url,
       password: source.password,
       disableAutoFetch: source.disableAutoFetch,
       rangeChunkSize: source.rangeChunkSize,
       length: source.length
     },
@@ -1481,16 +1481,20 @@ class PDFDocumentProxy {
   getPageLayout() {
     return this._transport.getPageLayout();
   }
 
   getPageMode() {
     return this._transport.getPageMode();
   }
 
+  getViewerPreferences() {
+    return this._transport.getViewerPreferences();
+  }
+
   getOpenActionDestination() {
     return this._transport.getOpenActionDestination();
   }
 
   getAttachments() {
     return this._transport.getAttachments();
   }
 
@@ -2527,16 +2531,17 @@ class WorkerTransport {
               id
             }).finally(() => {
               this.commonObjs.resolve(id, font);
             });
           });
           break;
 
         case 'FontPath':
+        case 'FontType3Res':
           this.commonObjs.resolve(id, exportedData);
           break;
 
         default:
           throw new Error(`Got unknown common object type ${type}`);
       }
     }, this);
     messageHandler.on('obj', function (data) {
@@ -2773,18 +2778,22 @@ class WorkerTransport {
   getPageLayout() {
     return this.messageHandler.sendWithPromise('GetPageLayout', null);
   }
 
   getPageMode() {
     return this.messageHandler.sendWithPromise('GetPageMode', null);
   }
 
+  getViewerPreferences() {
+    return this.messageHandler.sendWithPromise('GetViewerPreferences', null);
+  }
+
   getOpenActionDestination() {
-    return this.messageHandler.sendWithPromise('getOpenActionDestination', null);
+    return this.messageHandler.sendWithPromise('GetOpenActionDestination', null);
   }
 
   getAttachments() {
     return this.messageHandler.sendWithPromise('GetAttachments', null);
   }
 
   getJavaScript() {
     return this.messageHandler.sendWithPromise('GetJavaScript', null);
@@ -3083,19 +3092,19 @@ const InternalRenderTask = function Inte
       }
     }
 
   }
 
   return InternalRenderTask;
 }();
 
-const version = '2.2.145';
+const version = '2.2.154';
 exports.version = version;
-const build = '8bbae798';
+const build = '762c58e0';
 exports.build = build;
 
 /***/ }),
 /* 7 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
@@ -4525,22 +4534,18 @@ var CanvasGraphics = function CanvasGrap
           return i;
         }
 
         fnId = fnArray[i];
 
         if (fnId !== _util.OPS.dependency) {
           this[fnId].apply(this, argsArray[i]);
         } else {
-          var deps = argsArray[i];
-
-          for (var n = 0, nn = deps.length; n < nn; n++) {
-            var depObjId = deps[n];
-            var common = depObjId[0] === 'g' && depObjId[1] === '_';
-            var objsPool = common ? commonObjs : objs;
+          for (const depObjId of argsArray[i]) {
+            const objsPool = depObjId.startsWith('g_') ? commonObjs : objs;
 
             if (!objsPool.has(depObjId)) {
               objsPool.get(depObjId, continueCallback);
               return i;
             }
           }
         }
 
@@ -5538,17 +5543,17 @@ var CanvasGraphics = function CanvasGrap
 
       this.transform.apply(this, transform);
       this.transform.apply(this, matrix);
     },
     endAnnotation: function CanvasGraphics_endAnnotation() {
       this.restore();
     },
     paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
-      var domImage = this.objs.get(objId);
+      const domImage = this.processingType3 ? this.commonObjs.get(objId) : this.objs.get(objId);
 
       if (!domImage) {
         (0, _util.warn)('Dependent image isn\'t ready yet');
         return;
       }
 
       this.save();
       var ctx = this.ctx;
@@ -5647,27 +5652,27 @@ var CanvasGraphics = function CanvasGrap
         ctx.save();
         ctx.transform.apply(ctx, image.transform);
         ctx.scale(1, -1);
         ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
         ctx.restore();
       }
     },
     paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
-      var imgData = this.objs.get(objId);
+      const imgData = this.processingType3 ? this.commonObjs.get(objId) : this.objs.get(objId);
 
       if (!imgData) {
         (0, _util.warn)('Dependent image isn\'t ready yet');
         return;
       }
 
       this.paintInlineImageXObject(imgData);
     },
     paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
-      var imgData = this.objs.get(objId);
+      const imgData = this.processingType3 ? this.commonObjs.get(objId) : this.objs.get(objId);
 
       if (!imgData) {
         (0, _util.warn)('Dependent image isn\'t ready yet');
         return;
       }
 
       var width = imgData.width;
       var height = imgData.height;
@@ -7398,34 +7403,33 @@ var PDFDataTransportStream = function PD
       }
     },
 
     get _progressiveDataLength() {
       return this._fullRequestReader ? this._fullRequestReader._loaded : 0;
     },
 
     _onProgress: function PDFDataTransportStream_onDataProgress(evt) {
-      if (evt.total === undefined && this._rangeReaders.length > 0) {
-        var firstReader = this._rangeReaders[0];
-
-        if (firstReader.onProgress) {
+      if (evt.total === undefined) {
+        let firstReader = this._rangeReaders[0];
+
+        if (firstReader && firstReader.onProgress) {
           firstReader.onProgress({
             loaded: evt.loaded
           });
-          return;
         }
-      }
-
-      let fullReader = this._fullRequestReader;
-
-      if (fullReader && fullReader.onProgress) {
-        fullReader.onProgress({
-          loaded: evt.loaded,
-          total: evt.total
-        });
+      } else {
+        let fullReader = this._fullRequestReader;
+
+        if (fullReader && fullReader.onProgress) {
+          fullReader.onProgress({
+            loaded: evt.loaded,
+            total: evt.total
+          });
+        }
       }
     },
 
     _onProgressiveDone() {
       if (this._fullRequestReader) {
         this._fullRequestReader.progressiveDone();
       }
 
--- 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.2.145';
-const pdfjsBuild = '8bbae798';
+const pdfjsVersion = '2.2.154';
+const pdfjsBuild = '762c58e0';
 
 const pdfjsCoreWorker = __w_pdfjs_require__(1);
 
 exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
 
 /***/ }),
 /* 1 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
@@ -373,17 +373,17 @@ var WorkerMessageHandler = {
 
   createDocumentHandler(docParams, port) {
     var pdfManager;
     var terminated = false;
     var cancelXHRs = null;
     var WorkerTasks = [];
     const verbosity = (0, _util.getVerbosityLevel)();
     let apiVersion = docParams.apiVersion;
-    let workerVersion = '2.2.145';
+    let workerVersion = '2.2.154';
 
     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';
@@ -645,17 +645,20 @@ var WorkerMessageHandler = {
       return pdfManager.ensureCatalog('pageLabels');
     });
     handler.on('GetPageLayout', function wphSetupGetPageLayout(data) {
       return pdfManager.ensureCatalog('pageLayout');
     });
     handler.on('GetPageMode', function wphSetupGetPageMode(data) {
       return pdfManager.ensureCatalog('pageMode');
     });
-    handler.on('getOpenActionDestination', function (data) {
+    handler.on('GetViewerPreferences', function (data) {
+      return pdfManager.ensureCatalog('viewerPreferences');
+    });
+    handler.on('GetOpenActionDestination', function (data) {
       return pdfManager.ensureCatalog('openActionDestination');
     });
     handler.on('GetAttachments', function wphSetupGetAttachments(data) {
       return pdfManager.ensureCatalog('attachments');
     });
     handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
       return pdfManager.ensureCatalog('javaScript');
     });
@@ -2709,23 +2712,26 @@ class Page {
     this.pageDict = pageDict;
     this.xref = xref;
     this.ref = ref;
     this.fontCache = fontCache;
     this.builtInCMapCache = builtInCMapCache;
     this.pdfFunctionFactory = pdfFunctionFactory;
     this.evaluatorOptions = pdfManager.evaluatorOptions;
     this.resourcesPromise = null;
-    const uniquePrefix = `p${this.pageIndex}_`;
     const idCounters = {
       obj: 0
     };
     this.idFactory = {
       createObjId() {
-        return uniquePrefix + ++idCounters.obj;
+        return `p${pageIndex}_${++idCounters.obj}`;
+      },
+
+      getDocId() {
+        return `g_${pdfManager.docId}`;
       }
 
     };
   }
 
   _getInheritableProperty(key, getArray = false) {
     const value = (0, _core_utils.getInheritableProperty)({
       dict: this.pageDict,
@@ -2847,17 +2853,16 @@ class Page {
     handler,
     task,
     intent,
     renderInteractiveForms
   }) {
     const contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream');
     const resourcesPromise = this.loadResources(['ExtGState', 'ColorSpace', 'Pattern', 'Shading', 'XObject', 'Font']);
     const partialEvaluator = new _evaluator.PartialEvaluator({
-      pdfManager: this.pdfManager,
       xref: this.xref,
       handler,
       pageIndex: this.pageIndex,
       idFactory: this.idFactory,
       fontCache: this.fontCache,
       builtInCMapCache: this.builtInCMapCache,
       options: this.evaluatorOptions,
       pdfFunctionFactory: this.pdfFunctionFactory
@@ -2914,17 +2919,16 @@ class Page {
     sink,
     combineTextItems
   }) {
     const contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream');
     const resourcesPromise = this.loadResources(['ExtGState', 'XObject', 'Font']);
     const dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
     return dataPromises.then(([contentStream]) => {
       const partialEvaluator = new _evaluator.PartialEvaluator({
-        pdfManager: this.pdfManager,
         xref: this.xref,
         handler,
         pageIndex: this.pageIndex,
         idFactory: this.idFactory,
         fontCache: this.fontCache,
         builtInCMapCache: this.builtInCMapCache,
         options: this.evaluatorOptions,
         pdfFunctionFactory: this.pdfFunctionFactory
@@ -3791,16 +3795,169 @@ class Catalog {
         case 'UseAttachments':
           pageMode = obj.name;
       }
     }
 
     return (0, _util.shadow)(this, 'pageMode', pageMode);
   }
 
+  get viewerPreferences() {
+    const ViewerPreferencesValidators = {
+      HideToolbar: _util.isBool,
+      HideMenubar: _util.isBool,
+      HideWindowUI: _util.isBool,
+      FitWindow: _util.isBool,
+      CenterWindow: _util.isBool,
+      DisplayDocTitle: _util.isBool,
+      NonFullScreenPageMode: _primitives.isName,
+      Direction: _primitives.isName,
+      ViewArea: _primitives.isName,
+      ViewClip: _primitives.isName,
+      PrintArea: _primitives.isName,
+      PrintClip: _primitives.isName,
+      PrintScaling: _primitives.isName,
+      Duplex: _primitives.isName,
+      PickTrayByPDFSize: _util.isBool,
+      PrintPageRange: Array.isArray,
+      NumCopies: Number.isInteger
+    };
+    const obj = this.catDict.get('ViewerPreferences');
+    const prefs = Object.create(null);
+
+    if ((0, _primitives.isDict)(obj)) {
+      for (const key in ViewerPreferencesValidators) {
+        if (!obj.has(key)) {
+          continue;
+        }
+
+        const value = obj.get(key);
+
+        if (!ViewerPreferencesValidators[key](value)) {
+          (0, _util.info)(`Bad value in ViewerPreferences for "${key}".`);
+          continue;
+        }
+
+        let prefValue;
+
+        switch (key) {
+          case 'NonFullScreenPageMode':
+            switch (value.name) {
+              case 'UseNone':
+              case 'UseOutlines':
+              case 'UseThumbs':
+              case 'UseOC':
+                prefValue = value.name;
+                break;
+
+              default:
+                prefValue = 'UseNone';
+            }
+
+            break;
+
+          case 'Direction':
+            switch (value.name) {
+              case 'L2R':
+              case 'R2L':
+                prefValue = value.name;
+                break;
+
+              default:
+                prefValue = 'L2R';
+            }
+
+            break;
+
+          case 'ViewArea':
+          case 'ViewClip':
+          case 'PrintArea':
+          case 'PrintClip':
+            switch (value.name) {
+              case 'MediaBox':
+              case 'CropBox':
+              case 'BleedBox':
+              case 'TrimBox':
+              case 'ArtBox':
+                prefValue = value.name;
+                break;
+
+              default:
+                prefValue = 'CropBox';
+            }
+
+            break;
+
+          case 'PrintScaling':
+            switch (value.name) {
+              case 'None':
+              case 'AppDefault':
+                prefValue = value.name;
+                break;
+
+              default:
+                prefValue = 'AppDefault';
+            }
+
+            break;
+
+          case 'Duplex':
+            switch (value.name) {
+              case 'Simplex':
+              case 'DuplexFlipShortEdge':
+              case 'DuplexFlipLongEdge':
+                prefValue = value.name;
+                break;
+
+              default:
+                prefValue = 'None';
+            }
+
+            break;
+
+          case 'PrintPageRange':
+            const length = value.length;
+
+            if (length % 2 !== 0) {
+              break;
+            }
+
+            const isValid = value.every((page, i, arr) => {
+              return Number.isInteger(page) && page > 0 && (i === 0 || page >= arr[i - 1]) && page <= this.numPages;
+            });
+
+            if (isValid) {
+              prefValue = value;
+            }
+
+            break;
+
+          case 'NumCopies':
+            if (value > 0) {
+              prefValue = value;
+            }
+
+            break;
+
+          default:
+            (0, _util.assert)(typeof value === 'boolean');
+            prefValue = value;
+        }
+
+        if (prefValue !== undefined) {
+          prefs[key] = prefValue;
+        } else {
+          (0, _util.info)(`Bad value in ViewerPreferences for "${key}".`);
+        }
+      }
+    }
+
+    return (0, _util.shadow)(this, 'viewerPreferences', prefs);
+  }
+
   get openActionDestination() {
     const obj = this.catDict.get('OpenAction');
     let openActionDest = null;
 
     if ((0, _primitives.isDict)(obj)) {
       const destDict = new _primitives.Dict(this.xref);
       destDict.set('A', obj);
       const resultObj = {
@@ -18036,17 +18193,17 @@ class AnnotationFactory {
 
   static _create(xref, ref, pdfManager, idFactory) {
     let dict = xref.fetchIfRef(ref);
 
     if (!(0, _primitives.isDict)(dict)) {
       return;
     }
 
-    let id = (0, _primitives.isRef)(ref) ? ref.toString() : 'annot_' + idFactory.createObjId();
+    let id = (0, _primitives.isRef)(ref) ? ref.toString() : `annot_${idFactory.createObjId()}`;
     let subtype = dict.get('Subtype');
     subtype = (0, _primitives.isName)(subtype) ? subtype.name : null;
     let parameters = {
       xref,
       dict,
       ref: (0, _primitives.isRef)(ref) ? ref : null,
       subtype,
       id,
@@ -19654,35 +19811,34 @@ var PartialEvaluator = function PartialE
     maxImageSize: -1,
     disableFontFace: false,
     nativeImageDecoderSupport: _util.NativeImageDecoding.DECODE,
     ignoreErrors: false,
     isEvalSupported: true
   };
 
   function PartialEvaluator({
-    pdfManager,
     xref,
     handler,
     pageIndex,
     idFactory,
     fontCache,
     builtInCMapCache,
     options = null,
     pdfFunctionFactory
   }) {
-    this.pdfManager = pdfManager;
     this.xref = xref;
     this.handler = handler;
     this.pageIndex = pageIndex;
     this.idFactory = idFactory;
     this.fontCache = fontCache;
     this.builtInCMapCache = builtInCMapCache;
     this.options = options || DefaultPartialEvaluatorOptions;
     this.pdfFunctionFactory = pdfFunctionFactory;
+    this.parsingType3Font = false;
 
     this.fetchBuiltInCMap = async name => {
       if (this.builtInCMapCache.has(name)) {
         return this.builtInCMapCache.get(name);
       }
 
       const data = await this.handler.sendWithPromise('FetchBuiltInCMap', {
         name
@@ -19919,39 +20075,39 @@ var PartialEvaluator = function PartialE
         operatorList.addOp(_util.OPS.paintFormXObjectEnd, []);
 
         if (group) {
           operatorList.addOp(_util.OPS.endGroup, [groupOptions]);
         }
       });
     },
 
-    buildPaintImageXObject({
+    async buildPaintImageXObject({
       resources,
       image,
       isInline = false,
       operatorList,
       cacheKey,
       imageCache,
       forceDisableNativeImageDecoder = false
     }) {
       var dict = image.dict;
       var w = dict.get('Width', 'W');
       var h = dict.get('Height', 'H');
 
       if (!(w && (0, _util.isNum)(w)) || !(h && (0, _util.isNum)(h))) {
         (0, _util.warn)('Image dimensions are missing, or not numbers.');
-        return Promise.resolve();
+        return;
       }
 
       var maxImageSize = this.options.maxImageSize;
 
       if (maxImageSize !== -1 && w * h > maxImageSize) {
         (0, _util.warn)('Image exceeded maximum allowed size and was removed.');
-        return Promise.resolve();
+        return;
       }
 
       var imageMask = dict.get('ImageMask', 'IM') || false;
       var imgData, args;
 
       if (imageMask) {
         var width = dict.get('Width', 'W');
         var height = dict.get('Height', 'H');
@@ -19971,38 +20127,43 @@ var PartialEvaluator = function PartialE
 
         if (cacheKey) {
           imageCache[cacheKey] = {
             fn: _util.OPS.paintImageMaskXObject,
             args
           };
         }
 
-        return Promise.resolve();
+        return;
       }
 
       var softMask = dict.get('SMask', 'SM') || false;
       var mask = dict.get('Mask') || false;
       var SMALL_IMAGE_DIMENSIONS = 200;
 
       if (isInline && !softMask && !mask && !(image instanceof _jpeg_stream.JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
         let imageObj = new _image.PDFImage({
           xref: this.xref,
           res: resources,
           image,
           isInline,
           pdfFunctionFactory: this.pdfFunctionFactory
         });
         imgData = imageObj.createImageData(true);
         operatorList.addOp(_util.OPS.paintInlineImageXObject, [imgData]);
-        return Promise.resolve();
+        return;
       }
 
       const nativeImageDecoderSupport = forceDisableNativeImageDecoder ? _util.NativeImageDecoding.NONE : this.options.nativeImageDecoderSupport;
-      var objId = 'img_' + this.idFactory.createObjId();
+      let objId = `img_${this.idFactory.createObjId()}`;
+
+      if (this.parsingType3Font) {
+        (0, _util.assert)(nativeImageDecoderSupport === _util.NativeImageDecoding.NONE, 'Type3 image resources should be completely decoded in the worker.');
+        objId = `${this.idFactory.getDocId()}_type3res_${objId}`;
+      }
 
       if (nativeImageDecoderSupport !== _util.NativeImageDecoding.NONE && !softMask && !mask && image instanceof _jpeg_stream.JpegStream && _image_utils.NativeImageDecoder.isSupported(image, this.xref, resources, this.pdfFunctionFactory)) {
         return this.handler.sendWithPromise('obj', [objId, this.pageIndex, 'JpegStream', image.getIR(this.options.forceDataSchema)]).then(function () {
           operatorList.addDependency(objId);
           args = [objId, w, h];
           operatorList.addOp(_util.OPS.paintJpegXObject, args);
 
           if (cacheKey) {
@@ -20035,42 +20196,54 @@ var PartialEvaluator = function PartialE
           forceDataSchema: this.options.forceDataSchema,
           pdfFunctionFactory: this.pdfFunctionFactory
         });
       }
 
       operatorList.addDependency(objId);
       args = [objId, w, h];
 
-      _image.PDFImage.buildImage({
+      const imgPromise = _image.PDFImage.buildImage({
         handler: this.handler,
         xref: this.xref,
         res: resources,
         image,
         isInline,
         nativeDecoder: nativeImageDecoder,
         pdfFunctionFactory: this.pdfFunctionFactory
       }).then(imageObj => {
         var imgData = imageObj.createImageData(false);
+
+        if (this.parsingType3Font) {
+          return this.handler.sendWithPromise('commonobj', [objId, 'FontType3Res', imgData], [imgData.data.buffer]);
+        }
+
         this.handler.send('obj', [objId, this.pageIndex, 'Image', imgData], [imgData.data.buffer]);
       }).catch(reason => {
         (0, _util.warn)('Unable to decode image: ' + reason);
+
+        if (this.parsingType3Font) {
+          return this.handler.sendWithPromise('commonobj', [objId, 'FontType3Res', null]);
+        }
+
         this.handler.send('obj', [objId, this.pageIndex, 'Image', null]);
       });
 
+      if (this.parsingType3Font) {
+        await imgPromise;
+      }
+
       operatorList.addOp(_util.OPS.paintImageXObject, args);
 
       if (cacheKey) {
         imageCache[cacheKey] = {
           fn: _util.OPS.paintImageXObject,
           args
         };
       }
-
-      return Promise.resolve();
     },
 
     handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
       var smaskContent = smask.get('G');
       var smaskOptions = {
         subtype: smask.get('S').name,
         backdrop: smask.get('BC')
       };
@@ -20338,21 +20511,21 @@ var PartialEvaluator = function PartialE
 
       if (fontRefIsRef) {
         this.fontCache.put(fontRef, fontCapability.promise);
       } else {
         if (!fontID) {
           fontID = this.idFactory.createObjId();
         }
 
-        this.fontCache.put('id_' + fontID, fontCapability.promise);
+        this.fontCache.put(`id_${fontID}`, fontCapability.promise);
       }
 
       (0, _util.assert)(fontID, 'The "fontID" must be defined.');
-      font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
+      font.loadedName = `${this.idFactory.getDocId()}_f${fontID}`;
       font.translated = fontCapability.promise;
       var translatedPromise;
 
       try {
         translatedPromise = this.translateFont(preEvaluatedFont);
       } catch (e) {
         translatedPromise = Promise.reject(e);
       }
@@ -22149,17 +22322,19 @@ var TranslatedFont = function Translated
       }
 
       if (this.type3Loaded) {
         return this.type3Loaded;
       }
 
       var type3Options = Object.create(evaluator.options);
       type3Options.ignoreErrors = false;
+      type3Options.nativeImageDecoderSupport = _util.NativeImageDecoding.NONE;
       var type3Evaluator = evaluator.clone(type3Options);
+      type3Evaluator.parsingType3Font = true;
       var translatedFont = this.font;
       var loadCharProcsPromise = Promise.resolve();
       var charProcs = this.dict.get('CharProcs');
       var fontResources = this.dict.get('Resources') || resources;
       var charProcKeys = charProcs.getKeys();
       var charProcOperatorList = Object.create(null);
 
       for (var i = 0, n = charProcKeys.length; i < n; ++i) {
--- 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.2.145
+  release: version 2.2.154
 
   # 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