Backed out changeset c1c3cb16a29b (bug 1406405) for frequently failing browser/extensions/pdfjs/test/browser_pdfjs_main.js. r=backout
authorSebastian Hengst <archaeopteryx@coole-files.de>
Fri, 06 Oct 2017 18:36:44 +0200
changeset 427381 073b52890be1f0af93245d2697de1dfa464ec96a
parent 427380 a9ddc3f6748c15d975b14f7433b2570157acfd79
child 427382 e0b45659c51919f57d14685c9d6c95cbae13582e
push id97
push userfmarier@mozilla.com
push dateSat, 14 Oct 2017 01:12:59 +0000
reviewersbackout
bugs1406405
milestone58.0a1
backs outc1c3cb16a29bc306999171e9cd7f76830a778875
Backed out changeset c1c3cb16a29b (bug 1406405) for frequently failing browser/extensions/pdfjs/test/browser_pdfjs_main.js. r=backout
browser/extensions/pdfjs/README.mozilla
browser/extensions/pdfjs/content/build/pdf.js
browser/extensions/pdfjs/content/build/pdf.worker.js
browser/extensions/pdfjs/content/web/viewer.js
--- 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: 1.9.628
+Current extension version is: 1.9.607
 
-Taken from upstream commit: 460c4e38
+Taken from upstream commit: b3f84112
--- a/browser/extensions/pdfjs/content/build/pdf.js
+++ b/browser/extensions/pdfjs/content/build/pdf.js
@@ -701,16 +701,19 @@ var Util = function UtilClosure() {
     if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
       result[1] = orderedY[1];
       result[3] = orderedY[2];
     } else {
       return false;
     }
     return result;
   };
+  Util.sign = function Util_sign(num) {
+    return num < 0 ? -1 : 1;
+  };
   var ROMAN_NUMBER_MAP = ['', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM', '', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC', '', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'];
   Util.toRoman = function Util_toRoman(number, lowerCase) {
     assert(Number.isInteger(number) && number > 0, 'The number should be a positive integer.');
     var pos,
         romanBuf = [];
     while (number >= 1000) {
       number -= 1000;
       romanBuf.push('M');
@@ -1357,41 +1360,18 @@ MessageHandler.prototype = {
   },
   postMessage(message, transfers) {
     if (transfers && this.postMessageTransfers) {
       this.comObj.postMessage(message, transfers);
     } else {
       this.comObj.postMessage(message);
     }
   },
-  close(reason) {
+  destroy() {
     this.comObj.removeEventListener('message', this._onComObjOnMessage);
-    for (let i in this.callbacksCapabilities) {
-      const callbackCapability = this.callbacksCapabilities[i];
-      callbackCapability.reject(reason);
-    }
-    for (let i in this.streamSinks) {
-      const sink = this.streamSinks[i];
-      sink.sinkCapability.reject(reason);
-    }
-    for (let i in this.streamControllers) {
-      const controller = this.streamControllers[i];
-      if (!controller.isClosed) {
-        controller.controller.error(reason);
-      }
-      if (controller.startCall) {
-        controller.startCall.reject(reason);
-      }
-      if (controller.pullCall) {
-        controller.pullCall.reject(reason);
-      }
-      if (controller.cancelCall) {
-        controller.cancelCall.reject(reason);
-      }
-    }
   }
 };
 function loadJpegStream(id, imageUrl, objs) {
   var img = new Image();
   img.onload = function loadJpegStream_onloadClosure() {
     objs.resolve(id, img);
   };
   img.onerror = function loadJpegStream_onerrorClosure() {
@@ -2008,17 +1988,17 @@ function getDocument(src, pdfDataRangeTr
     });
   }).catch(task._capability.reject);
   return task;
 }
 function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
   if (worker.destroyed) {
     return Promise.reject(new Error('Worker was destroyed'));
   }
-  let apiVersion = '1.9.628';
+  let apiVersion = '1.9.607';
   source.disableAutoFetch = (0, _dom_utils.getDefaultSetting)('disableAutoFetch');
   source.disableStream = (0, _dom_utils.getDefaultSetting)('disableStream');
   source.chunkedViewerLoading = !!pdfDataRangeTransport;
   if (pdfDataRangeTransport) {
     source.length = pdfDataRangeTransport.length;
     source.initialData = pdfDataRangeTransport.initialData;
   }
   return worker.messageHandler.sendWithPromise('GetDocRequest', {
@@ -2574,17 +2554,17 @@ var PDFWorker = function PDFWorkerClosur
     _initialize: function PDFWorker_initialize() {
       if (!isWorkerDisabled && !(0, _dom_utils.getDefaultSetting)('disableWorker') && typeof Worker !== 'undefined') {
         var workerSrc = getWorkerSrc();
         try {
           var worker = new Worker(workerSrc);
           var messageHandler = new _util.MessageHandler('main', 'worker', worker);
           var terminateEarly = () => {
             worker.removeEventListener('error', onWorkerError);
-            messageHandler.close(new Error('Worker was terminated'));
+            messageHandler.destroy();
             worker.terminate();
             if (this.destroyed) {
               this._readyCapability.reject(new Error('Worker was destroyed'));
             } else {
               this._setupFakeWorker();
             }
           };
           var onWorkerError = () => {
@@ -2607,17 +2587,17 @@ var PDFWorker = function PDFWorkerClosur
               if (!data.supportTransfers) {
                 this.postMessageTransfers = false;
                 isPostMessageTransfersDisabled = true;
               }
               this._readyCapability.resolve();
               messageHandler.send('configure', { verbosity: (0, _util.getVerbosityLevel)() });
             } else {
               this._setupFakeWorker();
-              messageHandler.close(new Error('Worker was terminated'));
+              messageHandler.destroy();
               worker.terminate();
             }
           });
           messageHandler.on('console_log', function (data) {
             console.log.apply(console, data);
           });
           messageHandler.on('console_error', function (data) {
             console.error.apply(console, data);
@@ -2678,17 +2658,17 @@ var PDFWorker = function PDFWorkerClosur
       this.destroyed = true;
       if (this._webWorker) {
         this._webWorker.terminate();
         this._webWorker = null;
       }
       pdfWorkerPorts.delete(this._port);
       this._port = null;
       if (this._messageHandler) {
-        this._messageHandler.close(new _util.AbortException('Worker was destroyed'));
+        this._messageHandler.destroy();
         this._messageHandler = null;
       }
     }
   };
   PDFWorker.fromPort = function (port) {
     if (pdfWorkerPorts.has(port)) {
       return pdfWorkerPorts.get(port);
     }
@@ -2738,17 +2718,17 @@ var WorkerTransport = function WorkerTra
       var terminated = this.messageHandler.sendWithPromise('Terminate', null);
       waitOn.push(terminated);
       Promise.all(waitOn).then(() => {
         this.fontLoader.clear();
         if (this._networkStream) {
           this._networkStream.cancelAllRequests();
         }
         if (this.messageHandler) {
-          this.messageHandler.close(new _util.AbortException('Worker was destroyed'));
+          this.messageHandler.destroy();
           this.messageHandler = null;
         }
         this.destroyCapability.resolve();
       }, this.destroyCapability.reject);
       return this.destroyCapability.promise;
     },
     setupMessageHandler: function WorkerTransport_setupMessageHandler() {
       var messageHandler = this.messageHandler;
@@ -3329,18 +3309,18 @@ var _UnsupportedManager = function Unsup
       for (var i = 0, ii = listeners.length; i < ii; i++) {
         listeners[i](featureId);
       }
     }
   };
 }();
 var version, build;
 {
-  exports.version = version = '1.9.628';
-  exports.build = build = '460c4e38';
+  exports.version = version = '1.9.607';
+  exports.build = build = 'b3f84112';
 }
 exports.getDocument = getDocument;
 exports.LoopbackPort = LoopbackPort;
 exports.PDFDataRangeTransport = PDFDataRangeTransport;
 exports.PDFWorker = PDFWorker;
 exports.PDFDocumentProxy = PDFDocumentProxy;
 exports.PDFPageProxy = PDFPageProxy;
 exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
@@ -5069,18 +5049,18 @@ exports.SVGGraphics = SVGGraphics;
 
 /***/ }),
 /* 9 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
-var pdfjsVersion = '1.9.628';
-var pdfjsBuild = '460c4e38';
+var pdfjsVersion = '1.9.607';
+var pdfjsBuild = 'b3f84112';
 var pdfjsSharedUtil = __w_pdfjs_require__(0);
 var pdfjsDisplayGlobal = __w_pdfjs_require__(13);
 var pdfjsDisplayAPI = __w_pdfjs_require__(3);
 var pdfjsDisplayTextLayer = __w_pdfjs_require__(7);
 var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(6);
 var pdfjsDisplayDOMUtils = __w_pdfjs_require__(1);
 var pdfjsDisplaySVG = __w_pdfjs_require__(8);
 ;
@@ -8168,17 +8148,17 @@ if (isReadableStreamSupported) {
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
-exports.PDFJS = exports.globalScope = undefined;
+exports.PDFJS = exports.isWorker = exports.globalScope = undefined;
 
 var _api = __w_pdfjs_require__(3);
 
 var _dom_utils = __w_pdfjs_require__(1);
 
 var _util = __w_pdfjs_require__(0);
 
 var _annotation_layer = __w_pdfjs_require__(6);
@@ -8190,23 +8170,24 @@ var _global_scope2 = _interopRequireDefa
 var _metadata = __w_pdfjs_require__(5);
 
 var _text_layer = __w_pdfjs_require__(7);
 
 var _svg = __w_pdfjs_require__(8);
 
 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 
+var isWorker = typeof window === 'undefined';
 if (!_global_scope2.default.PDFJS) {
   _global_scope2.default.PDFJS = {};
 }
 var PDFJS = _global_scope2.default.PDFJS;
 {
-  PDFJS.version = '1.9.628';
-  PDFJS.build = '460c4e38';
+  PDFJS.version = '1.9.607';
+  PDFJS.build = 'b3f84112';
 }
 PDFJS.pdfBug = false;
 if (PDFJS.verbosity !== undefined) {
   (0, _util.setVerbosityLevel)(PDFJS.verbosity);
 }
 delete PDFJS.verbosity;
 Object.defineProperty(PDFJS, 'verbosity', {
   get() {
@@ -8274,16 +8255,17 @@ PDFJS.addLinkAttributes = _dom_utils.add
 PDFJS.getFilenameFromUrl = _dom_utils.getFilenameFromUrl;
 PDFJS.isExternalLinkTargetSet = _dom_utils.isExternalLinkTargetSet;
 PDFJS.AnnotationLayer = _annotation_layer.AnnotationLayer;
 PDFJS.renderTextLayer = _text_layer.renderTextLayer;
 PDFJS.Metadata = _metadata.Metadata;
 PDFJS.SVGGraphics = _svg.SVGGraphics;
 PDFJS.UnsupportedManager = _api._UnsupportedManager;
 exports.globalScope = _global_scope2.default;
+exports.isWorker = isWorker;
 exports.PDFJS = PDFJS;
 
 /***/ }),
 /* 14 */
 /***/ (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
@@ -701,16 +701,19 @@ var Util = function UtilClosure() {
     if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
       result[1] = orderedY[1];
       result[3] = orderedY[2];
     } else {
       return false;
     }
     return result;
   };
+  Util.sign = function Util_sign(num) {
+    return num < 0 ? -1 : 1;
+  };
   var ROMAN_NUMBER_MAP = ['', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM', '', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC', '', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'];
   Util.toRoman = function Util_toRoman(number, lowerCase) {
     assert(Number.isInteger(number) && number > 0, 'The number should be a positive integer.');
     var pos,
         romanBuf = [];
     while (number >= 1000) {
       number -= 1000;
       romanBuf.push('M');
@@ -1357,41 +1360,18 @@ MessageHandler.prototype = {
   },
   postMessage(message, transfers) {
     if (transfers && this.postMessageTransfers) {
       this.comObj.postMessage(message, transfers);
     } else {
       this.comObj.postMessage(message);
     }
   },
-  close(reason) {
+  destroy() {
     this.comObj.removeEventListener('message', this._onComObjOnMessage);
-    for (let i in this.callbacksCapabilities) {
-      const callbackCapability = this.callbacksCapabilities[i];
-      callbackCapability.reject(reason);
-    }
-    for (let i in this.streamSinks) {
-      const sink = this.streamSinks[i];
-      sink.sinkCapability.reject(reason);
-    }
-    for (let i in this.streamControllers) {
-      const controller = this.streamControllers[i];
-      if (!controller.isClosed) {
-        controller.controller.error(reason);
-      }
-      if (controller.startCall) {
-        controller.startCall.reject(reason);
-      }
-      if (controller.pullCall) {
-        controller.pullCall.reject(reason);
-      }
-      if (controller.cancelCall) {
-        controller.cancelCall.reject(reason);
-      }
-    }
   }
 };
 function loadJpegStream(id, imageUrl, objs) {
   var img = new Image();
   img.onload = function loadJpegStream_onloadClosure() {
     objs.resolve(id, img);
   };
   img.onerror = function loadJpegStream_onerrorClosure() {
@@ -23841,18 +23821,18 @@ exports.PostScriptCompiler = PostScriptC
 
 /***/ }),
 /* 17 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
-var pdfjsVersion = '1.9.628';
-var pdfjsBuild = '460c4e38';
+var pdfjsVersion = '1.9.607';
+var pdfjsBuild = 'b3f84112';
 var pdfjsCoreWorker = __w_pdfjs_require__(18);
 exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
 
 /***/ }),
 /* 18 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
@@ -24037,17 +24017,17 @@ var WorkerMessageHandler = {
     });
   },
   createDocumentHandler(docParams, port) {
     var pdfManager;
     var terminated = false;
     var cancelXHRs = null;
     var WorkerTasks = [];
     let apiVersion = docParams.apiVersion;
-    let workerVersion = '1.9.628';
+    let workerVersion = '1.9.607';
     if (apiVersion !== null && 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';
     var handler = new _util.MessageHandler(workerHandlerName, docId, port);
     handler.postMessageTransfers = docParams.postMessageTransfers;
@@ -24400,17 +24380,17 @@ var WorkerMessageHandler = {
         cancelXHRs();
       }
       var waitOn = [];
       WorkerTasks.forEach(function (task) {
         waitOn.push(task.finished);
         task.terminate();
       });
       return Promise.all(waitOn).then(function () {
-        handler.close(new _util.AbortException('Worker was terminated'));
+        handler.destroy();
         handler = null;
       });
     });
     handler.on('Ready', function wphReady(data) {
       setupDoc(docParams);
       docParams = null;
     });
     return workerHandlerName;
--- a/browser/extensions/pdfjs/content/web/viewer.js
+++ b/browser/extensions/pdfjs/content/web/viewer.js
@@ -4436,17 +4436,17 @@ class PDFHistory {
     let state = window.history.state;
     this.initialized = true;
     this.initialBookmark = null;
     this.initialRotation = null;
     this._popStateInProgress = false;
     this._blockHashChange = 0;
     this._currentHash = getCurrentHash();
     this._numPositionUpdates = 0;
-    this._uid = this._maxUid = 0;
+    this._currentUid = this._uid = 0;
     this._destination = null;
     this._position = null;
     if (!this._isValidState(state) || resetHistory) {
       let { hash, page, rotation } = parseCurrentHash(this.linkService);
       if (!hash || reInitialized || resetHistory) {
         this._pushOrReplaceState(null, true);
         return;
       }
@@ -4521,35 +4521,34 @@ class PDFHistory {
       window.history.back();
     }
   }
   forward() {
     if (!this.initialized || this._popStateInProgress) {
       return;
     }
     let state = window.history.state;
-    if (this._isValidState(state) && state.uid < this._maxUid) {
+    if (this._isValidState(state) && state.uid < this._uid - 1) {
       window.history.forward();
     }
   }
   get popStateInProgress() {
     return this.initialized && (this._popStateInProgress || this._blockHashChange > 0);
   }
   _pushOrReplaceState(destination, forceReplace = false) {
     let shouldReplace = forceReplace || !this._destination;
     let newState = {
       fingerprint: this.fingerprint,
-      uid: shouldReplace ? this._uid : this._uid + 1,
+      uid: shouldReplace ? this._currentUid : this._uid,
       destination
     };
     this._updateInternalState(destination, newState.uid);
     if (shouldReplace) {
       window.history.replaceState(newState, '');
     } else {
-      this._maxUid = this._uid;
       window.history.pushState(newState, '');
     }
   }
   _tryPushCurrentPosition(temporary = false) {
     if (!this._position) {
       return;
     }
     let position = this._position;
@@ -4599,17 +4598,18 @@ class PDFHistory {
     if (this._updateViewareaTimeout) {
       clearTimeout(this._updateViewareaTimeout);
       this._updateViewareaTimeout = null;
     }
     if (removeTemporary && destination && destination.temporary) {
       delete destination.temporary;
     }
     this._destination = destination;
-    this._uid = uid;
+    this._currentUid = uid;
+    this._uid = this._currentUid + 1;
     this._numPositionUpdates = 0;
   }
   _updateViewarea({ location }) {
     if (this._updateViewareaTimeout) {
       clearTimeout(this._updateViewareaTimeout);
       this._updateViewareaTimeout = null;
     }
     this._position = {
@@ -4633,17 +4633,17 @@ class PDFHistory {
       }, UPDATE_VIEWAREA_TIMEOUT);
     }
   }
   _popState({ state }) {
     let newHash = getCurrentHash(),
         hashChanged = this._currentHash !== newHash;
     this._currentHash = newHash;
     if (!state || false) {
-      this._uid++;
+      this._currentUid = this._uid;
       let { hash, page, rotation } = parseCurrentHash(this.linkService);
       this._pushOrReplaceState({
         hash,
         page,
         rotation
       }, true);
       return;
     }