Bug 1472491: Part 4b - Add lazy actor support to browser_all_files_referenced. r?florian draft
authorKris Maglione <maglione.k@gmail.com>
Tue, 31 Jul 2018 14:56:02 -0700
changeset 826643 57e23282178bfc0a50f604f1a0fda51010c8223c
parent 826642 305ea4ef709853f60489d1219ee61731400832b4
child 826644 04c16c8f3db9a7277103a3f2e761ac45c88a840c
push id118381
push usermaglione.k@gmail.com
push dateSat, 04 Aug 2018 22:44:24 +0000
reviewersflorian
bugs1472491
milestone63.0a1
Bug 1472491: Part 4b - Add lazy actor support to browser_all_files_referenced. r?florian ActorManagerParent.jsm handles loading JS IPC actors from JSMs using a base URL and some existing information. The browser_all_files_referenced test doesn't understand these fragmentary URLs, so this patch updates it to get the information directly from the actor registry. MozReview-Commit-ID: 6nRn3ZoXUsR
browser/base/content/test/static/browser_all_files_referenced.js
--- a/browser/base/content/test/static/browser_all_files_referenced.js
+++ b/browser/base/content/test/static/browser_all_files_referenced.js
@@ -3,16 +3,19 @@
 
 // Note to run this test similar to try server, you need to run:
 // ./mach package
 // ./mach mochitest --appname dist <path to test>
 
 // Slow on asan builds.
 requestLongerTimeout(5);
 
+ChromeUtils.defineModuleGetter(this, "ActorManagerParent",
+                               "resource://gre/modules/ActorManagerParent.jsm");
+
 var isDevtools = SimpleTest.harnessParameters.subsuite == "devtools";
 
 var gExceptionPaths = [
   "chrome://browser/content/defaultthemes/",
   "resource://app/defaults/settings/blocklists/",
   "resource://app/defaults/settings/main/",
   "resource://app/defaults/settings/pinning/",
   "resource://app/defaults/preferences/",
@@ -410,17 +413,21 @@ function parseCodeFile(fileUri) {
 
         let pos = url.indexOf("?");
         if (pos != -1) {
           url = url.slice(0, pos);
         }
 
         // Make urls like chrome://browser/skin/ point to an actual file,
         // and remove the ref if any.
-        url = Services.io.newURI(url).specIgnoringRef;
+        try {
+          url = Services.io.newURI(url).specIgnoringRef;
+        } catch (e) {
+          continue;
+        }
 
         if (isDevtools && line.includes("require(") &&
             !/\.(properties|js|jsm|json|css)$/.test(url))
           url += ".js";
 
         addCodeReference(url, fileUri);
       }
     }
@@ -497,16 +504,27 @@ function findChromeUrlsFromArray(array, 
 
     // Only keep strings that look like real chrome or resource urls.
     if (/chrome:\/\/[a-zA-Z09-]+\/(content|skin|locale)\//.test(string) ||
         /resource:\/\/[a-zA-Z09-]*\/.*\.[a-z]+/.test(string))
       gReferencesFromCode.set(string, null);
   }
 }
 
+function addActorModules() {
+  let groups = [...ActorManagerParent.parentGroups.values(),
+                ...ActorManagerParent.childGroups.values(),
+                ...ActorManagerParent.singletons.values()];
+  for (let group of groups) {
+    for (let {module} of group.actors.values()) {
+      gReferencesFromCode.set(module, null);
+    }
+  }
+}
+
 add_task(async function checkAllTheFiles() {
   let libxulPath = OS.Constants.Path.libxul;
   if (AppConstants.platform != "macosx")
     libxulPath = OS.Constants.Path.libDir + "/" + libxulPath;
   let libxul = await OS.File.read(libxulPath);
   findChromeUrlsFromArray(libxul, "chrome://");
   findChromeUrlsFromArray(libxul, "resource://");
   // Handle NS_LITERAL_STRING.
@@ -534,16 +552,18 @@ add_task(async function checkAllTheFiles
     }
 
     return true;
   });
 
   // Wait for all manifest to be parsed
   await throttledMapPromises(manifestURIs, parseManifest);
 
+  addActorModules();
+
   // We build a list of promises that get resolved when their respective
   // files have loaded and produced no errors.
   let allPromises = [];
 
   for (let uri of uris) {
     let path = uri.pathQueryRef;
     if (path.endsWith(".css"))
       allPromises.push([parseCSSFile, uri]);