Bug 1541630 [wpt PR 16142] - Use step_timeout() to force spin the EventLoop, a=testonly
authorDanyao Wang <danyao@chromium.org>
Thu, 18 Apr 2019 11:58:33 +0000
changeset 529969 499cb375a3c1e7c911408f5e285dab2da7a07810
parent 529968 97926249f68d2fd62c739dc731ff7ff4f529b603
child 529970 dbd76256cac2fa1bcef083b6f9124de6e1a63f75
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1541630, 16142
milestone68.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 1541630 [wpt PR 16142] - Use step_timeout() to force spin the EventLoop, a=testonly Automatic update from web-platform-tests Use step_timeout() to force spin the EventLoop (#16142) Use step_timeout() to force spin the EventLoop. Also allow eventPromise to reject before acceptPromise resolves. -- wpt-commits: 3bfdeb8976fc51748935c8d1f1014dfba8e08dfb wpt-pr: 16142
testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updateWith-call-immediate-manual.https.html
--- a/testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updateWith-call-immediate-manual.https.html
+++ b/testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updateWith-call-immediate-manual.https.html
@@ -50,36 +50,39 @@ function testImmediateUpdate({ textConte
     const request = new PaymentRequest(
       validMethods,
       validDetails,
       validOptions
     );
     const eventPromise = new Promise((resolve, reject) => {
       request.addEventListener(
         "shippingaddresschange",
-        async ev => {
-          // spin the event loop, sets [[waitForUpdate]] to true.
-          await Promise.resolve();
-          try {
-            ev.updateWith(validDetails);
-            resolve(); // This is bad.
-          } catch (err) {
-            reject(err); // this is good.
-          }
+        ev => {
+          // Forces updateWith() to be run in the next event loop tick so that
+          // [[waitForUpdate]] is already true when it runs.
+          t.step_timeout(() => {
+            try {
+              ev.updateWith(validDetails);
+              resolve(); // This is bad.
+            } catch (err) {
+              reject(err); // this is good.
+            }
+          });
         },
         { once: true }
       );
     });
-    const response = await request.show();
+    const acceptPromise = request.show();
     await promise_rejects(
       t,
       "InvalidStateError",
       eventPromise,
       "The event loop already spun, so [[waitForUpdate]] is now true"
     );
+    const response = await acceptPromise;
     await response.complete();
   }, testName.trim());
 }
 
 function testSubsequentUpdateWithCalls({ textContent: testName }) {
   promise_test(async t => {
     const request = new PaymentRequest(
       validMethods,