Bug 988169 - display the list of mochitests again; r=jmaher
authorNathan Froyd <froydnj@mozilla.com>
Thu, 22 May 2014 10:32:32 -0400
changeset 186596 f68a689a35931d5d98b11e33255fc9c1a1e676a7
parent 186595 4cc3b00d4ece49b0f34e19cd6f317631e27e6dab
child 186597 0f4eb14fcbd82aa5535d6f5371376b0655b05bb8
push idunknown
push userunknown
push dateunknown
reviewersjmaher
bugs988169
milestone32.0a1
Bug 988169 - display the list of mochitests again; r=jmaher
testing/mochitest/server.js
--- a/testing/mochitest/server.js
+++ b/testing/mochitest/server.js
@@ -568,28 +568,57 @@ function regularListing(metadata, respon
         A({href: ".."}, "Up a level"),
         UL(linksToListItems(links))
       )
     )
   );
 }
 
 /**
+ * Read a manifestFile located at the root of the server's directory and turn
+ * it into an object for creating a table of clickable links for each test.
+ */
+function convertManifestToTestLinks(root, manifest)
+{
+  Cu.import("resource://gre/modules/NetUtil.jsm");
+
+  var manifestFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
+  manifestFile.initWithFile(serverBasePath);
+  manifestFile.append(manifest);
+
+  var manifestStream = Cc["@mozilla.org/network/file-input-stream;1"].createInstance(Ci.nsIFileInputStream);
+  manifestStream.init(manifestFile, -1, 0, 0);
+
+  var manifestObj = JSON.parse(NetUtil.readInputStreamToString(manifestStream,
+                                                               manifestStream.available()));
+  var paths = manifestObj.tests;
+  var pathPrefix = '/' + root + '/'
+  return [paths.reduce(function(t, p) { t[pathPrefix + p.path] = true; return t; }, {}),
+          paths.length];
+}
+
+/**
  * Produce a test harness page containing all the test cases
  * below it, recursively.
  */
 function testListing(metadata, response)
 {
   var links = {};
   var count = 0;
   if (metadata.queryString.indexOf('manifestFile') == -1) {
     [links, count] = list(metadata.path,
                           metadata.getProperty("directory"),
                           true);
+  } else if (typeof(Components) != undefined) {
+    var manifest = metadata.queryString.match(/manifestFile=([^&]+)/)[1];
+
+    [links, count] = convertManifestToTestLinks(metadata.path.split('/')[1],
+                                                manifest);
   }
+
   var table_class = metadata.queryString.indexOf("hideResultsTable=1") > -1 ? "invisible": "";
 
   let testname = (metadata.queryString.indexOf("testname=") > -1)
                  ? metadata.queryString.match(/testname=([^&]+)/)[1]
                  : "";
 
   dumpn("count: " + count);
   var tests = testname