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 825179 03582577ed597205089f718c0e4d0dde1cfe8ec6
parent 825178 fd2383bab5a317bfa808c600a3bf674052920266
child 825180 ac8d370ac81013d471ceadf9204327b0cd5d4649
push id118036
push usermaglione.k@gmail.com
push dateWed, 01 Aug 2018 02:23:07 +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/",
@@ -415,17 +418,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);
       }
     }
@@ -502,16 +509,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.
@@ -539,16 +557,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]);