[Pkg-javascript-commits] [pdf.js] 158/414: [api-minor] Change `getPageLabels` to always return the pageLabels, even if they are identical to standard page numbering

David Prévot taffit at moszumanska.debian.org
Tue Jun 28 17:12:17 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit 1140a34f5ccbeb7cbf1c97b6e3586788fb3e5ab5
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Tue Jan 26 23:01:38 2016 +0100

    [api-minor] Change `getPageLabels` to always return the pageLabels, even if they are identical to standard page numbering
---
 src/core/obj.js       |  9 +--------
 src/display/api.js    |  8 +++-----
 test/unit/api_spec.js | 17 +++++++++++++----
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/src/core/obj.js b/src/core/obj.js
index 923cf18..7cf22f5 100644
--- a/src/core/obj.js
+++ b/src/core/obj.js
@@ -343,14 +343,7 @@ var Catalog = (function CatalogClosure() {
         currentLabel = '';
         currentIndex++;
       }
-
-      // Ignore PageLabels if they correspond to standard page numbering.
-      for (i = 0, ii = this.numPages; i < ii; i++) {
-        if (pageLabels[i] !== (i + 1).toString()) {
-          break;
-        }
-      }
-      return (i === ii ? [] : pageLabels);
+      return pageLabels;
     },
 
     get attachments() {
diff --git a/src/display/api.js b/src/display/api.js
index d94a4bd..57b9a3e 100644
--- a/src/display/api.js
+++ b/src/display/api.js
@@ -691,11 +691,9 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
       return this.transport.getDestination(id);
     },
     /**
-     * @return {Promise} A promise that is resolved with: an Array containing
-     *   the pageLabels that correspond to the pageIndexes; or null, when no
-     *   pageLabels are present in the PDF file.
-     *   NOTE: If the pageLabels are all identical to standard page numbering,
-     *         i.e. [1, 2, 3, ...], the promise is resolved with an empty Array.
+     * @return {Promise} A promise that is resolved with:
+     *   an Array containing the pageLabels that correspond to the pageIndexes,
+     *   or `null` when no pageLabels are present in the PDF file.
      */
     getPageLabels: function PDFDocumentProxy_getPageLabels() {
       return this.transport.getPageLabels();
diff --git a/test/unit/api_spec.js b/test/unit/api_spec.js
index 466d035..be49a67 100644
--- a/test/unit/api_spec.js
+++ b/test/unit/api_spec.js
@@ -338,17 +338,22 @@ describe('api', function() {
     it('gets page labels', function () {
       // PageLabels with Roman/Arabic numerals.
       var url0 = combineUrl(window.location.href, '../pdfs/bug793632.pdf');
-      var promise0 = PDFJS.getDocument(url0).promise.then(function (pdfDoc) {
+      var loadingTask0 = PDFJS.getDocument(url0);
+      var promise0 = loadingTask0.promise.then(function (pdfDoc) {
         return pdfDoc.getPageLabels();
       });
+
       // PageLabels with only a label prefix.
       var url1 = combineUrl(window.location.href, '../pdfs/issue1453.pdf');
-      var promise1 = PDFJS.getDocument(url1).promise.then(function (pdfDoc) {
+      var loadingTask1 = PDFJS.getDocument(url1);
+      var promise1 = loadingTask1.promise.then(function (pdfDoc) {
         return pdfDoc.getPageLabels();
       });
+
       // PageLabels identical to standard page numbering.
       var url2 = combineUrl(window.location.href, '../pdfs/rotation.pdf');
-      var promise2 = PDFJS.getDocument(url2).promise.then(function (pdfDoc) {
+      var loadingTask2 = PDFJS.getDocument(url2);
+      var promise2 = loadingTask2.promise.then(function (pdfDoc) {
         return pdfDoc.getPageLabels();
       });
 
@@ -356,7 +361,11 @@ describe('api', function() {
           function (pageLabels) {
         expect(pageLabels[0]).toEqual(['i', 'ii', 'iii', '1']);
         expect(pageLabels[1]).toEqual(['Front Page1']);
-        expect(pageLabels[2]).toEqual([]);
+        expect(pageLabels[2]).toEqual(['1', '2']);
+
+        loadingTask0.destroy();
+        loadingTask1.destroy();
+        loadingTask2.destroy();
       });
     });
     it('gets attachments', function() {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list