Bug 1426467: Part 2: Give the weak reference in test_cache_worker_gc.html more time to decay. r=baku
authorJim Blandy <jimb@mozilla.com>
Mon, 22 Oct 2018 15:35:32 +0000
changeset 490989 135b9518b925cfbd47e251a044c38d4304edf12b
parent 490966 7965ea047d6820f81670821b042654d3f41692c4
child 490990 52e7a7889da0f493c65fa0aa2fcea6a0e1f6a06b
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersbaku
bugs1426467
milestone65.0a1
Bug 1426467: Part 2: Give the weak reference in test_cache_worker_gc.html more time to decay. r=baku Certain runnables sent from the worker to the content window must be delayed if the content is paused in the JavaScript debugger. For example, delivering onmessage events while stopped at a breakpoint would violate the DOM's run-to-completion rule. However, other sorts of runnables must be delivered promptly if the worker is continue to function properly. Thus, the later patches in this bug that implement the delay for the debugger may, in general, reorder the delivery of some runnables. So whereas previously runnables sent from the worker to the main thread could simply assert that the worker was still alive, delayed runnables will now need to use a WorkerRef to hold the worker alive until they are processed. This affects the timing with which weak references to workers decay. Since there is no solid way to test such GC-sensitive APIs, this patch simply requests a second GC. This is not guaranteed to pass, but then again, the test as it stands is not guaranteed to pass either. Depends on D9217 Differential Revision: https://phabricator.services.mozilla.com/D9218
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
@@ -32,16 +32,17 @@ function gc() {
 SimpleTest.waitForExplicitFinish();
 
 async function test() {
   let w = await startWorker();
   let weakWorker = SpecialPowers.Cu.getWeakReference(w);
   ok(weakWorker, 'worker supports weak reference');
   w = null;
   await gc();
+  await gc();
   ok(!weakWorker.get(), 'worker weak reference should be garbage collected');
   SimpleTest.finish();
 }
 
 test();
 </script>
 </body>
 </html>