[Pkg-javascript-commits] [pdf.js] 57/106: [Firefox] Fix newChannel/asyncFetch fallout from bug 1167053

David Prévot taffit at moszumanska.debian.org
Sat Jun 20 21:34:16 UTC 2015


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

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

commit 5743b4f558eb91abcacbb6bf5ad77e067c2e8fbc
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Wed May 27 12:55:45 2015 +0200

    [Firefox] Fix newChannel/asyncFetch fallout from bug 1167053
    
    For some reason, https://bugzilla.mozilla.org/show_bug.cgi?id=1167053 changed methods of `NetUtil` yet *again*. This patch thus attempts to handle those changes, while keeping the addon backwards compatible.
    
    I've tested this using all current Firefox versions (Nightly, Aurora/DevEdition, Beta, Release, ESR), and things still appears to work correctly.
---
 extensions/firefox/content/PdfStreamConverter.jsm | 35 +++++++++++++++--------
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/extensions/firefox/content/PdfStreamConverter.jsm b/extensions/firefox/content/PdfStreamConverter.jsm
index 0acce8e..61e0c16 100644
--- a/extensions/firefox/content/PdfStreamConverter.jsm
+++ b/extensions/firefox/content/PdfStreamConverter.jsm
@@ -183,27 +183,38 @@ function makeContentReadable(obj, window) {
 
 function createNewChannel(uri, node, principal) {
 //#if !MOZCENTRAL
-  if (!NetUtil.newChannel2) {
+  if (NetUtil.newChannel2) {
+    return NetUtil.newChannel2(uri,
+                               null,
+                               null,
+                               node, // aLoadingNode
+                               principal, // aLoadingPrincipal
+                               null, // aTriggeringPrincipal
+                               Ci.nsILoadInfo.SEC_NORMAL,
+                               Ci.nsIContentPolicy.TYPE_OTHER);
+  }
+  // The signature of `NetUtil.newChannel` changed in Firefox 38,
+  // see https://bugzilla.mozilla.org/show_bug.cgi?id=1125618.
+  var ffVersion = parseInt(Services.appinfo.platformVersion);
+  if (ffVersion < 38) {
     return NetUtil.newChannel(uri);
   }
 //#endif
-  return NetUtil.newChannel2(uri,
-                             null,
-                             null,
-                             node, // aLoadingNode
-                             principal, // aLoadingPrincipal
-                             null, // aTriggeringPrincipal
-                             Ci.nsILoadInfo.SEC_NORMAL,
-                             Ci.nsIContentPolicy.TYPE_OTHER);
+  return NetUtil.newChannel({
+    uri: uri,
+    loadingNode: node,
+    loadingPrincipal: principal,
+    contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER,
+  });
 }
 
 function asyncFetchChannel(channel, callback) {
 //#if !MOZCENTRAL
-  if (!NetUtil.newChannel2) {
-    return NetUtil.asyncFetch(channel, callback);
+  if (NetUtil.asyncFetch2) {
+    return NetUtil.asyncFetch2(channel, callback);
   }
 //#endif
-  return NetUtil.asyncFetch2(channel, callback);
+  return NetUtil.asyncFetch(channel, callback);
 }
 
 // PDF data storage

-- 
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