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 828435 ee2e4e295225beb11a843e49475e2191c0d7e676
parent 828434 8baff73eb5a2b56a5eed7ad29b7d27ea7bbfa3b1
child 828436 908934a90c5341bdfd16ad97f07477ab41f5dcd8
push id118680
push usermaglione.k@gmail.com
push dateFri, 10 Aug 2018 23:04:22 +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]);