Backed out changeset a8809f15b582 (bug 1378727) for failing browser_ext_browserAction_context.js. r=backout on a CLOSED TREE
authorSebastian Hengst <archaeopteryx@coole-files.de>
Thu, 13 Jul 2017 00:37:45 +0200
changeset 607880 9c0a02ed5bad838685ee03e245df89b608013fbb
parent 607879 88e332b0ef13624c71010057c06eeb8370f5713f
child 607881 48ea9216e1beefd8c4e9dc68c2fe4ff560bf7403
child 607897 83c89460055eff4f0f441f467b7e118000461096
push id68136
push usermaglione.k@gmail.com
push dateWed, 12 Jul 2017 23:58:34 +0000
reviewersbackout
bugs1378727
milestone56.0a1
backs outa8809f15b58213f3292b9eaf7fa9583377d1fa30
Backed out changeset a8809f15b582 (bug 1378727) for failing browser_ext_browserAction_context.js. r=backout on a CLOSED TREE
toolkit/components/extensions/Extension.jsm
--- a/toolkit/components/extensions/Extension.jsm
+++ b/toolkit/components/extensions/Extension.jsm
@@ -88,20 +88,16 @@ XPCOMUtils.defineLazyGetter(
           .getService().wrappedJSObject);
 
 Cu.import("resource://gre/modules/ExtensionParent.jsm");
 Cu.import("resource://gre/modules/ExtensionUtils.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(this, "uuidGen",
                                    "@mozilla.org/uuid-generator;1",
                                    "nsIUUIDGenerator");
-XPCOMUtils.defineLazyServiceGetter(this, "zipCache",
-                                   "@mozilla.org/libjar/zip-reader-cache;1",
-                                   "nsIZipReaderCache");
-
 
 XPCOMUtils.defineLazyPreferenceGetter(this, "useRemoteWebExtensions",
                                       "extensions.webextensions.remote", false);
 
 var {
   GlobalManager,
   ParentAPIManager,
   StartupCache,
@@ -389,49 +385,56 @@ this.ExtensionData = class {
         // not a directory) for symmetry with the ZipReader behavior.
         Cu.reportError(e);
       }
       iter.close();
 
       return results;
     }
 
+    // FIXME: We need a way to do this without main thread IO.
+
     let uri = this.rootURI.QueryInterface(Ci.nsIJARURI);
+
     let file = uri.JARFile.QueryInterface(Ci.nsIFileURL).file;
-    let zipReader = zipCache.getZip(file);
+    let zipReader = Cc["@mozilla.org/libjar/zip-reader;1"].createInstance(Ci.nsIZipReader);
+    zipReader.open(file);
+    try {
+      let results = [];
 
-    let results = [];
+      // Normalize the directory path.
+      path = `${uri.JAREntry}/${path}`;
+      path = path.replace(/\/\/+/g, "/").replace(/^\/|\/$/g, "") + "/";
+
+      // Escape pattern metacharacters.
+      let pattern = path.replace(/[[\]()?*~|$\\]/g, "\\$&");
 
-    // Normalize the directory path.
-    path = `${uri.JAREntry}/${path}`;
-    path = path.replace(/\/\/+/g, "/").replace(/^\/|\/$/g, "") + "/";
+      let enumerator = zipReader.findEntries(pattern + "*");
+      while (enumerator.hasMore()) {
+        let name = enumerator.getNext();
+        if (!name.startsWith(path)) {
+          throw new Error("Unexpected ZipReader entry");
+        }
 
-    // Escape pattern metacharacters.
-    let pattern = path.replace(/[[\]()?*~|$\\]/g, "\\$&");
-
-    let enumerator = zipReader.findEntries(pattern + "*");
-    while (enumerator.hasMore()) {
-      let name = enumerator.getNext();
-      if (!name.startsWith(path)) {
-        throw new Error("Unexpected ZipReader entry");
+        // The enumerator returns the full path of all entries.
+        // Trim off the leading path, and filter out entries from
+        // subdirectories.
+        name = name.slice(path.length);
+        if (name && !/\/./.test(name)) {
+          results.push({
+            name: name.replace("/", ""),
+            isDir: name.endsWith("/"),
+          });
+        }
       }
 
-      // The enumerator returns the full path of all entries.
-      // Trim off the leading path, and filter out entries from
-      // subdirectories.
-      name = name.slice(path.length);
-      if (name && !/\/./.test(name)) {
-        results.push({
-          name: name.replace("/", ""),
-          isDir: name.endsWith("/"),
-        });
-      }
+      return results;
+    } finally {
+      zipReader.close();
     }
-
-    return results;
   }
 
   readJSON(path) {
     return new Promise((resolve, reject) => {
       let uri = this.rootURI.resolve(`./${path}`);
 
       NetUtil.asyncFetch({uri, loadUsingSystemPrincipal: true}, (inputStream, status) => {
         if (!Components.isSuccessCode(status)) {