Bug 1426467: Part 1: Rewrite test_cache_worker_gc.html to use async functions. r=baku
authorJim Blandy <jimb@mozilla.com>
Mon, 22 Oct 2018 15:34:21 +0000
changeset 490955 14b5c82201e5ea74962f98b6accc9d9f686c45fe
parent 490954 bc350062ad1b45d628e05ee715ff51d1f4d8bcdc
child 490956 307ddcb2187bd1a1f95e537d745c7dfc4de11d24
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersbaku
bugs1426467
milestone65.0a1
Bug 1426467: Part 1: Rewrite test_cache_worker_gc.html to use async functions. r=baku This just cleans up the function a bit to make the next change easier to see. No behavior change intended. Differential Revision: https://phabricator.services.mozilla.com/D9217
dom/cache/test/mochitest/test_cache_worker_gc.html
--- a/dom/cache/test/mochitest/test_cache_worker_gc.html
+++ b/dom/cache/test/mochitest/test_cache_worker_gc.html
@@ -24,23 +24,24 @@ function startWorker() {
 }
 
 function gc() {
   return new Promise(resolve => {
     SpecialPowers.exactGC(resolve);
   });
 }
 
-var weakWorker;
+SimpleTest.waitForExplicitFinish();
 
-SimpleTest.waitForExplicitFinish();
-startWorker().then(w => {
-  weakWorker = SpecialPowers.Cu.getWeakReference(w);
+async function test() {
+  let w = await startWorker();
+  let weakWorker = SpecialPowers.Cu.getWeakReference(w);
   ok(weakWorker, 'worker supports weak reference');
-}).then(_ => {
-  return gc();
-}).then(_ => {
+  w = null;
+  await gc();
   ok(!weakWorker.get(), 'worker weak reference should be garbage collected');
   SimpleTest.finish();
-});
+}
+
+test();
 </script>
 </body>
 </html>