Bug 1592781 use existing promise test instead of separate subtest for step_timeout() r=jgraham
authorKarl Tomlinson <karlt+@karlt.net>
Thu, 07 Nov 2019 00:47:33 +0000
changeset 502535 2d26bfe54d3fabcd4aabe257cbf9bb5c1cf9fd27
parent 502534 98ce0aadba7a30c5ca695468bf8561d1c911b038
child 502536 4f9bb3fd99208bbf178a0e2623faaf05eee18a02
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgraham
bugs1592781
milestone72.0a1
Bug 1592781 use existing promise test instead of separate subtest for step_timeout() r=jgraham Depends on D51564 Differential Revision: https://phabricator.services.mozilla.com/D51565
testing/web-platform/tests/webaudio/resources/audit.js
--- a/testing/web-platform/tests/webaudio/resources/audit.js
+++ b/testing/web-platform/tests/webaudio/resources/audit.js
@@ -1174,18 +1174,19 @@ window.Audit = (function() {
       if (arguments.length === 0)
         _throwException('Task.should:: requires at least 1 argument.');
 
       return new Should(this, actual, actualDescription);
     }
 
     // Run this task. |this| task will be passed into the user-supplied test
     // task function.
-    run() {
+    run(harnessTest) {
       this._state = TaskState.STARTED;
+      this._harnessTest = harnessTest;
       // Print out the task entry with label and description.
       _logPassed(
           '> [' + this._label + '] ' +
           (this._description ? this._description : ''));
 
       return new Promise((resolve, reject) => {
         this._resolve = resolve;
         let result = this._taskFunction(this, this.should.bind(this));
@@ -1224,22 +1225,17 @@ window.Audit = (function() {
 
       this._resolve();
     }
 
     // Runs |subTask| |time| milliseconds later. |setTimeout| is not allowed in
     // WPT linter, so a thin wrapper around the harness's |step_timeout| is
     // used here.
     timeout(subTask, time) {
-      async_test((test) => {
-        test.step_timeout(() => {
-          subTask();
-          test.done();
-        }, time);
-      });
+      this._harnessTest.step_timeout(subTask, time);
     }
 
     isPassed() {
       return this._state === TaskState.FINISHED && this._result;
     }
 
     toString() {
       return '"' + this._label + '": ' + this._description;
@@ -1319,17 +1315,17 @@ window.Audit = (function() {
         _throwException('Audit.run:: no task to run.');
         return;
       }
 
       for (let taskIndex in this._taskSequence) {
         let task = this._tasks[this._taskSequence[taskIndex]];
         // Some tests assume that tasks run in sequence, which is provided by
         // promise_test().
-        promise_test(() => task.run(), `Executing "${task.label}"`);
+        promise_test((t) => task.run(t), `Executing "${task.label}"`);
       }
 
       // Schedule a summary report on completion.
       promise_test(() => this._finish(), "Audit report");
 
       // From testharness.js. The harness now need not wait for more subtests
       // to be added.
       _testharnessDone();