Bug 1672237 - Add a subtestFailed function, similar to SimpleTest.finishWithFailure. r=botond
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 22 Oct 2020 00:47:24 +0000
changeset 553963 85b2a686add3d00797ec5d4a7c21876012c85101
parent 553962 5b41917730e22209c7634c344a517e13682c6e24
child 553964 dc1d17e222a7cee6a96a50df8ed5ad2d1330cfa0
push id37885
push userapavel@mozilla.com
push dateThu, 22 Oct 2020 14:54:09 +0000
treeherdermozilla-central@5684c9b12b5e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1672237
milestone84.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1672237 - Add a subtestFailed function, similar to SimpleTest.finishWithFailure. r=botond Differential Revision: https://phabricator.services.mozilla.com/D94164
gfx/layers/apz/test/mochitest/apz_test_utils.js
--- a/gfx/layers/apz/test/mochitest/apz_test_utils.js
+++ b/gfx/layers/apz/test/mochitest/apz_test_utils.js
@@ -312,35 +312,41 @@ async function promiseApzFlushedRepaints
 //           passed exactly one argument, which will be the child window.
 // An example of an array is:
 //   aSubtests = [
 //     { 'file': 'test_file_name.html' },
 //     { 'file': 'test_file_2.html', 'prefs': [['pref.name', true], ['other.pref', 1000]], 'dp_suppression': false }
 //     { 'file': 'file_3.html', 'onload': function(w) { w.subtestDone(); } }
 //   ];
 //
-// Each subtest should call the subtestDone() function when it is done, to
-// indicate that the window should be torn down and the next text should run.
-// The subtestDone() function is injected into the subtest's window by this
+// Each subtest should call one of the subtestDone() or subtestFailed()
+// functions when it is done, to indicate that the window should be torn
+// down and the next test should run.
+// These functions are injected into the subtest's window by this
 // function prior to loading the subtest. For convenience, the |is| and |ok|
 // functions provided by SimpleTest are also mapped into the subtest's window.
 // For other things from the parent, the subtest can use window.opener.<whatever>
 // to access objects.
 function runSubtestsSeriallyInFreshWindows(aSubtests) {
   return new Promise(function(resolve, reject) {
     var testIndex = -1;
     var w = null;
 
     // If the "apz.subtest" pref has been set, only a single subtest whose name matches
     // the pref's value (if any) will be run.
     var onlyOneSubtest = SpecialPowers.getCharPref(
       "apz.subtest",
       /* default = */ ""
     );
 
+    function advanceSubtestExecutionWithFailure(msg) {
+      SimpleTest.ok(false, msg);
+      advanceSubtestExecution();
+    }
+
     function advanceSubtestExecution() {
       var test = aSubtests[testIndex];
       if (w) {
         // Run any cleanup functions registered in the subtest
         // Guard against the subtest not loading apz_test_utils.js
         if (w.ApzCleanup) {
           w.ApzCleanup.execute();
         }
@@ -412,16 +418,17 @@ function runSubtestsSeriallyInFreshWindo
         SpecialPowers.getDOMWindowUtils(window).respectDisplayPortSuppression(
           test.dp_suppression
         );
       }
 
       function spawnTest(aFile) {
         w = window.open("", "_blank");
         w.subtestDone = advanceSubtestExecution;
+        w.subtestFailed = advanceSubtestExecutionWithFailure;
         w.isApzSubtest = true;
         w.SimpleTest = SimpleTest;
         w.dump = function(msg) {
           return dump(aFile + " | " + msg);
         };
         w.is = function(a, b, msg) {
           return is(a, b, aFile + " | " + msg);
         };