If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

Make --test-path=path/to/test_foo.html --close-when-done work



10 years ago
8 years ago


(Reporter: Waldo, Assigned: Waldo)



Firefox Tracking Flags

(Not tracked)



(1 attachment)

You can use --test-path to open a single test, but you can't use --close-when-done to close the browser when it completes.  If you only want to run a single test, this means you have to provide the containing folder and then click the individual test you want, which is a tad slower.
Mass move of the rest of the Mochitest bugs from Core:Testing to Testing:Mochitest. Filter on MochitestMassMove to ignore.
Component: Testing → Mochitest
Product: Core → Testing
QA Contact: testing → mochitest
Created attachment 359852 [details] [diff] [review]
"working" patch

This is not precisely a great patch, but it did work for me when I wanted to do this. I have no clue whether it breaks regular mochitests, though.
Comment on attachment 359852 [details] [diff] [review]
"working" patch

>diff --git a/testing/mochitest/tests/SimpleTest/SimpleTest.js b/testing/mochitest/tests/SimpleTest/SimpleTest.js

> if (typeof(SimpleTest) == "undefined") {
>     var SimpleTest = {};
> }

Doesn't quite seem necessary...

>+  From mozilla/toolkit/content
>+  These files did not have a license
>+function quitHook()
>+  var xhr = new XMLHttpRequest();
>+  xhr.open("GET", "http://" + location.host + "/server/shutdown", true);
>+  xhr.onreadystatechange = function (event)
>+    {
>+      if (xhr.readyState == 4)
>+        goQuitApplication();
>+    };
>+  xhr.send(null);
>+function canQuitApplication()
>+  var os = Components.classes["@mozilla.org/observer-service;1"]
>+    .getService(Components.interfaces.nsIObserverService);
>+  if (!os) 
>+  {
>+    return true;
>+  }
>+  try 
>+  {
>+    var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"]
>+      .createInstance(Components.interfaces.nsISupportsPRBool);
>+    os.notifyObservers(cancelQuit, "quit-application-requested", null);
>+    // Something aborted the quit process. 
>+    if (cancelQuit.data)
>+    {
>+      return false;
>+    }
>+  }
>+  catch (ex) 
>+  {
>+  }
>+  return true;
>+function goQuitApplication()
>+  const privs = 'UniversalXPConnect';

Don't use const in this file; it'll break running individual tests in non-Mozilla browsers.  Along those lines make sure to return silently here if we're not a Mozilla browser; I think there may be logic for this in TestRunner.js, either that or it's in a patch I've reviewed or it exists somewhere else in the test harness.  Sure, it's dumb to even run a test in another browser with the query string like this, but I can imagine someone writing a buggy test that "hangs" and copying the URL to another browser to test whether it completes there.

>+// Check the query string for arguments
>+var params = parseQueryString(location.search.substring(1), true);
> // Check to see if the TestRunner is present and has logging
> if (parentRunner) {
>     SimpleTest._logEnabled = parentRunner.logEnabled;
> }
> SimpleTest._tests = [];
> SimpleTest._stopOnLoad = true;

Seems better to save closeWhenDone as a "static" in the same manner as SimpleTest._stopOnLoad.

> /**
>  * Finishes the tests. This is automatically called, except when
>  * SimpleTest.waitForExplicitFinish() has been invoked.
> **/
> SimpleTest.finish = function () {
>     SimpleTest.showReport();
>     SimpleTest.talkToRunner();
>+    if (!parentRunner && params.closeWhenDone)
>+      goQuitApplication();
> };

Seems better just to condition closeWhenDone setting to be !parent so you don't need to check for !parentRunner here.

This pretty much looks like the half-patch I had written to do this awhile back, but I have no idea where that patch is at the moment.
Could just dupe this over to bug 508664, jmaher is doing the work to make this stuff happen. I asked him to make --test-path=path/to/test_foo.html load the single test in the harness page with the iframe, so everything should work (instead of fixing each feature of the harness individually).
Last Resolved: 8 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 508664
You need to log in before you can comment on or make changes to this bug.