Bug 1258145 - Remove `waitForPromise` from the xpcshell tests. r=wchen, a=test-only
authorKit Cambridge <kcambridge@mozilla.com>
Sat, 19 Mar 2016 14:57:15 -0700
changeset 323761 477b227b6224431e51ac256e37e96498e4843cf4
parent 323760 84d924134d1384e94d3227f21915f28b2841a9d7
child 323762 7c164deed2231846aceaf869fa251d1ce8052d01
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswchen, test-only
bugs1258145
milestone47.0a2
Bug 1258145 - Remove `waitForPromise` from the xpcshell tests. r=wchen, a=test-only MozReview-Commit-ID: 6dX63gyXw07
dom/push/test/xpcshell/head.js
dom/push/test/xpcshell/test_clear_origin_data.js
dom/push/test/xpcshell/test_drop_expired.js
dom/push/test/xpcshell/test_notification_ack.js
dom/push/test/xpcshell/test_notification_data.js
dom/push/test/xpcshell/test_notification_duplicate.js
dom/push/test/xpcshell/test_notification_error.js
dom/push/test/xpcshell/test_notification_http2.js
dom/push/test/xpcshell/test_notification_incomplete.js
dom/push/test/xpcshell/test_notification_version_string.js
dom/push/test/xpcshell/test_permissions.js
dom/push/test/xpcshell/test_quota_exceeded.js
dom/push/test/xpcshell/test_quota_observer.js
dom/push/test/xpcshell/test_quota_with_notification.js
dom/push/test/xpcshell/test_reconnect_retry.js
dom/push/test/xpcshell/test_register_case.js
dom/push/test/xpcshell/test_register_flush.js
dom/push/test/xpcshell/test_register_invalid_json.js
dom/push/test/xpcshell/test_register_no_id.js
dom/push/test/xpcshell/test_register_request_queue.js
dom/push/test/xpcshell/test_register_rollback.js
dom/push/test/xpcshell/test_register_timeout.js
dom/push/test/xpcshell/test_register_wrong_id.js
dom/push/test/xpcshell/test_register_wrong_type.js
dom/push/test/xpcshell/test_registration_success.js
dom/push/test/xpcshell/test_retry_ws.js
dom/push/test/xpcshell/test_unregister_error.js
dom/push/test/xpcshell/test_unregister_invalid_json.js
dom/push/test/xpcshell/test_unregister_success.js
dom/push/test/xpcshell/test_updateRecordNoEncryptionKeys_http2.js
--- a/dom/push/test/xpcshell/head.js
+++ b/dom/push/test/xpcshell/head.js
@@ -17,18 +17,16 @@ Cu.import('resource://gre/modules/Object
 XPCOMUtils.defineLazyModuleGetter(this, 'PlacesTestUtils',
                                   'resource://testing-common/PlacesTestUtils.jsm');
 XPCOMUtils.defineLazyServiceGetter(this, 'PushServiceComponent',
                                    '@mozilla.org/push/Service;1', 'nsIPushService');
 
 const serviceExports = Cu.import('resource://gre/modules/PushService.jsm', {});
 const servicePrefs = new Preferences('dom.push.');
 
-const DEFAULT_TIMEOUT = 5000;
-
 const WEBSOCKET_CLOSE_GOING_AWAY = 1001;
 
 var isParent = Cc['@mozilla.org/xre/runtime;1']
                  .getService(Ci.nsIXULRuntime).processType ==
                  Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
 
 // Stop and clean up after the PushService.
 Services.obs.addObserver(function observe(subject, topic, data) {
@@ -94,41 +92,16 @@ function promiseObserverNotification(top
       }
       Services.obs.removeObserver(observe, topic, false);
       resolve({subject, data});
     }, topic, false);
   });
 }
 
 /**
- * Waits for a promise to settle. Returns a rejected promise if the promise
- * is not resolved or rejected within the given delay.
- *
- * @param {Promise} promise The pending promise.
- * @param {Number} delay The time to wait before rejecting the promise.
- * @param {String} [message] The rejection message if the promise times out.
- * @returns {Promise} A promise that settles with the value of the pending
- *  promise, or rejects if the pending promise times out.
- */
-function waitForPromise(promise, delay, message = 'Timed out waiting on promise') {
-  let timeoutDefer = Promise.defer();
-  let id = setTimeout(() => timeoutDefer.reject(new Error(message)), delay);
-  return Promise.race([
-    promise.then(value => {
-      clearTimeout(id);
-      return value;
-    }, error => {
-      clearTimeout(id);
-      throw error;
-    }),
-    timeoutDefer.promise
-  ]);
-}
-
-/**
  * Wraps an object in a proxy that traps property gets and returns stubs. If
  * the stub is a function, the original value will be passed as the first
  * argument. If the original value is a function, the proxy returns a wrapper
  * that calls the stub; otherwise, the stub is called as a getter.
  *
  * @param {Object} target The object to wrap.
  * @param {Object} stubs An object containing stubbed values and functions.
  * @returns {Proxy} A proxy that returns stubs for property gets.
--- a/dom/push/test/xpcshell/test_clear_origin_data.js
+++ b/dom/push/test/xpcshell/test_clear_origin_data.js
@@ -132,11 +132,10 @@ add_task(function* test_webapps_cleardat
   // Removes all records for all scopes with the same app ID, where
   // `inIsolatedMozBrowser` is true.
   yield clearForPattern(testRecords, { appId: 2, inIsolatedMozBrowser: true });
 
   // Removes all records where `inIsolatedMozBrowser` is true.
   yield clearForPattern(testRecords, { inIsolatedMozBrowser: true });
 
   equal(testRecords.length, 0, 'Should remove all test records');
-  yield waitForPromise(unregisterPromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for unregister');
+  yield unregisterPromise;
 });
--- a/dom/push/test/xpcshell/test_drop_expired.js
+++ b/dom/push/test/xpcshell/test_drop_expired.js
@@ -115,37 +115,34 @@ add_task(function* setUp() {
             status: 200,
             uaid: userAgentID,
           }));
         },
       });
     },
   });
 
-  yield waitForPromise(subChangePromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for subscription change event on startup');
+  yield subChangePromise;
 });
 
 add_task(function* test_site_visited() {
   let subChangePromise = promiseObserverNotification(
     PushServiceComponent.subscriptionChangeTopic,
     (subject, data) => data == 'https://example.xyz/expired-quota-exceeded'
   );
 
   yield visitURI(quotaURI, Date.now());
   PushService.observe(null, 'idle-daily', '');
 
-  yield waitForPromise(subChangePromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for subscription change event after visit');
+  yield subChangePromise;
 });
 
 add_task(function* test_perm_restored() {
   let subChangePromise = promiseObserverNotification(
     PushServiceComponent.subscriptionChangeTopic,
     (subject, data) => data == 'https://example.info/expired-perm-revoked'
   );
 
   Services.perms.add(permURI, 'desktop-notification',
     Ci.nsIPermissionManager.ALLOW_ACTION);
 
-  yield waitForPromise(subChangePromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for subscription change event after permission');
+  yield subChangePromise;
 });
--- a/dom/push/test/xpcshell/test_notification_ack.js
+++ b/dom/push/test/xpcshell/test_notification_ack.js
@@ -113,13 +113,11 @@ add_task(function* test_notification_ack
           default:
             ok(false, 'Unexpected acknowledgement ' + acks);
           }
         }
       });
     }
   });
 
-  yield waitForPromise(notifyPromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for notifications');
-  yield waitForPromise(ackPromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for multiple acknowledgements');
+  yield notifyPromise;
+  yield ackPromise;
 });
--- a/dom/push/test/xpcshell/test_notification_data.js
+++ b/dom/push/test/xpcshell/test_notification_data.js
@@ -109,18 +109,17 @@ add_task(function* test_notification_ack
         onACK(request) {
           if (ackDone) {
             ackDone(request.updates);
           }
         }
       });
     }
   });
-  yield waitForPromise(setupDonePromise, DEFAULT_TIMEOUT,
-                       'Timed out waiting for notifications');
+  yield setupDonePromise;
 });
 
 add_task(function* test_notification_ack_data() {
   let allTestData = [
     {
       channelID: 'subscription1',
       version: 'v1',
       send: {
@@ -244,15 +243,12 @@ add_task(function* test_notification_ack
     msg.messageType = 'notification';
     msg.channelID = testData.channelID;
     msg.version = testData.version;
     server.serverSendMsg(JSON.stringify(msg));
 
     return Promise.all([messageReceived, ackReceived]);
   };
 
-  yield waitForPromise(
-    allTestData.reduce((p, testData) => {
-      return p.then(_ => sendAndReceive(testData));
-    }, Promise.resolve()),
-    DEFAULT_TIMEOUT,
-    'Timed out waiting for message exchange to complete');
+  yield allTestData.reduce((p, testData) => {
+    return p.then(_ => sendAndReceive(testData));
+  }, Promise.resolve());
 });
--- a/dom/push/test/xpcshell/test_notification_duplicate.js
+++ b/dom/push/test/xpcshell/test_notification_duplicate.js
@@ -68,20 +68,18 @@ add_task(function* test_notification_dup
             }]
           }));
         },
         onACK: ackDone
       });
     }
   });
 
-  yield waitForPromise(notifyPromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for notifications');
-  yield waitForPromise(ackPromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for stale acknowledgement');
+  yield notifyPromise;
+  yield ackPromise;
 
   let staleRecord = yield db.getByKeyID(
     '8d2d9400-3597-4c5a-8a38-c546b0043bcc');
   strictEqual(staleRecord.version, 2, 'Wrong stale record version');
 
   let updatedRecord = yield db.getByKeyID(
     '27d1e393-03ef-4c72-a5e6-9e890dfccad0');
   strictEqual(updatedRecord.version, 3, 'Wrong updated record version');
--- a/dom/push/test/xpcshell/test_notification_error.js
+++ b/dom/push/test/xpcshell/test_notification_error.js
@@ -82,28 +82,23 @@ add_task(function* test_notification_err
         },
         // Should acknowledge all received updates, even if updating
         // IndexedDB fails.
         onACK: ackDone
       });
     }
   });
 
-  yield waitForPromise(
-    notifyPromise,
-    DEFAULT_TIMEOUT,
-    'Timed out waiting for notifications'
-  );
+  yield notifyPromise;
   ok(scopes.includes('https://example.com/a'),
     'Missing scope for notification A');
   ok(scopes.includes('https://example.com/c'),
     'Missing scope for notification C');
 
-  yield waitForPromise(ackPromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for acknowledgements');
+  yield ackPromise;
 
   let aRecord = yield db.getByIdentifiers({scope: 'https://example.com/a',
                                            originAttributes: originAttributes });
   equal(aRecord.channelID, 'f04f1e46-9139-4826-b2d1-9411b0821283',
     'Wrong channel ID for record A');
   strictEqual(aRecord.version, 2,
     'Should return the new version for record A');
 
--- a/dom/push/test/xpcshell/test_notification_http2.js
+++ b/dom/push/test/xpcshell/test_notification_http2.js
@@ -181,17 +181,16 @@ add_task(function* test_pushNotification
     }),
   ]);
 
   PushService.init({
     serverURI: serverURL,
     db
   });
 
-  yield waitForPromise(notifyPromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for notifications');
+  yield notifyPromise;
 });
 
 add_task(function* test_complete() {
   prefs.setBoolPref("network.http.spdy.enforce-tls-profile", tlsProfile);
   prefs.setBoolPref("dom.push.enabled", pushEnabled);
   prefs.setBoolPref("dom.push.connection.enabled", pushConnectionEnabled);
 });
--- a/dom/push/test/xpcshell/test_notification_incomplete.js
+++ b/dom/push/test/xpcshell/test_notification_incomplete.js
@@ -103,18 +103,17 @@ add_task(function* test_notification_inc
         },
         onACK() {
           ok(false, 'Should not acknowledge malformed updates');
         }
       });
     }
   });
 
-  yield waitForPromise(notificationPromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for incomplete notifications');
+  yield notificationPromise;
 
   let storeRecords = yield db.getAllKeyIDs();
   storeRecords.sort(({pushEndpoint: a}, {pushEndpoint: b}) =>
     compareAscending(a, b));
   recordsAreEqual(records, storeRecords);
 });
 
 function recordIsEqual(a, b) {
--- a/dom/push/test/xpcshell/test_notification_version_string.js
+++ b/dom/push/test/xpcshell/test_notification_version_string.js
@@ -52,23 +52,18 @@ add_task(function* test_notification_ver
             }]
           }));
         },
         onACK: ackDone
       });
     }
   });
 
-  let {subject: notification, data: scope} = yield waitForPromise(
-    notifyPromise,
-    DEFAULT_TIMEOUT,
-    'Timed out waiting for string notification'
-  );
+  let {subject: notification, data: scope} = yield notifyPromise;
   equal(notification, null, 'Unexpected data for Simple Push message');
 
-  yield waitForPromise(ackPromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for string acknowledgement');
+  yield ackPromise;
 
   let storeRecord = yield db.getByKeyID(
     '6ff97d56-d0c0-43bc-8f5b-61b855e1d93b');
   strictEqual(storeRecord.version, 4, 'Wrong record version');
   equal(storeRecord.quota, Infinity, 'Wrong quota');
 });
--- a/dom/push/test/xpcshell/test_permissions.js
+++ b/dom/push/test/xpcshell/test_permissions.js
@@ -119,29 +119,27 @@ add_task(function* setUp() {
             'Dropped unexpected channel ID ' + request.channelID);
           delete unregisterDefers[request.channelID];
           resolve();
         },
         onACK(request) {},
       });
     }
   });
-  yield waitForPromise(handshakePromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for handshake');
+  yield handshakePromise;
 });
 
 add_task(function* test_permissions_allow_added() {
   let subChangePromise = promiseSubscriptionChanges(1);
 
   yield PushService._onPermissionChange(
     makePushPermission('https://example.info', 'ALLOW_ACTION'),
     'added'
   );
-  let notifiedScopes = yield waitForPromise(subChangePromise, DEFAULT_TIMEOUT,
-      'Timed out waiting for notifications after adding allow');
+  let notifiedScopes = yield subChangePromise;
 
   deepEqual(notifiedScopes, [
     'https://example.info/page/2',
   ], 'Wrong scopes after adding allow');
 
   let record = yield db.getByKeyID('active-allow');
   equal(record.quota, 16,
     'Should reset quota for active records after adding allow');
@@ -154,18 +152,17 @@ add_task(function* test_permissions_allo
   let unregisterPromise = new Promise(resolve => unregisterDefers[
     'active-allow'] = resolve);
 
   yield PushService._onPermissionChange(
     makePushPermission('https://example.info', 'ALLOW_ACTION'),
     'deleted'
   );
 
-  yield waitForPromise(unregisterPromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for unregister after deleting allow');
+  yield unregisterPromise;
 
   let record = yield db.getByKeyID('active-allow');
   ok(record.isExpired(),
     'Should expire active record after deleting allow');
 });
 
 add_task(function* test_permissions_deny_added() {
   let unregisterPromise = Promise.all([
@@ -174,18 +171,17 @@ add_task(function* test_permissions_deny
     new Promise(resolve => unregisterDefers[
       'active-deny-added-2'] = resolve),
   ]);
 
   yield PushService._onPermissionChange(
     makePushPermission('https://example.net', 'DENY_ACTION'),
     'added'
   );
-  yield waitForPromise(unregisterPromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for notifications after adding deny');
+  yield unregisterPromise;
 
   let isExpired = yield allExpired(
     'active-deny-added-1',
     'expired-deny-added'
   );
   ok(isExpired, 'Should expire all registrations after adding deny');
 });
 
@@ -205,18 +201,17 @@ add_task(function* test_permissions_deny
 add_task(function* test_permissions_allow_changed() {
   let subChangePromise = promiseSubscriptionChanges(3);
 
   yield PushService._onPermissionChange(
     makePushPermission('https://example.net', 'ALLOW_ACTION'),
     'changed'
   );
 
-  let notifiedScopes = yield waitForPromise(subChangePromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for notifications after changing to allow');
+  let notifiedScopes = yield subChangePromise;
 
   deepEqual(notifiedScopes, [
     'https://example.net/eggs',
     'https://example.net/green',
     'https://example.net/ham'
   ], 'Wrong scopes after changing to allow');
 
   let droppedRecords = yield Promise.all([
@@ -232,18 +227,17 @@ add_task(function* test_permissions_deny
   let unregisterPromise = new Promise(resolve => unregisterDefers[
     'active-deny-changed'] = resolve);
 
   yield PushService._onPermissionChange(
     makePushPermission('https://example.xyz', 'DENY_ACTION'),
     'changed'
   );
 
-  yield waitForPromise(unregisterPromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for unregister after changing to deny');
+  yield unregisterPromise;
 
   let record = yield db.getByKeyID('active-deny-changed');
   ok(record.isExpired(),
     'Should expire active record after changing to allow');
 });
 
 add_task(function* test_permissions_clear() {
   let records = yield db.getAllKeyIDs();
@@ -254,16 +248,15 @@ add_task(function* test_permissions_clea
     'never-expires',
   ], 'Wrong records in database before clearing');
 
   let unregisterPromise = new Promise(resolve => unregisterDefers[
       'drop-on-clear'] = resolve);
 
   yield PushService._onPermissionChange(null, 'cleared');
 
-  yield waitForPromise(unregisterPromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for unregister requests after clearing permissions');
+  yield unregisterPromise;
 
   records = yield db.getAllKeyIDs();
   deepEqual(records.map(record => record.keyID).sort(), [
     'never-expires',
   ], 'Unrestricted registrations should not be dropped');
 });
--- a/dom/push/test/xpcshell/test_quota_exceeded.js
+++ b/dom/push/test/xpcshell/test_quota_exceeded.js
@@ -127,17 +127,15 @@ add_task(function* test_expiration_origi
         },
         // We expect to receive acks, but don't care about their
         // contents.
         onACK(request) {},
       });
     },
   });
 
-  yield waitForPromise(unregisterPromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for unregister request');
+  yield unregisterPromise;
 
-  yield waitForPromise(notifyPromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for notifications');
+  yield notifyPromise;
 
   let expiredRecord = yield db.getByKeyID('eb33fc90-c883-4267-b5cb-613969e8e349');
   strictEqual(expiredRecord.quota, 0, 'Expired record not updated');
 });
--- a/dom/push/test/xpcshell/test_quota_observer.js
+++ b/dom/push/test/xpcshell/test_quota_observer.js
@@ -93,20 +93,18 @@ add_task(function* test_expiration_histo
           equal(request.channelID, '379c0668-8323-44d2-a315-4ee83f1a9ee9', 'Dropped wrong channel ID');
           unregisterDone();
         },
         onACK(request) {},
       });
     }
   });
 
-  yield waitForPromise(subChangePromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for subscription change event on startup');
-  yield waitForPromise(unregisterPromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for unregister request');
+  yield subChangePromise;
+  yield unregisterPromise;
 
   let expiredRecord = yield db.getByKeyID('379c0668-8323-44d2-a315-4ee83f1a9ee9');
   strictEqual(expiredRecord.quota, 0, 'Expired record not updated');
 
   let notifiedScopes = [];
   subChangePromise = promiseObserverNotification(PushServiceComponent.subscriptionChangeTopic, (subject, data) => {
     notifiedScopes.push(data);
     return notifiedScopes.length == 2;
@@ -129,18 +127,17 @@ add_task(function* test_expiration_histo
     uri: 'https://example.com/another-page',
     title: 'Infrequently-visited page',
     visitDate: Date.now() * 1000,
     transition: Ci.nsINavHistoryService.TRANSITION_LINK
   });
   Services.obs.notifyObservers(null, 'idle-daily', '');
 
   // And we should receive notifications for both scopes.
-  yield waitForPromise(subChangePromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for subscription change events');
+  yield subChangePromise;
   deepEqual(notifiedScopes.sort(), [
     'https://example.com/auctions',
     'https://example.com/deals'
   ], 'Wrong scopes for subscription changes');
 
   let aRecord = yield db.getByKeyID('379c0668-8323-44d2-a315-4ee83f1a9ee9');
   ok(!aRecord, 'Should drop expired record');
 
--- a/dom/push/test/xpcshell/test_quota_with_notification.js
+++ b/dom/push/test/xpcshell/test_quota_with_notification.js
@@ -98,17 +98,15 @@ add_task(function* test_expiration_origi
         },
         // We expect to receive acks, but don't care about their
         // contents.
         onACK(request) {},
       });
     },
   });
 
-  yield waitForPromise(notifyPromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for notifications');
+  yield notifyPromise;
 
-  yield waitForPromise(updateQuotaPromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for quota to be updated');
+  yield updateQuotaPromise;
 
   let expiredRecord = yield db.getByKeyID('f56645a9-1f32-4655-92ad-ddc37f6d54fb');
   notStrictEqual(expiredRecord.quota, 0, 'Expired record not updated');
 });
--- a/dom/push/test/xpcshell/test_reconnect_retry.js
+++ b/dom/push/test/xpcshell/test_reconnect_retry.js
@@ -63,12 +63,12 @@ add_task(function* test_reconnect_retry(
   let retryEndpoint = 'https://example.org/push/' + channelID;
   equal(registration.endpoint, retryEndpoint, 'Wrong endpoint for retried request');
 
   registration = yield PushService.register({
     scope: 'https://example.com/page/2',
     originAttributes: ChromeUtils.originAttributesToSuffix(
       { appId: Ci.nsIScriptSecurityManager.NO_APP_ID, inIsolatedMozBrowser: false }),
   });
-  notEqual(registration.endpoint, retryEndpoint, 'Wrong endpoint for new request')
+  notEqual(registration.endpoint, retryEndpoint, 'Wrong endpoint for new request');
 
   equal(registers, 3, 'Wrong registration count');
 });
--- a/dom/push/test/xpcshell/test_register_case.js
+++ b/dom/push/test/xpcshell/test_register_case.js
@@ -38,24 +38,20 @@ add_task(function* test_register_case() 
             status: 200,
             pushEndpoint: 'https://example.com/update/case'
           }));
         }
       });
     }
   });
 
-  let newRecord = yield waitForPromise(
-    PushService.register({
-      scope: 'https://example.net/case',
-      originAttributes: ChromeUtils.originAttributesToSuffix(
-        { appId: Ci.nsIScriptSecurityManager.NO_APP_ID, inIsolatedMozBrowser: false }),
-    }),
-    DEFAULT_TIMEOUT,
-    'Mixed-case register response timed out'
-  );
+  let newRecord = yield PushService.register({
+    scope: 'https://example.net/case',
+    originAttributes: ChromeUtils.originAttributesToSuffix(
+      { appId: Ci.nsIScriptSecurityManager.NO_APP_ID, inIsolatedMozBrowser: false }),
+  });
   equal(newRecord.endpoint, 'https://example.com/update/case',
     'Wrong push endpoint in registration record');
 
   let record = yield db.getByPushEndpoint('https://example.com/update/case');
   equal(record.scope, 'https://example.net/case',
     'Wrong scope in database record');
 });
--- a/dom/push/test/xpcshell/test_register_flush.js
+++ b/dom/push/test/xpcshell/test_register_flush.js
@@ -75,22 +75,20 @@ add_task(function* test_register_flush()
 
   let newRecord = yield PushService.register({
     scope: 'https://example.com/page/2',
     originAttributes: '',
   });
   equal(newRecord.endpoint, 'https://example.org/update/2',
     'Wrong push endpoint in record');
 
-  let {data: scope} = yield waitForPromise(notifyPromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for notification');
+  let {data: scope} = yield notifyPromise;
   equal(scope, 'https://example.com/page/1', 'Wrong notification scope');
 
-  yield waitForPromise(ackPromise, DEFAULT_TIMEOUT,
-     'Timed out waiting for acknowledgements');
+  yield ackPromise;
 
   let prevRecord = yield db.getByKeyID(
     '9bcc7efb-86c7-4457-93ea-e24e6eb59b74');
   equal(prevRecord.pushEndpoint, 'https://example.org/update/1',
     'Wrong existing push endpoint');
   strictEqual(prevRecord.version, 3,
     'Should record version updates sent before register responses');
 
--- a/dom/push/test/xpcshell/test_register_invalid_json.js
+++ b/dom/push/test/xpcshell/test_register_invalid_json.js
@@ -49,12 +49,11 @@ add_task(function* test_register_invalid
     PushService.register({
       scope: 'https://example.net/page/invalid-json',
       originAttributes: ChromeUtils.originAttributesToSuffix(
         { appId: Ci.nsIScriptSecurityManager.NO_APP_ID, inIsolatedMozBrowser: false }),
     }),
     'Expected error for invalid JSON response'
   );
 
-  yield waitForPromise(helloPromise, DEFAULT_TIMEOUT,
-    'Reconnect after invalid JSON response timed out');
+  yield helloPromise;
   equal(registers, 1, 'Wrong register count');
 });
--- a/dom/push/test/xpcshell/test_register_no_id.js
+++ b/dom/push/test/xpcshell/test_register_no_id.js
@@ -53,12 +53,11 @@ add_task(function* test_register_no_id()
     PushService.register({
       scope: 'https://example.com/incomplete',
       originAttributes: ChromeUtils.originAttributesToSuffix(
         { appId: Ci.nsIScriptSecurityManager.NO_APP_ID, inIsolatedMozBrowser: false }),
     }),
     'Expected error for incomplete register response'
   );
 
-  yield waitForPromise(helloPromise, DEFAULT_TIMEOUT,
-    'Reconnect after incomplete register response timed out');
+  yield helloPromise;
   equal(registers, 1, 'Wrong register count');
 });
--- a/dom/push/test/xpcshell/test_register_request_queue.js
+++ b/dom/push/test/xpcshell/test_register_request_queue.js
@@ -48,16 +48,15 @@ add_task(function* test_register_request
       { appId: Ci.nsIScriptSecurityManager.NO_APP_ID, inIsolatedMozBrowser: false }),
   });
   let secondRegister = PushService.register({
     scope: 'https://example.com/page/1',
     originAttributes: ChromeUtils.originAttributesToSuffix(
       { appId: Ci.nsIScriptSecurityManager.NO_APP_ID, inIsolatedMozBrowser: false }),
   });
 
-  yield waitForPromise(Promise.all([
+  yield Promise.all([
     rejects(firstRegister, 'Should time out the first request'),
     rejects(secondRegister, 'Should time out the second request')
-  ]), DEFAULT_TIMEOUT, 'Queued requests did not time out');
+  ]);
 
-  yield waitForPromise(helloPromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for reconnect');
+  yield helloPromise;
 });
--- a/dom/push/test/xpcshell/test_register_rollback.js
+++ b/dom/push/test/xpcshell/test_register_rollback.js
@@ -76,13 +76,12 @@ add_task(function* test_register_rollbac
       scope: 'https://example.com/storage-error',
       originAttributes: ChromeUtils.originAttributesToSuffix(
         { appId: Ci.nsIScriptSecurityManager.NO_APP_ID, inIsolatedMozBrowser: false }),
     }),
     'Expected error for unregister database failure'
   );
 
   // Should send an out-of-band unregister request.
-  yield waitForPromise(unregisterPromise, DEFAULT_TIMEOUT,
-    'Unregister request timed out');
+  yield unregisterPromise;
   equal(handshakes, 1, 'Wrong handshake count');
   equal(registers, 1, 'Wrong register count');
 });
--- a/dom/push/test/xpcshell/test_register_timeout.js
+++ b/dom/push/test/xpcshell/test_register_timeout.js
@@ -78,15 +78,11 @@ add_task(function* test_register_timeout
         { appId: Ci.nsIScriptSecurityManager.NO_APP_ID, inIsolatedMozBrowser: false }),
     }),
     'Expected error for request timeout'
   );
 
   let record = yield db.getByKeyID(channelID);
   ok(!record, 'Should not store records for timed-out responses');
 
-  yield waitForPromise(
-    timeoutPromise,
-    DEFAULT_TIMEOUT,
-    'Reconnect timed out'
-  );
+  yield timeoutPromise;
   equal(registers, 1, 'Should not handle timed-out register requests');
 });
--- a/dom/push/test/xpcshell/test_register_wrong_id.js
+++ b/dom/push/test/xpcshell/test_register_wrong_id.js
@@ -59,12 +59,11 @@ add_task(function* test_register_wrong_i
     PushService.register({
       scope: 'https://example.com/mismatched',
       originAttributes: ChromeUtils.originAttributesToSuffix(
         { appId: Ci.nsIScriptSecurityManager.NO_APP_ID, inIsolatedMozBrowser: false }),
     }),
     'Expected error for mismatched register reply'
   );
 
-  yield waitForPromise(helloPromise, DEFAULT_TIMEOUT,
-    'Reconnect after mismatched register reply timed out');
+  yield helloPromise;
   equal(registers, 1, 'Wrong register count');
 });
--- a/dom/push/test/xpcshell/test_register_wrong_type.js
+++ b/dom/push/test/xpcshell/test_register_wrong_type.js
@@ -53,12 +53,11 @@ add_task(function* test_register_wrong_t
     PushService.register({
       scope: 'https://example.com/mistyped',
       originAttributes: ChromeUtils.originAttributesToSuffix(
         { appId: Ci.nsIScriptSecurityManager.NO_APP_ID, inIsolatedMozBrowser: false }),
     }),
     'Expected error for non-string channel ID'
   );
 
-  yield waitForPromise(helloPromise, DEFAULT_TIMEOUT,
-    'Reconnect after sending non-string channel ID timed out');
+  yield helloPromise;
   equal(registers, 1, 'Wrong register count');
 });
--- a/dom/push/test/xpcshell/test_registration_success.js
+++ b/dom/push/test/xpcshell/test_registration_success.js
@@ -59,21 +59,17 @@ add_task(function* test_registration_suc
             uaid: userAgentID
           }));
           handshakeDone();
         }
       });
     }
   });
 
-  yield waitForPromise(
-    handshakePromise,
-    DEFAULT_TIMEOUT,
-    'Timed out waiting for handshake'
-  );
+  yield handshakePromise;
 
   let registration = yield PushService.registration({
     scope: 'https://example.net/a',
     originAttributes: '',
   });
   equal(
     registration.endpoint,
     'https://example.com/update/same-manifest/1',
--- a/dom/push/test/xpcshell/test_retry_ws.js
+++ b/dom/push/test/xpcshell/test_retry_ws.js
@@ -53,18 +53,14 @@ add_task(function* test_ws_retry() {
             return;
           }
           this.serverInterrupt();
         },
       });
     },
   });
 
-  yield waitForPromise(
-    handshakePromise,
-    45000,
-    'Timed out waiting for successful handshake'
-  );
+  yield handshakePromise;
   [25, 50, 100, 200, 400, 800, 1600, 3200, 6400, 10000].forEach(function(minDelay, index) {
     ok(alarmDelays[index] >= minDelay, `Should wait at least ${
       minDelay}ms before attempt ${index + 1}`);
   });
 });
--- a/dom/push/test/xpcshell/test_unregister_error.js
+++ b/dom/push/test/xpcshell/test_unregister_error.js
@@ -60,11 +60,10 @@ add_task(function* test_unregister_error
     scope: 'https://example.net/page/failure',
     originAttributes: '',
   });
 
   let result = yield db.getByKeyID(channelID);
   ok(!result, 'Deleted push record exists');
 
   // Make sure we send a request to the server.
-  yield waitForPromise(unregisterPromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for unregister');
+  yield unregisterPromise;
 });
--- a/dom/push/test/xpcshell/test_unregister_invalid_json.js
+++ b/dom/push/test/xpcshell/test_unregister_invalid_json.js
@@ -77,11 +77,10 @@ add_task(function* test_unregister_inval
     originAttributes: ChromeUtils.originAttributesToSuffix(
       { appId: Ci.nsIScriptSecurityManager.NO_APP_ID, inIsolatedMozBrowser: false }),
   });
   record = yield db.getByKeyID(
     '057caa8f-9b99-47ff-891c-adad18ce603e');
   ok(!record,
     'Failed to delete unregistered record after receiving invalid JSON');
 
-  yield waitForPromise(unregisterPromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for unregister');
+  yield unregisterPromise;
 });
--- a/dom/push/test/xpcshell/test_unregister_success.js
+++ b/dom/push/test/xpcshell/test_unregister_success.js
@@ -55,11 +55,10 @@ add_task(function* test_unregister_succe
 
   yield PushService.unregister({
     scope: 'https://example.com/page/unregister-success',
     originAttributes: '',
   });
   let record = yield db.getByKeyID(channelID);
   ok(!record, 'Unregister did not remove record');
 
-  yield waitForPromise(unregisterPromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for unregister');
+  yield unregisterPromise;
 });
--- a/dom/push/test/xpcshell/test_updateRecordNoEncryptionKeys_http2.js
+++ b/dom/push/test/xpcshell/test_updateRecordNoEncryptionKeys_http2.js
@@ -62,16 +62,15 @@ add_task(function* test1() {
   let notifyPromise = promiseObserverNotification(PushServiceComponent.subscriptionChangeTopic,
                                                   _ => true);
 
   PushService.init({
     serverURI: serverURL + "/subscribe",
     db
   });
 
-  yield waitForPromise(notifyPromise, DEFAULT_TIMEOUT,
-    'Timed out waiting for notifications');
+  yield notifyPromise;
 
   let aRecord = yield db.getByKeyID(serverURL + '/subscriptionNoKey');
   ok(aRecord, 'The record should still be there');
   ok(aRecord.p256dhPublicKey, 'There should be a public key');
   ok(aRecord.p256dhPrivateKey, 'There should be a private key');
 });